]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - libcurl.h
5b861278f4a5763dd892714ebd5fe090ebcf0f2d
[xonotic/darkplaces.git] / libcurl.h
1 enum
2 {
3         CURLCBSTATUS_OK = 0,
4         CURLCBSTATUS_FAILED = -1, // failed for generic reason (e.g. buffer too small)
5         CURLCBSTATUS_ABORTED = -2, // aborted by curl --cancel
6         CURLCBSTATUS_SERVERERROR = -3, // only used if no HTTP status code is available
7         CURLCBSTATUS_UNKNOWN = -4 // should never happen
8 };
9 typedef void (*curl_callback_t) (int status, size_t length_received, unsigned char *buffer, void *cbdata);
10 // code is one of the CURLCBSTATUS constants, or the HTTP error code (when > 0).
11
12 void Curl_Run();
13 qboolean Curl_Running();
14 qboolean Curl_Begin_ToFile(const char *URL, const char *name, qboolean ispak, qboolean forthismap);
15 qboolean Curl_Begin_ToMemory(const char *URL, unsigned char *buf, size_t bufsize, curl_callback_t callback, void *cbdata);
16         // NOTE: if it returns false, the callback will NOT get called, so free your buffer then!
17 void Curl_Init();
18 void Curl_Init_Commands();
19 void Curl_Shutdown();
20 void Curl_CancelAll();
21 void Curl_Clear_forthismap();
22 qboolean Curl_Have_forthismap();
23 void Curl_Register_predownload();
24
25 void Curl_ClearRequirements();
26 void Curl_RequireFile(const char *filename);
27 void Curl_SendRequirements();
28
29 typedef struct Curl_downloadinfo_s
30 {
31         char filename[MAX_QPATH];
32         double progress;
33         double speed;
34         qboolean queued;
35 }
36 Curl_downloadinfo_t;
37 Curl_downloadinfo_t *Curl_GetDownloadInfo(int *nDownloads, const char **additional_info);
38         // this may and should be Z_Free()ed
39         // the result is actually an array
40         // an additional info string may be returned in additional_info as a
41         // pointer to a static string (but the argument may be NULL if the caller
42         // does not care)