aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-12-19 00:31:40 +0100
committerJan200101 <sentrycraft123@gmail.com>2020-12-19 00:31:40 +0100
commit79e6835eb9478680530e66e12dc365993a08b788 (patch)
tree477a96ea6f0ae70df4c1c0daa3e3dcfc3337bcc3 /src
parent24288734e78aa2242b86dde8c770278fa1f5e05c (diff)
downloadpolecat-79e6835eb9478680530e66e12dc365993a08b788.tar.gz
polecat-79e6835eb9478680530e66e12dc365993a08b788.zip
remove useless struct, add json length type macro
- previously used progress struct was a leftover from when libcurl examples were used - json_object_array_length returns int pre 0.13 and site_t on any other version
Diffstat (limited to 'src')
-rw-r--r--src/common.h10
-rw-r--r--src/dxvk.c4
-rw-r--r--src/net.c15
-rw-r--r--src/net.h1
-rw-r--r--src/wine.c4
5 files changed, 15 insertions, 19 deletions
diff --git a/src/common.h b/src/common.h
index 5916b99..a77d0a2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -39,6 +39,16 @@
#define UNUSED
#endif
+#include <json.h>
+
+// since json-c 0.13 json_object_array_length returns a size_t
+#if defined(JSON_C_MINOR_VERSION) && JSON_C_MINOR_VERSION >= 13
+#define JSON_LENGTH_TYPE size_t
+#else
+#define JSON_LENGTH_TYPE int
+#endif
+
+
struct MemoryStruct {
uint8_t* memory;
size_t size;
diff --git a/src/dxvk.c b/src/dxvk.c
index 888d963..ffe9262 100644
--- a/src/dxvk.c
+++ b/src/dxvk.c
@@ -36,7 +36,7 @@ COMMAND(dxvk, download)
char* choice = argv[1];
- for (size_t i = 0; i < json_object_array_length(runner); ++i)
+ for (JSON_LENGTH_TYPE i = 0; i < json_object_array_length(runner); ++i)
{
value = json_object_array_get_idx(runner, i);
json_object_object_get_ex(value, "tag_name", &temp);
@@ -140,7 +140,7 @@ COMMAND(dxvk, list)
int istty = isatty(STDOUT_FILENO);
if (istty) puts("Installable DXVK versions:");
- for (size_t i = 0; i < json_object_array_length(runner); ++i)
+ for (JSON_LENGTH_TYPE i = 0; i < json_object_array_length(runner); ++i)
{
struct json_object* version = json_object_array_get_idx(runner, i);
struct json_object* name;
diff --git a/src/net.c b/src/net.c
index e7397f6..c20f076 100644
--- a/src/net.c
+++ b/src/net.c
@@ -10,11 +10,6 @@
#include "net.h"
#include "common.h"
-struct progress {
- TIMETYPE lastruntime;
- CURL *curl;
-};
-
static size_t memoryCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
size_t realsize = size * nmemb;
@@ -35,14 +30,8 @@ static size_t memoryCallback(void* contents, size_t size, size_t nmemb, void* us
return realsize;
}
-static int xferinfo(void *p, curl_off_t dltotal, curl_off_t dlnow, UNUSED curl_off_t ultotal, UNUSED curl_off_t ulnow)
+static int xferinfo(UNUSED void *p, curl_off_t dltotal, curl_off_t dlnow, UNUSED curl_off_t ultotal, UNUSED curl_off_t ulnow)
{
- struct progress *myp = (struct progress *)p;
- CURL *curl = myp->curl;
- TIMETYPE curtime = 0;
-
- curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &curtime);
-
curl_off_t progress = 0;
if (dltotal != 0)
progress = ((float)dlnow / dltotal) * 100;
@@ -58,7 +47,6 @@ struct MemoryStruct* downloadToRam(const char* URL, long noprogress)
{
CURL* curl_handle;
CURLcode res = CURLE_OK;
- struct progress prog;
if (!isatty(STDERR_FILENO))
noprogress = 1L;
@@ -80,7 +68,6 @@ struct MemoryStruct* downloadToRam(const char* URL, long noprogress)
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, xferinfo);
- curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, &prog);
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, noprogress);
res = curl_easy_perform(curl_handle);
diff --git a/src/net.h b/src/net.h
index 25790d9..722c6bb 100644
--- a/src/net.h
+++ b/src/net.h
@@ -4,7 +4,6 @@
#include <curl/curl.h>
#include <json.h>
-#define TIMETYPE curl_off_t
#define TIMEOPT CURLINFO_TOTAL_TIME_T
size_t WriteMemoryCallback(void*, size_t, size_t, void*);
diff --git a/src/wine.c b/src/wine.c
index 29283cd..46bfd46 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -45,7 +45,7 @@ COMMAND(wine, download)
char* choice = argv[i];
- for (size_t i = 0; i < json_object_array_length(versions); ++i)
+ for (JSON_LENGTH_TYPE i = 0; i < json_object_array_length(versions); ++i)
{
value = json_object_array_get_idx(versions, i);
json_object_object_get_ex(value, "version", &temp);
@@ -165,7 +165,7 @@ COMMAND(wine, list)
if(intty) puts("Installable wine versions:");
- for (size_t i = 0; i < json_object_array_length(versions); ++i)
+ for (JSON_LENGTH_TYPE i = 0; i < json_object_array_length(versions); ++i)
{
value = json_object_array_get_idx(versions, i);
json_object_object_get_ex(value, "version", &val);