diff options
author | Mole Shang <[email protected]> | 2023-07-25 09:27:26 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-08-05 23:19:46 +0800 |
commit | ed8f6df90b0c39835198d5b7af4bbd391362f180 (patch) | |
tree | 907ba31bac854eb5dc8a2781825e24c049b10580 /src/process_url.h | |
download | hinata-ed8f6df90b0c39835198d5b7af4bbd391362f180.tar.gz hinata-ed8f6df90b0c39835198d5b7af4bbd391362f180.tar.bz2 hinata-ed8f6df90b0c39835198d5b7af4bbd391362f180.zip |
hinata: initial commit
Diffstat (limited to 'src/process_url.h')
-rw-r--r-- | src/process_url.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/process_url.h b/src/process_url.h new file mode 100644 index 0000000..03023b5 --- /dev/null +++ b/src/process_url.h @@ -0,0 +1,59 @@ +#ifndef PROCESS_URL_H_ +#define PROCESS_URL_H_ + +#include <curl/curl.h> +#include <limits.h> +#include <stdbool.h> + +#include "utils.h" + +#define MAX_THREAD 6 +#define MAX_THREAD_SIZE 10485760 + +#define ERRTOSTRING(err) curl_easy_strerror(err) +#define logerr(X) \ + _Generic((X), CURLcode \ + : logerr_b, CURLHcode \ + : logerr_h, CURLUcode \ + : logerr_u)(X) + +typedef struct curl_conf { + curl_off_t dlnow_per_thrd[MAX_THREAD]; + curl_off_t dlnow; + curl_off_t dltotal; + unsigned char success_thrd; + unsigned char total_thrd; + char *URL; + char outfn[USHRT_MAX]; + str_array_t partfn; + FILE *fplist[MAX_THREAD]; +} curl_conf_t; + +typedef struct thrd_info { + unsigned char no; + curl_conf_t *curl_c; + char range[UCHAR_MAX]; +} thrd_info_t; + +typedef struct status { + curl_off_t cur; + curl_off_t total; + bool is_done; +} status_t; + +typedef struct str_data { + char *string; + size_t len; +} str_data_t; + +void curl_init(); + +void curl_cleanup(status_t *); + +void poll_status(status_t *); + +int get(const char *, char **); + +void add_url(const char *, const char *, const char *, const char *); + +#endif |