php_curl_globals curl_globals;
#endif
-/* Basically grabbed from the source code of cURL */
-#ifdef PHP_WIN32
+#if PHP_WIN32
static void win32_cleanup();
static void win32_init();
curl_functions,
PHP_MINIT(curl),
PHP_MSHUTDOWN(curl),
- PHP_RINIT(curl),
+ NULL,
NULL,
PHP_MINFO(curl),
STANDARD_MODULE_PROPERTIES
REGISTER_LONG_CONSTANT("CURLE_BAD_CALLING_ORDER", CE_BAD_CALLING_ORDER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CURL_LAST", C_LAST, CONST_CS | CONST_PERSISTENT);
- if (win32_init() != CURLE_OK)
- return FAILURE;
+ win32_init();
- return SUCCESS;
-}
+ CURLG(output_start).next = NULL;
-PHP_RINIT_FUNCTION(curl)
-{
- CURLG(use_file) = 0;
+ return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(curl)
ZEND_FETCH_RESOURCE(fp, FILE *, uCurlValue, -1, "File-handle", php_file_le_fopen());
ret = curl_easy_setopt(cp, option, fp);
- if (option & CURLOPT_FILE)
- CURLG(use_file) = 1;
-
+ if (option == CURLOPT_FILE) {
+ CURLG(output_node) = &CURLG(output_start);
+ while (CURLG(output_node)->next)
+ CURLG(output_node) = CURLG(output_node)->next;
+
+ CURLG(output_node)->next = (struct curl_fileid_table *)emalloc(sizeof(struct curl_fileid_table));
+ CURLG(output_node) = CURLG(output_node)->next;
+ CURLG(output_node)->id = Z_LVAL_PP(uCurlId);
+ CURLG(output_node)->next = NULL;
+ }
}
RETURN_LONG(php_curl_error_translator(ret));
zval **uCurlId;
CURL *cp;
CURLcode ret;
+ int use_file = 0;
CURLLS_FETCH();
if (ZEND_NUM_ARGS() != 1 ||
ZEND_FETCH_RESOURCE(cp, CURL *, uCurlId, -1, "CURL Handle", CURLG(le_curl));
- if (CURLG(use_file)) {
+ CURLG(output_node) = CURLG(output_start).next;
+ while (CURLG(output_node))
+ {
+ if (CURLG(output_node)->id == Z_LVAL_PP(uCurlId)) {
+ use_file = 1;
+ break;
+ }
+ CURLG(output_node) = CURLG(output_node)->next;
+ }
+
+ if (use_file) {
ret = curl_easy_perform (cp);
} else {
FILE *tmp;
PHP_MINIT_FUNCTION(curl);
PHP_MSHUTDOWN_FUNCTION(curl);
-PHP_RINIT_FUNCTION(curl);
PHP_MINFO_FUNCTION(curl);
PHP_FUNCTION(curl_version);
PHP_FUNCTION(curl_init);
#define CE_BAD_CALLING_ORDER 44
#define C_LAST 45
+struct curl_fileid_table
+{
+ int id;
+ struct curl_fileid_table *next;
+};
+
typedef struct {
int use_file;
int le_curl;
+ struct curl_fileid_table *output_node, output_start;
} php_curl_globals;
#ifdef ZTS