1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Kjetil Jacobsen's patch that introduces CURLOPT_PRIVATE and CURLINFO_PRIVATE

for storage and retrieval of private data in the curl handle.
This commit is contained in:
Daniel Stenberg 2002-11-20 19:11:22 +00:00
parent f68505ee23
commit 8bca5e05b8
6 changed files with 29 additions and 2 deletions

View File

@ -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, 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 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) 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 .PP
.SH RETURN VALUE .SH RETURN VALUE
If the operation was successful, CURLE_OK is returned. Otherwise an If the operation was successful, CURLE_OK is returned. Otherwise an
appropriate error code will be returned. appropriate error code will be returned.

View File

@ -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 will be used. Set the string to NULL to disable kerberos4. The kerberos
support only works for FTP. (Added in 7.3) support only works for FTP. (Added in 7.3)
.PP .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 .SH RETURN VALUE
CURLE_OK (zero) means that the option was set properly, non-zero means an CURLE_OK (zero) means that the option was set properly, non-zero means an
error occurred as \fI<curl/curl.h>\fP defines. See the \fIlibcurl-errors.3\fP error occurred as \fI<curl/curl.h>\fP defines. See the \fIlibcurl-errors.3\fP

View File

@ -610,6 +610,8 @@ typedef enum {
the response to be compressed. */ the response to be compressed. */
CINIT(ENCODING, OBJECTPOINT, 102), CINIT(ENCODING, OBJECTPOINT, 102),
/* Set pointer to private data */
CINIT(PRIVATE, OBJECTPOINT, 103),
CURLOPT_LASTENTRY /* the last unused */ CURLOPT_LASTENTRY /* the last unused */
} CURLoption; } CURLoption;
@ -861,9 +863,11 @@ typedef enum {
CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
CURLINFO_PRIVATE = CURLINFO_STRING + 21,
/* Fill in new entries here! */ /* Fill in new entries here! */
CURLINFO_LASTONE = 21 CURLINFO_LASTONE = 22
} CURLINFO; } CURLINFO;
/* unfortunately, the easy.h and multi.h include files need options and info /* unfortunately, the easy.h and multi.h include files need options and info

View File

@ -158,6 +158,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
case CURLINFO_CONTENT_TYPE: case CURLINFO_CONTENT_TYPE:
*param_charp = data->info.contenttype; *param_charp = data->info.contenttype;
break; break;
case CURLINFO_PRIVATE:
*param_charp = data->set.private?data->set.private:(char *)"";
break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
} }

View File

@ -1088,6 +1088,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
data->set.proxytype = va_arg(param, long); data->set.proxytype = va_arg(param, long);
break; break;
case CURLOPT_PRIVATE:
/*
* Set private data pointer.
*/
data->set.private = va_arg(param, char *);
break;
default: default:
/* unknown tag and its companion, just ignore: */ /* unknown tag and its companion, just ignore: */
return CURLE_FAILED_INIT; /* correct this */ return CURLE_FAILED_INIT; /* correct this */

View File

@ -686,6 +686,8 @@ struct UserDefined {
int dns_cache_timeout; /* DNS cache timeout */ int dns_cache_timeout; /* DNS cache timeout */
long buffer_size; /* size of receive buffer to use */ long buffer_size; /* size of receive buffer to use */
char *private; /* Private data */
/* Here follows boolean settings that define how to behave during /* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially this session. They are STATIC, set by libcurl users or at least initially