12 * We detect based on the cURL version if multi-transfer is
13 * usable in this implementation and define this symbol accordingly.
14 * This is not something Makefile should set nor users should pass
19 #if LIBCURL_VERSION_NUM >= 0x071000
20 #define USE_CURL_MULTI
21 #define DEFAULT_MAX_REQUESTS 5
24 #if LIBCURL_VERSION_NUM < 0x070704
25 #define curl_global_cleanup() do { /* nothing */ } while(0)
27 #if LIBCURL_VERSION_NUM < 0x070800
28 #define curl_global_init(a) do { /* nothing */ } while(0)
31 #if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000)
32 #define NO_CURL_EASY_DUPHANDLE
35 #if LIBCURL_VERSION_NUM < 0x070a03
36 #define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND
45 struct active_request_slot
53 struct slot_results
*results
;
55 void (*callback_func
)(void *data
);
56 struct active_request_slot
*next
;
65 /* Curl request read/write callbacks */
66 extern size_t fread_buffer(void *ptr
, size_t eltsize
, size_t nmemb
,
67 struct buffer
*buffer
);
68 extern size_t fwrite_buffer(const void *ptr
, size_t eltsize
,
69 size_t nmemb
, struct strbuf
*buffer
);
70 extern size_t fwrite_null(const void *ptr
, size_t eltsize
,
71 size_t nmemb
, struct strbuf
*buffer
);
73 /* Slot lifecycle functions */
74 extern struct active_request_slot
*get_active_slot(void);
75 extern int start_active_slot(struct active_request_slot
*slot
);
76 extern void run_active_slot(struct active_request_slot
*slot
);
77 extern void finish_all_active_slots(void);
78 extern void release_active_slot(struct active_request_slot
*slot
);
81 extern void fill_active_slots(void);
82 extern void add_fill_function(void *data
, int (*fill
)(void *));
83 extern void step_active_slots(void);
86 extern void http_init(void);
87 extern void http_cleanup(void);
89 extern int data_received
;
90 extern int active_requests
;
92 extern char curl_errorstr
[CURL_ERROR_SIZE
];
94 static inline int missing__target(int code
, int result
)
96 return /* file:// URL -- do we ever use one??? */
97 (result
== CURLE_FILE_COULDNT_READ_FILE
) ||
98 /* http:// and https:// URL */
99 (code
== 404 && result
== CURLE_HTTP_RETURNED_ERROR
) ||
101 (code
== 550 && result
== CURLE_FTP_COULDNT_RETR_FILE
)
105 #define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
107 extern int http_fetch_ref(const char *base
, const char *ref
, unsigned char *sha1
);