X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=libcurl.h;h=f8de728e34a2e7fd059bf0ad6039fd011fdff454;hb=88afce3b344f4f271c771c1c674c41e327c6c625;hp=f92a23875cf22e58294f95c79f098794a25e979b;hpb=ea9b3b9a3b5e29dffb47faf7a8bf2fe61aa61517;p=xonotic%2Fdarkplaces.git diff --git a/libcurl.h b/libcurl.h index f92a2387..f8de728e 100644 --- a/libcurl.h +++ b/libcurl.h @@ -1,11 +1,28 @@ +enum +{ + CURLCBSTATUS_OK = 0, + CURLCBSTATUS_FAILED = -1, // failed for generic reason (e.g. buffer too small) + CURLCBSTATUS_ABORTED = -2, // aborted by curl --cancel + CURLCBSTATUS_SERVERERROR = -3, // only used if no HTTP status code is available + CURLCBSTATUS_UNKNOWN = -4 // should never happen +}; +typedef void (*curl_callback_t) (int status, size_t length_received, unsigned char *buffer, void *cbdata); +// code is one of the CURLCBSTATUS constants, or the HTTP error code (when > 0). + void Curl_Run(); qboolean Curl_Running(); -void Curl_Begin(const char *URL, const char *name, qboolean ispak, qboolean forthismap); +qboolean Curl_Begin_ToFile(const char *URL, const char *name, qboolean ispak, qboolean forthismap); +qboolean Curl_Begin_ToMemory(const char *URL, unsigned char *buf, size_t bufsize, curl_callback_t callback, void *cbdata); + // NOTE: if it returns false, the callback will NOT get called, so free your buffer then! +void Curl_Cancel_ToMemory(curl_callback_t callback, void *cbdata); + // removes all downloads with the given callback and cbdata (this does NOT call the callbacks!) void Curl_Init(); void Curl_Init_Commands(); void Curl_Shutdown(); void Curl_CancelAll(); void Curl_Clear_forthismap(); +qboolean Curl_Have_forthismap(); +void Curl_Register_predownload(); void Curl_ClearRequirements(); void Curl_RequireFile(const char *filename);