summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2023-08-10 22:48:37 +0800
committerMole Shang <[email protected]>2024-03-01 22:30:16 +0800
commit085c2a88d44ebac41c64c32ee6b796ff64e5331f (patch)
tree18d01810dae57b364b4234477ece4dc6cca59a56
parent2a4121c0e76f988a45b91145a9e2f50595817f81 (diff)
downloadhinata-085c2a88d44ebac41c64c32ee6b796ff64e5331f.tar.gz
hinata-085c2a88d44ebac41c64c32ee6b796ff64e5331f.tar.bz2
hinata-085c2a88d44ebac41c64c32ee6b796ff64e5331f.zip
status: support large file sizes on 64bit systems
Convert all unsigned long nums to unsigned long long in order to let the UI safely display sizes >= 4GB
-rw-r--r--src/process_url.c6
-rw-r--r--src/process_url.h3
-rw-r--r--src/status.h4
-rw-r--r--src/utils/size_info.c2
-rw-r--r--src/utils/size_info.h2
5 files changed, 9 insertions, 8 deletions
diff --git a/src/process_url.c b/src/process_url.c
index e09647a..a8dadc9 100644
--- a/src/process_url.c
+++ b/src/process_url.c
@@ -245,7 +245,7 @@ static int parse_url(const char *URL, const char *outdir, char *fn) {
return 0;
}
-bool get_info(const char *URL, long *psize, char **p_content_type,
+bool get_info(const char *URL, curl_off_t *psize, char **p_content_type,
char **p_cookie) {
CURL *curl;
long resp_code;
@@ -528,8 +528,8 @@ void poll_status(status_t *stat) {
for (unsigned char i = 0; i < curl_conf->total_thrd; i++) {
curl_conf->dlnow += curl_conf->dlnow_per_thrd[i];
}
- stat->cur = (unsigned long)curl_conf->dlnow;
- stat->total = (unsigned long)curl_conf->dltotal;
+ stat->cur = (unsigned long long)curl_conf->dlnow;
+ stat->total = (unsigned long long)curl_conf->dltotal;
DEBUG_PRINT("success_thrd: %hhu, total_thrd: %hhu, is_done: %s\n",
curl_conf->success_thrd, curl_conf->total_thrd,
stat->is_done ? "yes" : "no");
diff --git a/src/process_url.h b/src/process_url.h
index a98d05a..72a650f 100644
--- a/src/process_url.h
+++ b/src/process_url.h
@@ -2,6 +2,7 @@
#define PROCESS_URL_H_
#include <curl/curl.h>
+#include <curl/system.h>
#include <limits.h>
#include <stdbool.h>
@@ -55,7 +56,7 @@ void set_referer(char *referer);
int get(const char *, char **);
-bool get_info(const char *URL, long *psize, char **p_content_type,
+bool get_info(const char *URL, curl_off_t *psize, char **p_content_type,
char **p_cookie);
void add_url(const char *, const char *, const char *, callback_t,
diff --git a/src/status.h b/src/status.h
index 97f8a4e..5adfff5 100644
--- a/src/status.h
+++ b/src/status.h
@@ -6,8 +6,8 @@
typedef enum stat_type { SIZE_BYTES, TIME_SECS } stat_type_t;
typedef struct status {
- unsigned long cur;
- unsigned long total;
+ unsigned long long cur;
+ unsigned long long total;
bool is_done;
stat_type_t type;
} status_t;
diff --git a/src/utils/size_info.c b/src/utils/size_info.c
index 6b238bb..b846ae6 100644
--- a/src/utils/size_info.c
+++ b/src/utils/size_info.c
@@ -2,7 +2,7 @@
static const char *size_unit_map[] = {"B", "KB", "MB", "GB"};
-size_info_t num2sizeinfo(const unsigned long n) {
+size_info_t num2sizeinfo(const unsigned long long n) {
size_info_t size_info = {0};
long double tmp = (long double)n;
if ((unsigned long)tmp / 1024 == 0) {
diff --git a/src/utils/size_info.h b/src/utils/size_info.h
index e0994c1..238ddf8 100644
--- a/src/utils/size_info.h
+++ b/src/utils/size_info.h
@@ -9,6 +9,6 @@ typedef struct size_info {
const char *unit_str;
} size_info_t;
-size_info_t num2sizeinfo(const unsigned long n);
+size_info_t num2sizeinfo(const unsigned long long n);
#endif