diff --git a/docs/libcurl/curl_easy_getinfo.3 b/docs/libcurl/curl_easy_getinfo.3 index 9f1e6a07ee28232a97407de2a87da9084e0375f0..ae149264d5cfa1978cbcb961c74097eebcdeb412 100644 --- a/docs/libcurl/curl_easy_getinfo.3 +++ b/docs/libcurl/curl_easy_getinfo.3 @@ -115,8 +115,12 @@ Pass a pointer to a 'char *' to receive the content-type of the downloaded object. This is the value read from the Content-Type: field. If you get NULL, it means that the server didn't send a valid Content-Type header or that the protocol used doesn't support this. (Added in 7.9.4) +.TP +.B CURLINFO_PRIVATE +Pass a pointer to a 'char *' to receive the pointer to the private data +associated with the curl handle (set with the CURLOPT_PRIVATE option to curl_easy_setopt). +(Added in 7.10.3) .PP - .SH RETURN VALUE If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3 index 1d17ebb8eb670ceeeb9742e1327930a58e279fdb..b387445f4f4024aa6a33ae3b8decf228be914245 100644 --- a/docs/libcurl/curl_easy_setopt.3 +++ b/docs/libcurl/curl_easy_setopt.3 @@ -763,6 +763,13 @@ krb4 awareness. This is a string, 'clear', 'safe', 'confidential' or will be used. Set the string to NULL to disable kerberos4. The kerberos support only works for FTP. (Added in 7.3) .PP +.SH OTHER OPTIONS +.TP 0.4i +.B CURLOPT_PRIVATE +Pass a char * as parameter, pointing to data that should be +associated with the curl handle. The pointer can be subsequently retrieved using +the CURLINFO_PRIVATE options to curl_easy_getinfo. (Added in 7.10.3) +.PP .SH RETURN VALUE CURLE_OK (zero) means that the option was set properly, non-zero means an error occurred as \fI\fP defines. See the \fIlibcurl-errors.3\fP diff --git a/include/curl/curl.h b/include/curl/curl.h index 94c2cd04899a2f97c7feae71b5c3926c7b01f1d6..bf7b4852d287e5d1a8310804dd231de9ff4112b1 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -610,6 +610,8 @@ typedef enum { the response to be compressed. */ CINIT(ENCODING, OBJECTPOINT, 102), + /* Set pointer to private data */ + CINIT(PRIVATE, OBJECTPOINT, 103), CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -861,9 +863,11 @@ typedef enum { CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, + CURLINFO_PRIVATE = CURLINFO_STRING + 21, + /* Fill in new entries here! */ - CURLINFO_LASTONE = 21 + CURLINFO_LASTONE = 22 } CURLINFO; /* unfortunately, the easy.h and multi.h include files need options and info diff --git a/lib/getinfo.c b/lib/getinfo.c index 01d6dda854f6b1c17d9e5965ae15c2d50d8616f2..009a3c10a79311e36ba5fbbad517e982f01b83e7 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -158,6 +158,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) case CURLINFO_CONTENT_TYPE: *param_charp = data->info.contenttype; break; + case CURLINFO_PRIVATE: + *param_charp = data->set.private?data->set.private:(char *)""; + break; default: return CURLE_BAD_FUNCTION_ARGUMENT; } diff --git a/lib/url.c b/lib/url.c index 7083490be101ee64270360ff6bb0489135429526..c07c50861301cbff4a32e20cdd7052431cdb857b 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1088,6 +1088,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) data->set.proxytype = va_arg(param, long); break; + case CURLOPT_PRIVATE: + /* + * Set private data pointer. + */ + data->set.private = va_arg(param, char *); + break; + default: /* unknown tag and its companion, just ignore: */ return CURLE_FAILED_INIT; /* correct this */ diff --git a/lib/urldata.h b/lib/urldata.h index 8d20a78f8c08de54dede06df803265826d134083..f123a770cde9b75a02194ebd4d65a5b98478cb12 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -686,6 +686,8 @@ struct UserDefined { int dns_cache_timeout; /* DNS cache timeout */ long buffer_size; /* size of receive buffer to use */ + + char *private; /* Private data */ /* Here follows boolean settings that define how to behave during this session. They are STATIC, set by libcurl users or at least initially