11 #if LIBCURL_VERSION_NUM >= 0x071000
12 #define USE_CURL_MULTI
13 #define DEFAULT_MAX_REQUESTS 5
16 #if LIBCURL_VERSION_NUM < 0x070704
17 #define curl_global_cleanup() do { /* nothing */ } while(0)
19 #if LIBCURL_VERSION_NUM < 0x070800
20 #define curl_global_init(a) do { /* nothing */ } while(0)
23 #if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000)
24 #define NO_CURL_EASY_DUPHANDLE
27 #if LIBCURL_VERSION_NUM < 0x070a03
28 #define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND
37 struct active_request_slot
45 struct slot_results
*results
;
47 void (*callback_func
)(void *data
);
48 struct active_request_slot
*next
;
57 /* Curl request read/write callbacks */
58 extern size_t fread_buffer(void *ptr
, size_t eltsize
, size_t nmemb
,
59 struct buffer
*buffer
);
60 extern size_t fwrite_buffer(const void *ptr
, size_t eltsize
,
61 size_t nmemb
, struct strbuf
*buffer
);
62 extern size_t fwrite_null(const void *ptr
, size_t eltsize
,
63 size_t nmemb
, struct strbuf
*buffer
);
65 /* Slot lifecycle functions */
66 extern struct active_request_slot
*get_active_slot(void);
67 extern int start_active_slot(struct active_request_slot
*slot
);
68 extern void run_active_slot(struct active_request_slot
*slot
);
69 extern void finish_all_active_slots(void);
70 extern void release_active_slot(struct active_request_slot
*slot
);
73 extern void fill_active_slots(void);
74 extern void add_fill_function(void *data
, int (*fill
)(void *));
75 extern void step_active_slots(void);
78 extern void http_init(void);
79 extern void http_cleanup(void);
81 extern int data_received
;
82 extern int active_requests
;
84 extern char curl_errorstr
[CURL_ERROR_SIZE
];
86 static inline int missing__target(int code
, int result
)
88 return /* file:// URL -- do we ever use one??? */
89 (result
== CURLE_FILE_COULDNT_READ_FILE
) ||
90 /* http:// and https:// URL */
91 (code
== 404 && result
== CURLE_HTTP_RETURNED_ERROR
) ||
93 (code
== 550 && result
== CURLE_FTP_COULDNT_RETR_FILE
)
97 #define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
99 extern int http_fetch_ref(const char *base
, const char *ref
, unsigned char *sha1
);