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

Major rename and redesign of the internal "backbone" structs. Details will

be posted in a minute to the libcurl list.
This commit is contained in:
Daniel Stenberg 2001-08-30 22:48:34 +00:00
parent 315954c175
commit 0ece1b5c34
26 changed files with 870 additions and 894 deletions

View File

@ -90,7 +90,7 @@ CURLcode Curl_dict(struct connectdata *conn)
char *nthdef = NULL; /* This is not part of the protocol, but required
by RFC 2229 */
CURLcode result=CURLE_OK;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
char *path = conn->path;
long *bytecount = &conn->bytecount;

View File

@ -175,7 +175,7 @@ void curl_global_cleanup(void)
CURL *curl_easy_init(void)
{
CURLcode res;
struct UrlData *data;
struct SessionHandle *data;
/* Make sure we inited the global SSL stuff */
if (!initialized)
@ -186,9 +186,6 @@ CURL *curl_easy_init(void)
if(res != CURLE_OK)
return NULL;
/* SAC */
data->device = NULL;
return data;
}
@ -199,7 +196,7 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
func_T param_func = (func_T)0;
long param_long = 0;
void *param_obj = NULL;
struct UrlData *data = curl;
struct SessionHandle *data = curl;
va_start(arg, tag);
@ -231,14 +228,14 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
CURLcode curl_easy_perform(CURL *curl)
{
struct UrlData *data = (struct UrlData *)curl;
struct SessionHandle *data = (struct SessionHandle *)curl;
return Curl_perform(data);
}
void curl_easy_cleanup(CURL *curl)
{
struct UrlData *data = (struct UrlData *)curl;
struct SessionHandle *data = (struct SessionHandle *)curl;
Curl_close(data);
}
@ -246,7 +243,7 @@ CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
{
va_list arg;
void *paramp;
struct UrlData *data = (struct UrlData *)curl;
struct SessionHandle *data = (struct SessionHandle *)curl;
va_start(arg, info);
paramp = va_arg(arg, void *);

View File

@ -142,8 +142,8 @@ CURLcode Curl_file(struct connectdata *conn)
struct stat statbuf;
ssize_t expected_size=-1;
ssize_t nread;
struct UrlData *data = conn->data;
char *buf = data->buffer;
struct SessionHandle *data = conn->data;
char *buf = data->state.buffer;
int bytecount = 0;
struct timeval start = Curl_tvnow();
struct timeval now = start;

151
lib/ftp.c
View File

@ -98,7 +98,7 @@ static CURLcode _ftp_cwd(struct connectdata *conn, char *path);
/* easy-to-use macro: */
#define ftpsendf Curl_ftpsendf
static CURLcode AllowServerConnect(struct UrlData *data,
static CURLcode AllowServerConnect(struct SessionHandle *data,
struct connectdata *conn,
int sock)
{
@ -178,7 +178,7 @@ int Curl_GetFTPResponse(int sockfd,
struct timeval interval;
fd_set rkeepfd;
fd_set readfd;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
char *line_start;
int code=0; /* default "error code" to return */
@ -190,9 +190,9 @@ int Curl_GetFTPResponse(int sockfd,
if(ftpcode)
*ftpcode=0; /* 0 for errors */
if(data->timeout) {
if(data->set.timeout) {
/* if timeout is requested, find out how much remaining time we have */
timeout = data->timeout - /* timeout time */
timeout = data->set.timeout - /* timeout time */
(Curl_tvlong(Curl_tvnow()) - Curl_tvlong(conn->now)); /* spent time */
if(timeout <=0 ) {
failf(data, "Transfer aborted due to timeout");
@ -255,9 +255,9 @@ int Curl_GetFTPResponse(int sockfd,
the line isn't really terminated until the LF comes */
/* output debug output if that is requested */
if(data->bits.verbose) {
fputs("< ", data->err);
fwrite(line_start, perline, 1, data->err);
if(data->set.verbose) {
fputs("< ", data->set.err);
fwrite(line_start, perline, 1, data->set.err);
/* no need to output LF here, it is part of the data */
}
@ -339,8 +339,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
{
/* this is FTP and no proxy */
int nread;
struct UrlData *data=conn->data;
char *buf = data->buffer; /* this is our buffer */
struct SessionHandle *data=conn->data;
char *buf = data->state.buffer; /* this is our buffer */
struct FTP *ftp;
CURLcode result;
int ftpcode;
@ -360,11 +360,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* get some initial data into the ftp struct */
ftp->bytecountp = &conn->bytecount;
/* duplicate to keep them even when the data struct changes */
ftp->user = strdup(data->user);
ftp->passwd = strdup(data->passwd);
/* no need to duplicate them, the data struct won't change */
ftp->user = data->state.user;
ftp->passwd = data->state.passwd;
if (data->bits.tunnel_thru_httpproxy) {
if (data->set.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
result = Curl_ConnectHTTPProxyTunnel(conn, conn->firstsocket,
conn->hostname, conn->remote_port);
@ -393,14 +393,14 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
#ifdef KRB4
/* if not anonymous login, try a secure login */
if(data->bits.krb4) {
if(data->set.krb4) {
/* request data protection level (default is 'clear') */
Curl_sec_request_prot(conn, "private");
/* We set private first as default, in case the line below fails to
set a valid level */
Curl_sec_request_prot(conn, data->krb4_level);
Curl_sec_request_prot(conn, data->set.krb4_level);
if(Curl_sec_login(conn) != 0)
infof(data, "Logging in with password in cleartext!\n");
@ -462,7 +462,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* we may need to issue a KAUTH here to have access to the files
* do it if user supplied a password
*/
if(conn->data->passwd && *conn->data->passwd)
if(conn->data->set.passwd && *conn->data->set.passwd)
Curl_krb_kauth(conn);
#endif
}
@ -530,16 +530,16 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* argument is already checked for validity */
CURLcode Curl_ftp_done(struct connectdata *conn)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
struct FTP *ftp = conn->proto.ftp;
ssize_t nread;
char *buf = data->buffer; /* this is our buffer */
char *buf = data->state.buffer; /* this is our buffer */
int ftpcode;
if(data->bits.upload) {
if((-1 != data->infilesize) && (data->infilesize != *ftp->bytecountp)) {
if(data->set.upload) {
if((-1 != data->set.infilesize) && (data->set.infilesize != *ftp->bytecountp)) {
failf(data, "Wrote only partial file (%d out of %d bytes)",
*ftp->bytecountp, data->infilesize);
*ftp->bytecountp, data->set.infilesize);
return CURLE_PARTIAL_FILE;
}
}
@ -550,7 +550,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
return CURLE_PARTIAL_FILE;
}
else if(!conn->bits.resume_done &&
!data->bits.no_body &&
!data->set.no_body &&
(0 == *ftp->bytecountp)) {
failf(data, "No data was received!");
return CURLE_FTP_COULDNT_RETR_FILE;
@ -564,7 +564,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
sclose(conn->secondarysocket);
conn->secondarysocket = -1;
if(!data->bits.no_body && !conn->bits.resume_done) {
if(!data->set.no_body && !conn->bits.resume_done) {
/* now let's see what the server says about the transfer we
just performed: */
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
@ -581,8 +581,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
conn->bits.resume_done = FALSE; /* clean this for next connection */
/* Send any post-transfer QUOTE strings? */
if(data->postquote) {
CURLcode result = _ftp_sendquote(conn, data->postquote);
if(data->set.postquote) {
CURLcode result = _ftp_sendquote(conn, data->set.postquote);
return result;
}
@ -603,7 +603,7 @@ CURLcode _ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
ftpsendf(conn->firstsocket, conn, "%s", item->data);
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, &ftpcode);
conn->data->state.buffer, conn, &ftpcode);
if (nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@ -627,7 +627,7 @@ CURLcode _ftp_cwd(struct connectdata *conn, char *path)
ftpsendf(conn->firstsocket, conn, "CWD %s", path);
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, &ftpcode);
conn->data->state.buffer, conn, &ftpcode);
if (nread < 0)
return CURLE_OPERATION_TIMEOUTED;
@ -645,7 +645,7 @@ CURLcode _ftp_getfiletime(struct connectdata *conn, char *file)
CURLcode result=CURLE_OK;
int ftpcode; /* for ftp status */
ssize_t nread;
char *buf = conn->data->buffer;
char *buf = conn->data->state.buffer;
/* we have requested to get the modified-time of the file, this is yet
again a grey area as the MDTM is not kosher RFC959 */
@ -666,7 +666,7 @@ CURLcode _ftp_getfiletime(struct connectdata *conn, char *file)
sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
conn->data->progress.filetime = curl_getdate(buf, &secs);
conn->data->info.filetime = curl_getdate(buf, &secs);
}
else {
infof(conn->data, "unsupported MDTM reply format\n");
@ -678,10 +678,10 @@ CURLcode _ftp_getfiletime(struct connectdata *conn, char *file)
static CURLcode _ftp_transfertype(struct connectdata *conn,
bool ascii)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
int ftpcode;
ssize_t nread;
char *buf=data->buffer;
char *buf=data->state.buffer;
ftpsendf(conn->firstsocket, conn, "TYPE %s", ascii?"A":"I");
@ -702,10 +702,10 @@ static
CURLcode _ftp_getsize(struct connectdata *conn, char *file,
ssize_t *size)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
int ftpcode;
ssize_t nread;
char *buf=data->buffer;
char *buf=data->state.buffer;
ftpsendf(conn->firstsocket, conn, "SIZE %s", file);
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
@ -729,8 +729,8 @@ CURLcode _ftp(struct connectdata *conn)
/* this is FTP and no proxy */
ssize_t nread;
CURLcode result;
struct UrlData *data=conn->data;
char *buf = data->buffer; /* this is our buffer */
struct SessionHandle *data=conn->data;
char *buf = data->state.buffer; /* this is our buffer */
/* for the ftp PORT mode */
int portsock=-1;
#if defined (HAVE_INET_NTOA_R)
@ -750,8 +750,8 @@ CURLcode _ftp(struct connectdata *conn)
int ftpcode; /* for ftp status */
/* Send any QUOTE strings? */
if(data->quote) {
if ((result = _ftp_sendquote(conn, data->quote)) != CURLE_OK)
if(data->set.quote) {
if ((result = _ftp_sendquote(conn, data->set.quote)) != CURLE_OK)
return result;
}
@ -770,7 +770,7 @@ CURLcode _ftp(struct connectdata *conn)
}
/* Requested time of file? */
if(data->bits.get_filetime && ftp->file) {
if(data->set.get_filetime && ftp->file) {
result = _ftp_getfiletime(conn, ftp->file);
if(result)
return result;
@ -778,7 +778,7 @@ CURLcode _ftp(struct connectdata *conn)
/* If we have selected NOBODY, it means that we only want file information.
Which in FTP can't be much more than the file size! */
if(data->bits.no_body) {
if(data->set.no_body) {
/* The SIZE command is _not_ RFC 959 specified, and therefor many servers
may not support it! It is however the only way we have to get a file's
size! */
@ -786,7 +786,7 @@ CURLcode _ftp(struct connectdata *conn)
/* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */
result = _ftp_transfertype(conn, data->bits.ftp_ascii);
result = _ftp_transfertype(conn, data->set.ftp_ascii);
if(result)
return result;
@ -804,13 +804,13 @@ CURLcode _ftp(struct connectdata *conn)
well, we "emulate" a HTTP-style header in our output. */
#ifdef HAVE_STRFTIME
if(data->bits.get_filetime && data->progress.filetime) {
if(data->set.get_filetime && data->info.filetime) {
struct tm *tm;
#ifdef HAVE_LOCALTIME_R
struct tm buffer;
tm = (struct tm *)localtime_r(&data->progress.filetime, &buffer);
tm = (struct tm *)localtime_r(&data->info.filetime, &buffer);
#else
tm = localtime(&data->progress.filetime);
tm = localtime(&data->info.filetime);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S %Z\r\n",
@ -825,7 +825,7 @@ CURLcode _ftp(struct connectdata *conn)
}
/* We have chosen to use the PORT command */
if(data->bits.ftp_use_port) {
if(data->set.ftp_use_port) {
#ifdef ENABLE_IPV6
struct addrinfo hints, *res, *ai;
struct sockaddr_storage ss;
@ -1005,15 +1005,15 @@ CURLcode _ftp(struct connectdata *conn)
unsigned short porttouse;
char myhost[256] = "";
if(data->ftpport) {
if(Curl_if2ip(data->ftpport, myhost, sizeof(myhost))) {
if(data->set.ftpport) {
if(Curl_if2ip(data->set.ftpport, myhost, sizeof(myhost))) {
h = Curl_gethost(data, myhost, &hostdataptr);
}
else {
if(strlen(data->ftpport)>1)
h = Curl_gethost(data, data->ftpport, &hostdataptr);
if(strlen(data->set.ftpport)>1)
h = Curl_gethost(data, data->set.ftpport, &hostdataptr);
if(h)
strcpy(myhost, data->ftpport); /* buffer overflow risk */
strcpy(myhost, data->set.ftpport); /* buffer overflow risk */
}
}
if(! *myhost) {
@ -1172,7 +1172,7 @@ CURLcode _ftp(struct connectdata *conn)
sprintf(newhost, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
newport = (port[0]<<8) + port[1];
if(data->bits.httpproxy) {
if(data->change.proxy) {
/*
* This is a tunnel through a http proxy and we need to connect to the
* proxy again here. We already have the name info for it since the
@ -1214,7 +1214,7 @@ CURLcode _ftp(struct connectdata *conn)
if (conn->secondarysocket < 0)
continue;
if(data->bits.verbose) {
if(data->set.verbose) {
char hbuf[NI_MAXHOST];
char nbuf[NI_MAXHOST];
char sbuf[NI_MAXSERV];
@ -1258,7 +1258,7 @@ CURLcode _ftp(struct connectdata *conn)
serv_addr.sin_port = htons(connectport);
if(data->bits.verbose) {
if(data->set.verbose) {
struct in_addr in;
struct hostent * answer;
@ -1346,7 +1346,7 @@ CURLcode _ftp(struct connectdata *conn)
}
#endif /*ENABLE_IPV6*/
if (data->bits.tunnel_thru_httpproxy) {
if (data->set.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
result = Curl_ConnectHTTPProxyTunnel(conn, conn->secondarysocket,
newhost, newport);
@ -1360,10 +1360,10 @@ CURLcode _ftp(struct connectdata *conn)
/* we have the (new) data connection ready */
infof(data, "Connected the data stream!\n");
if(data->bits.upload) {
if(data->set.upload) {
/* Set type to binary (unless specified ASCII) */
result = _ftp_transfertype(conn, data->bits.ftp_ascii);
result = _ftp_transfertype(conn, data->set.ftp_ascii);
if(result)
return result;
@ -1395,7 +1395,7 @@ CURLcode _ftp(struct connectdata *conn)
/* do we still game? */
int passed=0;
/* enable append instead */
data->bits.ftp_append = 1;
data->set.ftp_append = 1;
/* Now, let's read off the proper amount of bytes from the
input. If we knew it was a proper file we could've just
@ -1408,7 +1408,8 @@ CURLcode _ftp(struct connectdata *conn)
readthisamountnow = BUFSIZE;
actuallyread =
data->fread(data->buffer, 1, readthisamountnow, data->in);
data->set.fread(data->state.buffer, 1, readthisamountnow,
data->set.in);
passed += actuallyread;
if(actuallyread != readthisamountnow) {
@ -1419,10 +1420,10 @@ CURLcode _ftp(struct connectdata *conn)
while(passed != conn->resume_from);
/* now, decrease the size of the read */
if(data->infilesize>0) {
data->infilesize -= conn->resume_from;
if(data->set.infilesize>0) {
data->set.infilesize -= conn->resume_from;
if(data->infilesize <= 0) {
if(data->set.infilesize <= 0) {
infof(data, "File already completely uploaded\n");
/* no data to transfer */
@ -1440,8 +1441,8 @@ CURLcode _ftp(struct connectdata *conn)
}
}
/* Send everything on data->in to the socket */
if(data->bits.ftp_append)
/* Send everything on data->set.in to the socket */
if(data->set.ftp_append)
/* we append onto the file instead of rewriting it */
ftpsendf(conn->firstsocket, conn, "APPE %s", ftp->file);
else
@ -1457,7 +1458,7 @@ CURLcode _ftp(struct connectdata *conn)
return CURLE_FTP_COULDNT_STOR_FILE;
}
if(data->bits.ftp_use_port) {
if(data->set.ftp_use_port) {
/* PORT means we are now awaiting the server to connect to us. */
result = AllowServerConnect(data, conn, portsock);
if( result )
@ -1469,7 +1470,7 @@ CURLcode _ftp(struct connectdata *conn)
/* When we know we're uploading a specified file, we can get the file
size prior to the actual upload. */
Curl_pgrsSetUploadSize(data, data->infilesize);
Curl_pgrsSetUploadSize(data, data->set.infilesize);
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
conn->secondarysocket, bytecountp);
@ -1520,7 +1521,7 @@ CURLcode _ftp(struct connectdata *conn)
from, to, totalsize);
}
if((data->bits.ftp_list_only) || !ftp->file) {
if((data->set.ftp_list_only) || !ftp->file) {
/* The specified path ends with a slash, and therefore we think this
is a directory that is requested, use LIST. But before that we
need to set ASCII transfer mode. */
@ -1536,12 +1537,12 @@ CURLcode _ftp(struct connectdata *conn)
standard in any way */
ftpsendf(conn->firstsocket, conn, "%s",
data->customrequest?data->customrequest:
(data->bits.ftp_list_only?"NLST":"LIST"));
data->set.customrequest?data->set.customrequest:
(data->set.ftp_list_only?"NLST":"LIST"));
}
else {
/* Set type to binary (unless specified ASCII) */
result = _ftp_transfertype(conn, data->bits.ftp_ascii);
result = _ftp_transfertype(conn, data->set.ftp_ascii);
if(result)
return result;
@ -1647,7 +1648,7 @@ CURLcode _ftp(struct connectdata *conn)
int size=-1; /* default unknown size */
if(!dirlist &&
!data->bits.ftp_ascii &&
!data->set.ftp_ascii &&
(-1 == downloadsize)) {
/*
* It seems directory listings either don't show the size or very
@ -1684,7 +1685,7 @@ CURLcode _ftp(struct connectdata *conn)
else if(downloadsize > -1)
size = downloadsize;
if(data->bits.ftp_use_port) {
if(data->set.ftp_use_port) {
result = AllowServerConnect(data, conn, portsock);
if( result )
return result;
@ -1717,7 +1718,7 @@ CURLcode Curl_ftp(struct connectdata *conn)
{
CURLcode retcode;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
struct FTP *ftp;
int dirlength=0; /* 0 forces strlen() */
@ -1793,8 +1794,8 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn,
vsnprintf(s, 250, fmt, ap);
va_end(ap);
if(conn->data->bits.verbose)
fprintf(conn->data->err, "> %s\n", s);
if(conn->data->set.verbose)
fprintf(conn->data->set.err, "> %s\n", s);
strcat(s, "\r\n"); /* append a trailing CRLF */
@ -1811,10 +1812,6 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
/* The FTP session may or may not have been allocated/setup at this point! */
if(ftp) {
if(ftp->user)
free(ftp->user);
if(ftp->passwd)
free(ftp->passwd);
if(ftp->entrypath)
free(ftp->entrypath);
}

View File

@ -35,22 +35,23 @@
* This is supposed to be called in the beginning of a permform() session
* and should reset all session-info variables
*/
CURLcode Curl_initinfo(struct UrlData *data)
CURLcode Curl_initinfo(struct SessionHandle *data)
{
struct Progress *pro = &data->progress;
struct PureInfo *info =&data->info;
pro->t_nslookup = 0;
pro->t_connect = 0;
pro->t_pretransfer = 0;
pro->httpcode = 0;
pro->httpversion=0;
pro->filetime=0;
info->httpcode = 0;
info->httpversion=0;
info->filetime=0;
return CURLE_OK;
}
CURLcode Curl_getinfo(struct UrlData *data, CURLINFO info, ...)
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
{
va_list arg;
long *param_longp;
@ -80,19 +81,19 @@ CURLcode Curl_getinfo(struct UrlData *data, CURLINFO info, ...)
switch(info) {
case CURLINFO_EFFECTIVE_URL:
*param_charp = data->url?data->url:(char *)"";
*param_charp = data->change.url?data->change.url:(char *)"";
break;
case CURLINFO_HTTP_CODE:
*param_longp = data->progress.httpcode;
*param_longp = data->info.httpcode;
break;
case CURLINFO_FILETIME:
*param_longp = data->progress.filetime;
*param_longp = data->info.filetime;
break;
case CURLINFO_HEADER_SIZE:
*param_longp = data->header_size;
*param_longp = data->info.header_size;
break;
case CURLINFO_REQUEST_SIZE:
*param_longp = data->request_size;
*param_longp = data->info.request_size;
break;
case CURLINFO_TOTAL_TIME:
*param_doublep = data->progress.timespent;
@ -119,7 +120,7 @@ CURLcode Curl_getinfo(struct UrlData *data, CURLINFO info, ...)
*param_doublep = data->progress.ulspeed;
break;
case CURLINFO_SSL_VERIFYRESULT:
*param_longp = data->ssl.certverifyresult;
*param_longp = data->set.ssl.certverifyresult;
break;
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
*param_doublep = data->progress.size_dl;

View File

@ -22,7 +22,7 @@
*
* $Id$
*****************************************************************************/
CURLcode Curl_getinfo(struct UrlData *data, CURLINFO info, ...);
CURLcode Curl_initinfo(struct UrlData *data);
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...);
CURLcode Curl_initinfo(struct SessionHandle *data);
#endif

View File

@ -89,7 +89,7 @@ static char *MakeIP(unsigned long num,char *addr, int addr_len)
}
#ifdef ENABLE_IPV6
struct addrinfo *Curl_getaddrinfo(struct UrlData *data,
struct addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
char *hostname,
int port)
{
@ -119,7 +119,7 @@ struct addrinfo *Curl_getaddrinfo(struct UrlData *data,
#define INADDR_NONE (unsigned long) ~0
#endif
struct hostent *Curl_gethost(struct UrlData *data,
struct hostent *Curl_gethost(struct SessionHandle *data,
char *hostname,
char **bufp)
{

View File

@ -24,11 +24,11 @@
*****************************************************************************/
struct addrinfo;
struct addrinfo *Curl_getaddrinfo(struct UrlData *data,
struct addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
char *hostname,
int port);
struct hostent *Curl_gethost(struct UrlData *data,
struct hostent *Curl_gethost(struct SessionHandle *data,
char *hostname,
char **bufp);

View File

@ -128,10 +128,10 @@ static
size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
{
size_t amount;
if(conn->data->bits.verbose) {
fputs("> ", conn->data->err);
if(conn->data->set.verbose) {
fputs("> ", conn->data->set.err);
/* this data _may_ contain binary stuff */
fwrite(in->buffer, in->size_used, 1, conn->data->err);
fwrite(in->buffer, in->size_used, 1, conn->data->set.err);
}
Curl_write(conn, sockfd, in->buffer, in->size_used, &amount);
@ -209,7 +209,7 @@ int GetLine(int sockfd, char *buf, struct connectdata *conn)
ssize_t nread;
int read_rc=1;
char *ptr;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
ptr=buf;
@ -224,10 +224,10 @@ int GetLine(int sockfd, char *buf, struct connectdata *conn)
}
*ptr=0; /* zero terminate */
if(data->bits.verbose) {
fputs("< ", data->err);
fwrite(buf, 1, nread, data->err);
fputs("\n", data->err);
if(data->set.verbose) {
fputs("< ", data->set.err);
fwrite(buf, 1, nread, data->set.err);
fputs("\n", data->set.err);
}
return nread>0?nread:0;
}
@ -238,12 +238,12 @@ int GetLine(int sockfd, char *buf, struct connectdata *conn)
* This function checks the linked list of custom HTTP headers for a particular
* header (prefix).
*/
static bool checkheaders(struct UrlData *data, const char *thisheader)
static bool checkheaders(struct SessionHandle *data, const char *thisheader)
{
struct curl_slist *head;
size_t thislen = strlen(thisheader);
for(head = data->headers; head; head=head->next) {
for(head = data->set.headers; head; head=head->next) {
if(strnequal(head->data, thisheader, thislen)) {
return TRUE;
}
@ -263,7 +263,7 @@ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
{
int httperror=0;
int subversion=0;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
infof(data, "Establish HTTP proxy tunnel to %s:%d\n", hostname, remote_port);
@ -275,14 +275,14 @@ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
"\r\n",
hostname, remote_port,
(conn->bits.proxy_user_passwd)?conn->allocptr.proxyuserpwd:"",
(data->useragent?conn->allocptr.uagent:"")
(data->set.useragent?conn->allocptr.uagent:"")
);
/* wait for the proxy to send us a HTTP/1.0 200 OK header */
while(GetLine(tunnelsocket, data->buffer, conn)) {
if('\r' == data->buffer[0])
while(GetLine(tunnelsocket, data->state.buffer, conn)) {
if('\r' == data->state.buffer[0])
break; /* end of headers */
if(2 == sscanf(data->buffer, "HTTP/1.%d %d",
if(2 == sscanf(data->state.buffer, "HTTP/1.%d %d",
&subversion,
&httperror)) {
;
@ -306,7 +306,7 @@ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
*/
CURLcode Curl_http_connect(struct connectdata *conn)
{
struct UrlData *data;
struct SessionHandle *data;
CURLcode result;
data=conn->data;
@ -318,7 +318,7 @@ CURLcode Curl_http_connect(struct connectdata *conn)
* has occured, can we start talking SSL
*/
if (conn->protocol & PROT_HTTPS) {
if (data->bits.httpproxy) {
if (data->change.proxy) {
/* HTTPS through a proxy can only be done with a tunnel */
result = Curl_ConnectHTTPProxyTunnel(conn, conn->firstsocket,
conn->hostname, conn->remote_port);
@ -332,10 +332,10 @@ CURLcode Curl_http_connect(struct connectdata *conn)
return result;
}
if(conn->bits.user_passwd && !data->bits.this_is_a_follow) {
if(conn->bits.user_passwd && !data->state.this_is_a_follow) {
/* Authorization: is requested, this is not a followed location, get the
original host name */
data->auth_host = strdup(conn->hostname);
data->state.auth_host = strdup(conn->hostname);
}
return CURLE_OK;
@ -345,29 +345,29 @@ CURLcode Curl_http_connect(struct connectdata *conn)
protocol-specific resources */
CURLcode Curl_http_close(struct connectdata *conn)
{
if(conn->data->auth_host)
free(conn->data->auth_host);
if(conn->data->state.auth_host)
free(conn->data->state.auth_host);
return CURLE_OK;
}
CURLcode Curl_http_done(struct connectdata *conn)
{
struct UrlData *data;
struct SessionHandle *data;
long *bytecount = &conn->bytecount;
struct HTTP *http;
data=conn->data;
http=conn->proto.http;
if(HTTPREQ_POST_FORM == data->httpreq) {
if(HTTPREQ_POST_FORM == data->set.httpreq) {
*bytecount = http->readbytecount + http->writebytecount;
Curl_formclean(http->sendit); /* Now free that whole lot */
data->fread = http->storefread; /* restore */
data->in = http->in; /* restore */
data->set.fread = http->storefread; /* restore */
data->set.in = http->in; /* restore */
}
else if(HTTPREQ_PUT == data->httpreq) {
else if(HTTPREQ_PUT == data->set.httpreq) {
*bytecount = http->readbytecount + http->writebytecount;
}
@ -377,8 +377,8 @@ CURLcode Curl_http_done(struct connectdata *conn)
CURLcode Curl_http(struct connectdata *conn)
{
struct UrlData *data=conn->data;
char *buf = data->buffer; /* this is a short cut to the buffer */
struct SessionHandle *data=conn->data;
char *buf = data->state.buffer; /* this is a short cut to the buffer */
CURLcode result=CURLE_OK;
struct HTTP *http;
struct Cookie *co=NULL; /* no cookies from start */
@ -402,8 +402,8 @@ CURLcode Curl_http(struct connectdata *conn)
conn->bits.close = FALSE;
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
data->bits.upload) {
data->httpreq = HTTPREQ_PUT;
data->set.upload) {
data->set.httpreq = HTTPREQ_PUT;
}
/* The User-Agent string has been built in url.c already, because it might
@ -420,45 +420,45 @@ CURLcode Curl_http(struct connectdata *conn)
/* To prevent the user+password to get sent to other than the original
host due to a location-follow, we do some weirdo checks here */
if(!data->bits.this_is_a_follow ||
!data->auth_host ||
strequal(data->auth_host, conn->hostname)) {
sprintf(data->buffer, "%s:%s", data->user, data->passwd);
if(Curl_base64_encode(data->buffer, strlen(data->buffer),
if(!data->state.this_is_a_follow ||
!data->state.auth_host ||
strequal(data->state.auth_host, conn->hostname)) {
sprintf(data->state.buffer, "%s:%s",
data->state.user, data->state.passwd);
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
&authorization) >= 0) {
if(conn->allocptr.userpwd)
free(conn->allocptr.userpwd);
conn->allocptr.userpwd = aprintf( "Authorization: Basic %s\015\012",
authorization);
authorization);
free(authorization);
}
}
}
if((data->bits.http_set_referer) && !checkheaders(data, "Referer:")) {
if((data->change.referer) && !checkheaders(data, "Referer:")) {
if(conn->allocptr.ref)
free(conn->allocptr.ref);
conn->allocptr.ref = aprintf("Referer: %s\015\012", data->referer);
conn->allocptr.ref = aprintf("Referer: %s\015\012", data->change.referer);
}
if(data->cookie && !checkheaders(data, "Cookie:")) {
if(data->set.cookie && !checkheaders(data, "Cookie:")) {
if(conn->allocptr.cookie)
free(conn->allocptr.cookie);
conn->allocptr.cookie = aprintf("Cookie: %s\015\012", data->cookie);
conn->allocptr.cookie = aprintf("Cookie: %s\015\012", data->set.cookie);
}
if(data->cookies) {
co = Curl_cookie_getlist(data->cookies,
host,
ppath,
host, ppath,
conn->protocol&PROT_HTTPS?TRUE:FALSE);
}
if ((data->bits.httpproxy) && !(conn->protocol&PROT_HTTPS)) {
if ((data->change.proxy) && !(conn->protocol&PROT_HTTPS)) {
/* The path sent to the proxy is in fact the entire URL */
ppath = data->url;
ppath = data->change.url;
}
if(HTTPREQ_POST_FORM == data->httpreq) {
if(HTTPREQ_POST_FORM == data->set.httpreq) {
/* we must build the whole darned post sequence first, so that we have
a size of the whole shebang before we start to send it */
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
http->sendit = Curl_getFormData(data->set.httppost, &http->postsize);
}
if(!checkheaders(data, "Host:")) {
@ -486,9 +486,9 @@ CURLcode Curl_http(struct connectdata *conn)
if(!checkheaders(data, "Accept:"))
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
if(( (HTTPREQ_POST == data->httpreq) ||
(HTTPREQ_POST_FORM == data->httpreq) ||
(HTTPREQ_PUT == data->httpreq) ) &&
if(( (HTTPREQ_POST == data->set.httpreq) ||
(HTTPREQ_POST_FORM == data->set.httpreq) ||
(HTTPREQ_PUT == data->set.httpreq) ) &&
conn->resume_from) {
/**********************************************************************
* Resuming upload in HTTP means that we PUT or POST and that we have
@ -521,7 +521,8 @@ CURLcode Curl_http(struct connectdata *conn)
readthisamountnow = BUFSIZE;
actuallyread =
data->fread(data->buffer, 1, readthisamountnow, data->in);
data->set.fread(data->state.buffer, 1, readthisamountnow,
data->set.in);
passed += actuallyread;
if(actuallyread != readthisamountnow) {
@ -532,10 +533,10 @@ CURLcode Curl_http(struct connectdata *conn)
} while(passed != conn->resume_from); /* loop until done */
/* now, decrease the size of the read */
if(data->infilesize>0) {
data->infilesize -= conn->resume_from;
if(data->set.infilesize>0) {
data->set.infilesize -= conn->resume_from;
if(data->infilesize <= 0) {
if(data->set.infilesize <= 0) {
failf(data, "File already completely uploaded\n");
return CURLE_PARTIAL_FILE;
}
@ -549,16 +550,16 @@ CURLcode Curl_http(struct connectdata *conn)
* or uploading and we always let customized headers override our internal
* ones if any such are specified.
*/
if((data->httpreq == HTTPREQ_GET) &&
if((data->set.httpreq == HTTPREQ_GET) &&
!checkheaders(data, "Range:")) {
conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range);
}
else if((data->httpreq != HTTPREQ_GET) &&
else if((data->set.httpreq != HTTPREQ_GET) &&
!checkheaders(data, "Content-Range:")) {
if(conn->resume_from) {
/* This is because "resume" was selected */
long total_expected_size= conn->resume_from + data->infilesize;
long total_expected_size= conn->resume_from + data->set.infilesize;
conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n",
conn->range, total_expected_size-1,
total_expected_size);
@ -567,14 +568,14 @@ CURLcode Curl_http(struct connectdata *conn)
/* Range was selected and then we just pass the incoming range and
append total size */
conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n",
conn->range, data->infilesize);
conn->range, data->set.infilesize);
}
}
}
do {
send_buffer *req_buffer;
struct curl_slist *headers=data->headers;
struct curl_slist *headers=data->set.headers;
/* initialize a dynamic send-buffer */
req_buffer = add_buffer_init();
@ -593,11 +594,11 @@ CURLcode Curl_http(struct connectdata *conn)
"%s" /* accept */
"%s", /* referer */
data->customrequest?data->customrequest:
(data->bits.no_body?"HEAD":
((HTTPREQ_POST == data->httpreq) ||
(HTTPREQ_POST_FORM == data->httpreq))?"POST":
(HTTPREQ_PUT == data->httpreq)?"PUT":"GET"),
data->set.customrequest?data->set.customrequest:
(data->set.no_body?"HEAD":
((HTTPREQ_POST == data->set.httpreq) ||
(HTTPREQ_POST_FORM == data->set.httpreq))?"POST":
(HTTPREQ_PUT == data->set.httpreq)?"PUT":"GET"),
ppath,
(conn->bits.proxy_user_passwd &&
conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"",
@ -605,13 +606,13 @@ CURLcode Curl_http(struct connectdata *conn)
conn->allocptr.userpwd:"",
(conn->bits.use_range && conn->allocptr.rangeline)?
conn->allocptr.rangeline:"",
(data->useragent && *data->useragent && conn->allocptr.uagent)?
(data->set.useragent && *data->set.useragent && conn->allocptr.uagent)?
conn->allocptr.uagent:"",
(conn->allocptr.cookie?conn->allocptr.cookie:""), /* Cookie: <data> */
(conn->allocptr.host?conn->allocptr.host:""), /* Host: host */
http->p_pragma?http->p_pragma:"",
http->p_accept?http->p_accept:"",
(data->bits.http_set_referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: <data> <CRLF> */
(data->change.referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: <data> <CRLF> */
);
if(co) {
@ -636,7 +637,7 @@ CURLcode Curl_http(struct connectdata *conn)
co=NULL;
}
if(data->timecondition) {
if(data->set.timecondition) {
struct tm *thistime;
/* Phil Karn (Fri, 13 Apr 2001) pointed out that the If-Modified-Since
@ -651,9 +652,9 @@ CURLcode Curl_http(struct connectdata *conn)
/* We assume that the presense of localtime_r() proves the presense
of gmtime_r() which is a bit ugly but might work */
struct tm keeptime;
thistime = (struct tm *)gmtime_r(&data->timevalue, &keeptime);
thistime = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime);
#else
thistime = gmtime(&data->timevalue);
thistime = gmtime(&data->set.timevalue);
#endif
if(NULL == thistime) {
failf(data, "localtime() failed!");
@ -667,7 +668,7 @@ CURLcode Curl_http(struct connectdata *conn)
/* TODO: Right, we *could* write a replacement here */
strcpy(buf, "no strftime() support");
#endif
switch(data->timecondition) {
switch(data->set.timecondition) {
case TIMECOND_IFMODSINCE:
default:
add_bufferf(req_buffer,
@ -702,7 +703,7 @@ CURLcode Curl_http(struct connectdata *conn)
headers = headers->next;
}
if(HTTPREQ_POST_FORM == data->httpreq) {
if(HTTPREQ_POST_FORM == data->set.httpreq) {
char contentType[256];
int linelength=0;
if(Curl_FormInit(&http->form, http->sendit)) {
@ -710,13 +711,13 @@ CURLcode Curl_http(struct connectdata *conn)
return CURLE_HTTP_POST_ERROR;
}
http->storefread = data->fread; /* backup */
http->in = data->in; /* backup */
http->storefread = data->set.fread; /* backup */
http->in = data->set.in; /* backup */
data->fread = (curl_read_callback)
data->set.fread = (curl_read_callback)
Curl_FormReader; /* set the read function to read from the
generated form data */
data->in = (FILE *)&http->form;
data->set.in = (FILE *)&http->form;
add_bufferf(req_buffer,
"Content-Length: %d\r\n", http->postsize-2);
@ -727,7 +728,7 @@ CURLcode Curl_http(struct connectdata *conn)
there is one packet coming back from the web server) */
add_bufferf(req_buffer,
"Expect: 100-continue\r\n");
data->bits.expect100header = TRUE;
data->set.expect100header = TRUE;
/* Get Content-Type: line from Curl_FormReadOneLine, which happens
to always be the first line. We can know this for sure since
@ -747,7 +748,7 @@ CURLcode Curl_http(struct connectdata *conn)
Curl_pgrsSetUploadSize(data, http->postsize);
/* fire away the whole request to the server */
data->request_size =
data->info.request_size =
add_buffer_send(conn->firstsocket, conn, req_buffer);
/* setup variables for the upcoming transfer */
@ -760,22 +761,22 @@ CURLcode Curl_http(struct connectdata *conn)
return result;
}
}
else if(HTTPREQ_PUT == data->httpreq) {
else if(HTTPREQ_PUT == data->set.httpreq) {
/* Let's PUT the data to the server! */
if(data->infilesize>0) {
if(data->set.infilesize>0) {
add_bufferf(req_buffer,
"Content-Length: %d\r\n\r\n", /* file size */
data->infilesize );
data->set.infilesize );
}
else
add_bufferf(req_buffer, "\015\012");
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, data->infilesize);
Curl_pgrsSetUploadSize(data, data->set.infilesize);
/* this sends the buffer and frees all the buffer resources */
data->request_size =
data->info.request_size =
add_buffer_send(conn->firstsocket, conn, req_buffer);
/* prepare for transfer */
@ -788,17 +789,17 @@ CURLcode Curl_http(struct connectdata *conn)
}
else {
if(HTTPREQ_POST == data->httpreq) {
if(HTTPREQ_POST == data->set.httpreq) {
/* this is the simple POST, using x-www-form-urlencoded style */
if(!data->postfields) {
if(!data->set.postfields) {
/*
* This is an attempt to do a POST without having anything to
* actually send. Let's make a NULL pointer equal "" here. Good/bad
* ?
*/
data->postfields = (char *)"";
data->postfieldsize = 0; /* it might been set to something illegal,
data->set.postfields = (char *)"";
data->set.postfieldsize = 0; /* it might been set to something illegal,
anything > 0 would be! */
}
@ -807,32 +808,32 @@ CURLcode Curl_http(struct connectdata *conn)
actually set your own */
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
(data->postfieldsize?data->postfieldsize:
strlen(data->postfields)) );
(data->set.postfieldsize?data->set.postfieldsize:
strlen(data->set.postfields)) );
if(!checkheaders(data, "Content-Type:"))
add_bufferf(req_buffer,
"Content-Type: application/x-www-form-urlencoded\r\n");
/* and here comes the actual data */
if(data->postfieldsize) {
if(data->set.postfieldsize) {
add_buffer(req_buffer, "\r\n", 2);
add_buffer(req_buffer, data->postfields,
data->postfieldsize);
add_buffer(req_buffer, data->set.postfields,
data->set.postfieldsize);
add_buffer(req_buffer, "\r\n", 2);
}
else {
add_bufferf(req_buffer,
"\r\n"
"%s\r\n",
data->postfields );
data->set.postfields );
}
}
else
add_buffer(req_buffer, "\r\n", 2);
/* issue the request */
data->request_size =
data->info.request_size =
add_buffer_send(conn->firstsocket, conn, req_buffer);
/* HTTP GET/HEAD download: */

View File

@ -248,17 +248,17 @@ krb4_auth(void *app_data, struct connectdata *conn)
Curl_ftpsendf(conn->firstsocket, conn, "ADAT %s", p);
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, NULL);
conn->data.set->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
free(p);
if(/*ret != COMPLETE*/conn->data->buffer[0] != '2'){
if(/*ret != COMPLETE*/conn->data.set->buffer[0] != '2'){
printf("Server didn't accept auth data.\n");
return AUTH_ERROR;
}
p = strstr(conn->data->buffer, "ADAT=");
p = strstr(conn->data.set->buffer, "ADAT=");
if(!p){
printf("Remote host didn't send adat reply.\n");
return AUTH_ERROR;
@ -314,20 +314,20 @@ void Curl_krb_kauth(struct connectdata *conn)
save = Curl_set_command_prot(conn, prot_private);
Curl_ftpsendf(conn->firstsocket, conn,
"SITE KAUTH %s", conn->data->user);
"SITE KAUTH %s", conn->data.set->user);
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data.set->buffer,
conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;
if(/*ret != CONTINUE*/conn->data->buffer[0] != '3'){
if(/*ret != CONTINUE*/conn->data.set->buffer[0] != '3'){
Curl_set_command_prot(conn, save);
/*code = -1;***/
return;
}
p = strstr(conn->data->buffer, "T=");
p = strstr(conn->data.set->buffer, "T=");
if(!p) {
printf("Bad reply from server.\n");
Curl_set_command_prot(conn, save);
@ -344,7 +344,7 @@ void Curl_krb_kauth(struct connectdata *conn)
tkt.length = tmp;
tktcopy.length = tkt.length;
p = strstr(conn->data->buffer, "P=");
p = strstr(conn->data.set->buffer, "P=");
if(!p) {
printf("Bad reply from server.\n");
Curl_set_command_prot(conn, save);
@ -354,7 +354,7 @@ void Curl_krb_kauth(struct connectdata *conn)
for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++);
*p = 0;
des_string_to_key (conn->data->passwd, &key);
des_string_to_key (conn->data.set->passwd, &key);
des_key_sched(&key, schedule);
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat,
@ -383,7 +383,7 @@ void Curl_krb_kauth(struct connectdata *conn)
Curl_ftpsendf(conn->firstsocket, conn,
"SITE KAUTH %s %s", name, p);
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data.set->buffer,
conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;

View File

@ -116,7 +116,7 @@ static void * DynaGetFunction(const char *name)
static int WriteProc(void *param, char *text, int len)
{
struct UrlData *data = (struct UrlData *)param;
struct SessionHandle *data = (struct SessionHandle *)param;
len = 0; /* prevent compiler warning */
Curl_client_write(data, CLIENTWRITE_BODY, text, 0);
return 0;
@ -142,9 +142,9 @@ CURLcode Curl_ldap(struct connectdata *conn)
void *entryIterator;
int ldaptext;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
infof(data, "LDAP: %s %s\n", data->url);
infof(data, "LDAP: %s %s\n", data->change.url);
DynaOpen();
if (libldap == NULL) {
@ -152,7 +152,7 @@ CURLcode Curl_ldap(struct connectdata *conn)
return CURLE_LIBRARY_NOT_FOUND;
}
ldaptext = data->bits.ftp_ascii; /* This is a dirty hack */
ldaptext = data->set.ftp_ascii; /* This is a dirty hack */
/* The types are needed because ANSI C distinguishes between
* pointer-to-object (data) and pointer-to-function.
@ -173,12 +173,12 @@ CURLcode Curl_ldap(struct connectdata *conn)
conn->hostname, conn->port);
status = CURLE_COULDNT_CONNECT;
} else {
rc = ldap_simple_bind_s(server, data->user, data->passwd);
rc = ldap_simple_bind_s(server, data->state.user, data->state.passwd);
if (rc != 0) {
failf(data, "LDAP: %s", ldap_err2string(rc));
status = CURLE_LDAP_CANNOT_BIND;
} else {
rc = ldap_url_search_s(server, data->url, 0, &result);
rc = ldap_url_search_s(server, data->change.url, 0, &result);
if (rc != 0) {
failf(data, "LDAP: %s", ldap_err2string(rc));
status = CURLE_LDAP_SEARCH_FAILED;

View File

@ -93,17 +93,17 @@ static char *max5data(double bytes, char *max5)
void Curl_pgrsDone(struct connectdata *conn)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
if(!(data->progress.flags & PGRS_HIDE)) {
data->progress.lastshow=0;
Curl_pgrsUpdate(conn); /* the final (forced) update */
if(!data->progress.callback)
/* only output if we don't use progress callback */
fprintf(data->err, "\n");
fprintf(data->set.err, "\n");
}
}
void Curl_pgrsTime(struct UrlData *data, timerid timer)
void Curl_pgrsTime(struct SessionHandle *data, timerid timer)
{
switch(timer) {
default:
@ -135,23 +135,23 @@ void Curl_pgrsTime(struct UrlData *data, timerid timer)
}
}
void Curl_pgrsStartNow(struct UrlData *data)
void Curl_pgrsStartNow(struct SessionHandle *data)
{
data->progress.speeder_c = 0; /* reset the progress meter display */
data->progress.start = Curl_tvnow();
}
void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size)
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, double size)
{
data->progress.downloaded = size;
}
void Curl_pgrsSetUploadCounter(struct UrlData *data, double size)
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, double size)
{
data->progress.uploaded = size;
}
void Curl_pgrsSetDownloadSize(struct UrlData *data, double size)
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, double size)
{
if(size > 0) {
data->progress.size_dl = size;
@ -159,7 +159,7 @@ void Curl_pgrsSetDownloadSize(struct UrlData *data, double size)
}
}
void Curl_pgrsSetUploadSize(struct UrlData *data, double size)
void Curl_pgrsSetUploadSize(struct SessionHandle *data, double size)
{
if(size > 0) {
data->progress.size_ul = size;
@ -188,7 +188,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
double total_transfer;
double total_expected_transfer;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
int nowindex = data->progress.speeder_c% CURR_TIME;
int checkindex;
@ -211,9 +211,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
else if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
if (!data->progress.callback) {
if(conn->resume_from)
fprintf(data->err, "** Resuming transfer from byte position %d\n",
fprintf(data->set.err, "** Resuming transfer from byte position %d\n",
conn->resume_from);
fprintf(data->err,
fprintf(data->set.err,
" %% Total %% Received %% Xferd Average Speed Time Curr.\n"
" Dload Upload Total Current Left Speed\n");
}
@ -254,12 +254,12 @@ int Curl_pgrsUpdate(struct connectdata *conn)
if(data->progress.flags & PGRS_HIDE)
return 0;
else if(data->fprogress) {
result= data->fprogress(data->progress_client,
data->progress.size_dl,
data->progress.downloaded,
data->progress.size_ul,
data->progress.uploaded);
else if(data->set.fprogress) {
result= data->set.fprogress(data->set.progress_client,
data->progress.size_dl,
data->progress.downloaded,
data->progress.size_ul,
data->progress.uploaded);
if(result)
failf(data, "Callback aborted");
return result;
@ -310,7 +310,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
if(total_expected_transfer)
total_percen=(double)(total_transfer/total_expected_transfer)*100;
fprintf(data->err,
fprintf(data->set.err,
"\r%3d %s %3d %s %3d %s %s %s %s %s %s %s",
(int)total_percen, /* total % */
max5data(total_expected_transfer, max5[2]), /* total size */
@ -328,7 +328,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
);
/* we flush the output stream to make it appear as soon as possible */
fflush(data->err);
fflush(data->set.err);
return 0;
}

View File

@ -37,13 +37,13 @@ typedef enum {
} timerid;
void Curl_pgrsDone(struct connectdata *);
void Curl_pgrsStartNow(struct UrlData *data);
void Curl_pgrsSetDownloadSize(struct UrlData *data, double size);
void Curl_pgrsSetUploadSize(struct UrlData *data, double size);
void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size);
void Curl_pgrsSetUploadCounter(struct UrlData *data, double size);
void Curl_pgrsStartNow(struct SessionHandle *data);
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, double size);
void Curl_pgrsSetUploadSize(struct SessionHandle *data, double size);
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, double size);
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, double size);
int Curl_pgrsUpdate(struct connectdata *);
void Curl_pgrsTime(struct UrlData *data, timerid timer);
void Curl_pgrsTime(struct SessionHandle *data, timerid timer);
/* Don't show progress for sizes smaller than: */

View File

@ -417,15 +417,15 @@ sec_prot_internal(struct connectdata *conn, int level)
"PBSZ %u", s);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, NULL);
conn->data.set->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != COMPLETE*/conn->data->buffer[0] != '2'){
if(/*ret != COMPLETE*/conn->data.set->buffer[0] != '2'){
failf(conn->data, "Failed to set protection buffer size.\n");
return -1;
}
conn->buffer_size = s;
p = strstr(/*reply_string*/conn->data->buffer, "PBSZ=");
p = strstr(/*reply_string*/conn->data.set->buffer, "PBSZ=");
if(p)
sscanf(p, "PBSZ=%u", &s);
if(s < conn->buffer_size)
@ -436,10 +436,10 @@ sec_prot_internal(struct connectdata *conn, int level)
"PROT %c", level["CSEP"]);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, NULL);
conn->data.set->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != COMPLETE*/conn->data->buffer[0] != '2'){
if(/*ret != COMPLETE*/conn->data.set->buffer[0] != '2'){
failf(conn->data, "Failed to set protection level.\n");
return -1;
}
@ -472,7 +472,7 @@ Curl_sec_login(struct connectdata *conn)
int ret;
struct Curl_sec_client_mech **m;
ssize_t nread;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
for(m = mechs; *m && (*m)->name; m++) {
void *tmp;
@ -494,18 +494,18 @@ Curl_sec_login(struct connectdata *conn)
"AUTH %s", (*m)->name);
/* wait for feedback */
nread = Curl_GetFTPResponse(conn->firstsocket,
conn->data->buffer, conn, NULL);
conn->data.set->buffer, conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/-1;
if(/*ret != CONTINUE*/conn->data->buffer[0] != '3'){
if(/*code == 504*/strncmp(conn->data->buffer,"504",3) == 0) {
if(/*ret != CONTINUE*/conn->data.set->buffer[0] != '3'){
if(/*code == 504*/strncmp(conn->data.set->buffer,"504",3) == 0) {
infof(data,
"%s is not supported by the server.\n", (*m)->name);
}
else if(/*code == 534*/strncmp(conn->data->buffer,"534",3) == 0) {
else if(/*code == 534*/strncmp(conn->data.set->buffer,"534",3) == 0) {
infof(data, "%s rejected as security mechanism.\n", (*m)->name);
}
else if(/*ret == ERROR*/conn->data->buffer[0] == '5') {
else if(/*ret == ERROR*/conn->data.set->buffer[0] == '5') {
infof(data, "The server doesn't support the FTP "
"security extensions.\n");
return -1;

View File

@ -122,13 +122,13 @@ void curl_slist_free_all(struct curl_slist *list)
/* Curl_infof() is for info message along the way */
void Curl_infof(struct UrlData *data, const char *fmt, ...)
void Curl_infof(struct SessionHandle *data, const char *fmt, ...)
{
va_list ap;
if(data->bits.verbose) {
if(data->set.verbose) {
va_start(ap, fmt);
fputs("* ", data->err);
vfprintf(data->err, fmt, ap);
fputs("* ", data->set.err);
vfprintf(data->set.err, fmt, ap);
va_end(ap);
}
}
@ -136,12 +136,12 @@ void Curl_infof(struct UrlData *data, const char *fmt, ...)
/* Curl_failf() is for messages stating why we failed, the LAST one will be
returned for the user (if requested) */
void Curl_failf(struct UrlData *data, const char *fmt, ...)
void Curl_failf(struct SessionHandle *data, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if(data->errorbuffer)
vsnprintf(data->errorbuffer, CURL_ERROR_SIZE, fmt, ap);
if(data->set.errorbuffer)
vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap);
va_end(ap);
}
@ -149,7 +149,7 @@ void Curl_failf(struct UrlData *data, const char *fmt, ...)
size_t Curl_sendf(int sockfd, struct connectdata *conn,
const char *fmt, ...)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
size_t bytes_written;
char *s;
va_list ap;
@ -158,8 +158,8 @@ size_t Curl_sendf(int sockfd, struct connectdata *conn,
va_end(ap);
if(!s)
return 0; /* failure */
if(data->bits.verbose)
fprintf(data->err, "> %s", s);
if(data->set.verbose)
fprintf(data->set.err, "> %s", s);
/* Write the buffer to the socket */
Curl_write(conn, sockfd, s, strlen(s), &bytes_written);
@ -219,7 +219,7 @@ CURLcode Curl_write(struct connectdata *conn, int sockfd,
The bit pattern defines to what "streams" to write to. Body and/or header.
The defines are in sendf.h of course.
*/
CURLcode Curl_client_write(struct UrlData *data,
CURLcode Curl_client_write(struct SessionHandle *data,
int type,
char *ptr,
size_t len)
@ -230,22 +230,22 @@ CURLcode Curl_client_write(struct UrlData *data,
len = strlen(ptr);
if(type & CLIENTWRITE_BODY) {
wrote = data->fwrite(ptr, 1, len, data->out);
wrote = data->set.fwrite(ptr, 1, len, data->set.out);
if(wrote != len) {
failf (data, "Failed writing body");
return CURLE_WRITE_ERROR;
}
}
if((type & CLIENTWRITE_HEADER) &&
(data->fwrite_header || data->writeheader) ) {
(data->set.fwrite_header || data->set.writeheader) ) {
/*
* Write headers to the same callback or to the especially setup
* header callback function (added after version 7.7.1).
*/
curl_write_callback writeit=
data->fwrite_header?data->fwrite_header:data->fwrite;
data->set.fwrite_header?data->set.fwrite_header:data->set.fwrite;
wrote = writeit(ptr, 1, len, data->writeheader);
wrote = writeit(ptr, 1, len, data->set.writeheader);
if(wrote != len) {
failf (data, "Failed writing header");
return CURLE_WRITE_ERROR;

View File

@ -24,8 +24,8 @@
*****************************************************************************/
size_t Curl_sendf(int fd, struct connectdata *, const char *fmt, ...);
void Curl_infof(struct UrlData *, const char *fmt, ...);
void Curl_failf(struct UrlData *, const char *fmt, ...);
void Curl_infof(struct SessionHandle *, const char *fmt, ...);
void Curl_failf(struct SessionHandle *, const char *fmt, ...);
#define infof Curl_infof
#define failf Curl_failf
@ -41,7 +41,7 @@ typedef struct send_buffer send_buffer;
#define CLIENTWRITE_HEADER 2
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
CURLcode Curl_client_write(struct UrlData *data, int type, char *ptr,
CURLcode Curl_client_write(struct SessionHandle *data, int type, char *ptr,
size_t len);
/* internal read-function, does plain socket, SSL and krb4 */

View File

@ -34,36 +34,36 @@
#include "sendf.h"
#include "speedcheck.h"
void Curl_speedinit(struct UrlData *data)
void Curl_speedinit(struct SessionHandle *data)
{
memset(&data->keeps_speed, 0, sizeof(struct timeval));
memset(&data->state.keeps_speed, 0, sizeof(struct timeval));
}
CURLcode Curl_speedcheck(struct UrlData *data,
CURLcode Curl_speedcheck(struct SessionHandle *data,
struct timeval now)
{
if((data->progress.current_speed >= 0) &&
data->low_speed_time &&
(Curl_tvlong(data->keeps_speed) != 0) &&
(data->progress.current_speed < data->low_speed_limit)) {
data->set.low_speed_time &&
(Curl_tvlong(data->state.keeps_speed) != 0) &&
(data->progress.current_speed < data->set.low_speed_limit)) {
/* We are now below the "low speed limit". If we are below it
for "low speed time" seconds we consider that enough reason
to abort the download. */
if( Curl_tvdiff(now, data->keeps_speed) > data->low_speed_time) {
if( Curl_tvdiff(now, data->state.keeps_speed) > data->set.low_speed_time) {
/* we have been this slow for long enough, now die */
failf(data,
"Operation too slow. "
"Less than %d bytes/sec transfered the last %d seconds",
data->low_speed_limit,
data->low_speed_time);
data->set.low_speed_limit,
data->set.low_speed_time);
return CURLE_OPERATION_TIMEOUTED;
}
}
else {
/* we keep up the required speed all right */
data->keeps_speed = now;
data->state.keeps_speed = now;
}
return CURLE_OK;
}

View File

@ -27,8 +27,8 @@
#include "timeval.h"
void Curl_speedinit(struct UrlData *data);
CURLcode Curl_speedcheck(struct UrlData *data,
void Curl_speedinit(struct SessionHandle *data);
CURLcode Curl_speedcheck(struct SessionHandle *data,
struct timeval now);
#endif

View File

@ -94,9 +94,9 @@ bool seed_enough(struct connectdata *conn, /* unused for now */
static
int random_the_seed(struct connectdata *conn)
{
char *buf = conn->data->buffer; /* point to the big buffer */
char *buf = conn->data->state.buffer; /* point to the big buffer */
int nread=0;
struct UrlData *data=conn->data;
struct SessionHandle *data=conn->data;
/* Q: should we add support for a random file name as a libcurl option?
A: Yes, it is here */
@ -104,13 +104,13 @@ int random_the_seed(struct connectdata *conn)
#ifndef RANDOM_FILE
/* if RANDOM_FILE isn't defined, we only perform this if an option tells
us to! */
if(data->ssl.random_file)
if(data->set.ssl.random_file)
#define RANDOM_FILE "" /* doesn't matter won't be used */
#endif
{
/* let the option override the define */
nread += RAND_load_file((data->ssl.random_file?
data->ssl.random_file:RANDOM_FILE),
nread += RAND_load_file((data->set.ssl.random_file?
data->set.ssl.random_file:RANDOM_FILE),
16384);
if(seed_enough(conn, nread))
return nread;
@ -122,13 +122,13 @@ int random_the_seed(struct connectdata *conn)
#ifndef EGD_SOCKET
/* If we don't have the define set, we only do this if the egd-option
is set */
if(data->ssl.egdsocket)
if(data->set.ssl.egdsocket)
#define EGD_SOCKET "" /* doesn't matter won't be used */
#endif
{
/* If there's an option and a define, the option overrides the
define */
int ret = RAND_egd(data->ssl.egdsocket?data->ssl.egdsocket:EGD_SOCKET);
int ret = RAND_egd(data->set.ssl.egdsocket?data->set.ssl.egdsocket:EGD_SOCKET);
if(-1 != ret) {
nread += ret;
if(seed_enough(conn, nread))
@ -176,23 +176,23 @@ int cert_stuff(struct connectdata *conn,
char *cert_file,
char *key_file)
{
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
if (cert_file != NULL) {
SSL *ssl;
X509 *x509;
if(data->cert_passwd) {
if(data->set.cert_passwd) {
#ifndef HAVE_USERDATA_IN_PWD_CALLBACK
/*
* If password has been given, we store that in the global
* area (*shudder*) for a while:
*/
strcpy(global_passwd, data->cert_passwd);
strcpy(global_passwd, data->set.cert_passwd);
#else
/*
* We set the password in the callback userdata
*/
SSL_CTX_set_default_passwd_cb_userdata(conn->ssl.ctx, data->cert_passwd);
SSL_CTX_set_default_passwd_cb_userdata(conn->ssl.ctx, data->set.cert_passwd);
#endif
/* Set passwd callback: */
SSL_CTX_set_default_passwd_cb(conn->ssl.ctx, passwd_callback);
@ -331,11 +331,11 @@ void Curl_SSL_cleanup(void)
/*
* This sets up a session cache to the specified size.
*/
CURLcode Curl_SSL_InitSessions(struct UrlData *data, long amount)
CURLcode Curl_SSL_InitSessions(struct SessionHandle *data, long amount)
{
struct curl_ssl_session *session;
if(data->ssl.session)
if(data->set.ssl.session)
/* this is just a precaution to prevent multiple inits */
return CURLE_OK;
@ -348,9 +348,9 @@ CURLcode Curl_SSL_InitSessions(struct UrlData *data, long amount)
memset(session, 0, amount * sizeof(struct curl_ssl_session));
/* store the info in the SSL section */
data->ssl.numsessions = amount;
data->ssl.session = session;
data->ssl.sessionage = 1; /* this is brand new */
data->set.ssl.numsessions = amount;
data->set.ssl.session = session;
data->set.ssl.sessionage = 1; /* this is brand new */
return CURLE_OK;
}
@ -363,19 +363,19 @@ static int Get_SSL_Session(struct connectdata *conn,
SSL_SESSION **ssl_sessionid)
{
struct curl_ssl_session *check;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
long i;
for(i=0; i< data->ssl.numsessions; i++) {
check = &data->ssl.session[i];
for(i=0; i< data->set.ssl.numsessions; i++) {
check = &data->set.ssl.session[i];
if(!check->sessionid)
/* not session ID means blank entry */
continue;
if(strequal(conn->name, check->name) &&
(conn->remote_port == check->remote_port) ) {
/* yes, we have a session ID! */
data->ssl.sessionage++; /* increase general age */
check->age = data->ssl.sessionage; /* set this as used in this age */
data->set.ssl.sessionage++; /* increase general age */
check->age = data->set.ssl.sessionage; /* set this as used in this age */
*ssl_sessionid = check->sessionid;
return FALSE;
}
@ -409,15 +409,15 @@ static int Kill_Single_Session(struct curl_ssl_session *session)
* This function is called when the 'data' struct is going away. Close
* down everything and free all resources!
*/
int Curl_SSL_Close_All(struct UrlData *data)
int Curl_SSL_Close_All(struct SessionHandle *data)
{
int i;
for(i=0; i< data->ssl.numsessions; i++)
for(i=0; i< data->set.ssl.numsessions; i++)
/* the single-killer function handles empty table slots */
Kill_Single_Session(&data->ssl.session[i]);
Kill_Single_Session(&data->set.ssl.session[i]);
/* free the cache data */
free(data->ssl.session);
free(data->set.ssl.session);
return 0;
}
@ -430,8 +430,8 @@ static int Store_SSL_Session(struct connectdata *conn)
SSL_SESSION *ssl_sessionid;
struct curl_ssl_session *store;
int i;
struct UrlData *data=conn->data; /* the mother of all structs */
int oldest_age=data->ssl.session[0].age; /* zero if unused */
struct SessionHandle *data=conn->data; /* the mother of all structs */
int oldest_age=data->set.ssl.session[0].age; /* zero if unused */
/* ask OpenSSL, say please */
ssl_sessionid = SSL_get1_session(conn->ssl.handle);
@ -444,21 +444,21 @@ static int Store_SSL_Session(struct connectdata *conn)
the oldest if necessary) */
/* find an empty slot for us, or find the oldest */
for(i=0; (i<data->ssl.numsessions) && data->ssl.session[i].sessionid; i++) {
if(data->ssl.session[i].age < oldest_age) {
oldest_age = data->ssl.session[i].age;
store = &data->ssl.session[i];
for(i=0; (i<data->set.ssl.numsessions) && data->set.ssl.session[i].sessionid; i++) {
if(data->set.ssl.session[i].age < oldest_age) {
oldest_age = data->set.ssl.session[i].age;
store = &data->set.ssl.session[i];
}
}
if(i == data->ssl.numsessions)
if(i == data->set.ssl.numsessions)
/* cache is full, we must "kill" the oldest entry! */
Kill_Single_Session(store);
else
store = &data->ssl.session[i]; /* use this slot */
store = &data->set.ssl.session[i]; /* use this slot */
/* now init the session struct wisely */
store->sessionid = ssl_sessionid;
store->age = data->ssl.sessionage; /* set current age */
store->age = data->set.ssl.sessionage; /* set current age */
store->name = strdup(conn->name); /* clone host name */
store->remote_port = conn->remote_port; /* port number */
@ -472,7 +472,7 @@ Curl_SSLConnect(struct connectdata *conn)
CURLcode retcode = CURLE_OK;
#ifdef USE_SSLEAY
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
int err;
char * str;
SSL_METHOD *req_method;
@ -484,7 +484,7 @@ Curl_SSLConnect(struct connectdata *conn)
/* Make funny stuff to get random input */
random_the_seed(conn);
switch(data->ssl.version) {
switch(data->set.ssl.version) {
default:
req_method = SSLv23_client_method();
break;
@ -503,21 +503,21 @@ Curl_SSLConnect(struct connectdata *conn)
return CURLE_OUT_OF_MEMORY;
}
if(data->cert) {
if (!cert_stuff(conn, data->cert, data->cert)) {
if(data->set.cert) {
if (!cert_stuff(conn, data->set.cert, data->set.cert)) {
/* failf() is already done in cert_stuff() */
return CURLE_SSL_CONNECT_ERROR;
}
}
if(data->ssl.verifypeer){
if(data->set.ssl.verifypeer){
SSL_CTX_set_verify(conn->ssl.ctx,
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT|
SSL_VERIFY_CLIENT_ONCE,
cert_verify_callback);
if (!SSL_CTX_load_verify_locations(conn->ssl.ctx,
data->ssl.CAfile,
data->ssl.CApath)) {
data->set.ssl.CAfile,
data->set.ssl.CApath)) {
failf(data,"error setting cerficate verify locations\n");
return CURLE_SSL_CONNECT_ERROR;
}
@ -587,7 +587,7 @@ Curl_SSLConnect(struct connectdata *conn)
infof(data, "\t subject: %s\n", str);
CRYPTO_free(str);
if (data->ssl.verifyhost) {
if (data->set.ssl.verifyhost) {
char peer_CN[257];
if (X509_NAME_get_text_by_NID(X509_get_subject_name(conn->ssl.server_cert), NID_commonName, peer_CN, sizeof(peer_CN)) < 0) {
failf(data, "SSL: unable to obtain common name from peer certificate");
@ -596,7 +596,7 @@ Curl_SSLConnect(struct connectdata *conn)
}
if (!strequal(peer_CN, conn->hostname)) {
if (data->ssl.verifyhost > 1) {
if (data->set.ssl.verifyhost > 1) {
failf(data, "SSL: certificate subject name '%s' does not match target host name '%s'",
peer_CN, conn->hostname);
X509_free(conn->ssl.server_cert);
@ -622,16 +622,16 @@ Curl_SSLConnect(struct connectdata *conn)
/* We could do all sorts of certificate verification stuff here before
deallocating the certificate. */
if(data->ssl.verifypeer) {
data->ssl.certverifyresult=SSL_get_verify_result(conn->ssl.handle);
if (data->ssl.certverifyresult != X509_V_OK) {
if(data->set.ssl.verifypeer) {
data->set.ssl.certverifyresult=SSL_get_verify_result(conn->ssl.handle);
if (data->set.ssl.certverifyresult != X509_V_OK) {
failf(data, "SSL certificate verify result: %d\n",
data->ssl.certverifyresult);
data->set.ssl.certverifyresult);
retcode = CURLE_SSL_PEER_CERTIFICATE;
}
}
else
data->ssl.certverifyresult=0;
data->set.ssl.certverifyresult=0;
X509_free(conn->ssl.server_cert);
#else /* USE_SSLEAY */

View File

@ -28,10 +28,10 @@ void Curl_SSL_init(void); /* Global SSL init */
void Curl_SSL_cleanup(void); /* Global SSL cleanup */
/* init the SSL session ID cache */
CURLcode Curl_SSL_InitSessions(struct UrlData *, long);
CURLcode Curl_SSL_InitSessions(struct SessionHandle *, long);
void Curl_SSL_Close(struct connectdata *conn); /* close a SSL connection */
/* tell the SSL stuff to close down all open information regarding
connections (and thus session ID caching etc) */
int Curl_SSL_Close_All(struct UrlData *data);
int Curl_SSL_Close_All(struct SessionHandle *data);
#endif

View File

@ -105,7 +105,7 @@ void telrcv(struct connectdata *,
unsigned char *inbuf, /* Data received from socket */
int count); /* Number of bytes received */
static void printoption(struct UrlData *data,
static void printoption(struct SessionHandle *data,
const char *direction,
int cmd, int option);
@ -114,7 +114,7 @@ static void send_negotiation(struct connectdata *, int cmd, int option);
static void set_local_option(struct connectdata *, int cmd, int option);
static void set_remote_option(struct connectdata *, int cmd, int option);
static void printsub(struct UrlData *data,
static void printsub(struct SessionHandle *data,
int direction, unsigned char *pointer, int length);
static void suboption(struct connectdata *);
@ -215,13 +215,13 @@ static void negotiate(struct connectdata *conn)
}
}
static void printoption(struct UrlData *data,
static void printoption(struct SessionHandle *data,
const char *direction, int cmd, int option)
{
const char *fmt;
const char *opt;
if (data->bits.verbose)
if (data->set.verbose)
{
if (cmd == IAC)
{
@ -627,14 +627,14 @@ void rec_dont(struct connectdata *conn, int option)
}
static void printsub(struct UrlData *data,
static void printsub(struct SessionHandle *data,
int direction, /* '<' or '>' */
unsigned char *pointer, /* where suboption data is */
int length) /* length of suboption data */
{
int i = 0;
if (data->bits.verbose)
if (data->set.verbose)
{
if (direction)
{
@ -745,7 +745,7 @@ static int check_telnet_options(struct connectdata *conn)
char option_keyword[128];
char option_arg[256];
char *buf;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
/* Add the user name as an environment variable if it
@ -753,13 +753,13 @@ static int check_telnet_options(struct connectdata *conn)
if(conn->bits.user_passwd)
{
char *buf = malloc(256);
sprintf(buf, "USER,%s", data->user);
sprintf(buf, "USER,%s", data->state.user);
tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf);
tn->us_preferred[TELOPT_NEW_ENVIRON] = YES;
}
for(head = data->telnet_options; head; head=head->next) {
for(head = data->set.telnet_options; head; head=head->next) {
if(sscanf(head->data, "%127[^= ]%*[ =]%255s",
option_keyword, option_arg) == 2) {
@ -814,7 +814,7 @@ static void suboption(struct connectdata *conn)
int tmplen;
char varname[128];
char varval[128];
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
printsub(data, '<', (unsigned char *)tn->subbuffer, SB_LEN(tn)+2);
@ -868,7 +868,7 @@ void telrcv(struct connectdata *conn,
{
unsigned char c;
int index = 0;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
while(count--)
@ -1031,13 +1031,13 @@ CURLcode Curl_telnet_done(struct connectdata *conn)
CURLcode Curl_telnet(struct connectdata *conn)
{
CURLcode code;
struct UrlData *data = conn->data;
struct SessionHandle *data = conn->data;
int sockfd = conn->firstsocket;
fd_set readfd;
fd_set keepfd;
bool keepon = TRUE;
char *buf = data->buffer;
char *buf = data->state.buffer;
ssize_t nread;
struct TELNET *tn;

View File

@ -209,16 +209,16 @@ Transfer(struct connectdata *c_conn)
int writetype;
/* the highest fd we use + 1 */
struct UrlData *data;
struct SessionHandle *data;
struct connectdata *conn = (struct connectdata *)c_conn;
char *buf;
int maxfd;
data = conn->data; /* there's the root struct */
buf = data->buffer;
buf = data->state.buffer;
maxfd = (conn->sockfd>conn->writesockfd?conn->sockfd:conn->writesockfd)+1;
hbufp = data->headerbuff;
hbufp = data->state.headerbuff;
myalarm (0); /* switch off the alarm-style timeout */
@ -244,7 +244,7 @@ Transfer(struct connectdata *c_conn)
}
/* we want header and/or body, if neither then don't do this! */
if(conn->getheader ||
!data->bits.no_body) {
!data->set.no_body) {
fd_set readfd;
fd_set writefd;
fd_set rkeepfd;
@ -267,7 +267,7 @@ Transfer(struct connectdata *c_conn)
FD_ZERO (&writefd); /* clear it */
if(conn->writesockfd != -1) {
if (data->bits.expect100header)
if (data->set.expect100header)
/* wait with write until we either got 100-continue or a timeout */
write_after_100_header = TRUE;
else {
@ -350,19 +350,19 @@ Transfer(struct connectdata *c_conn)
* We enlarge the header buffer if it seems to be too
* smallish
*/
if (hbuflen + (int)str_length >= data->headersize) {
if (hbuflen + (int)str_length >= data->state.headersize) {
char *newbuff;
long newsize=MAX((hbuflen+str_length)*3/2,
data->headersize*2);
hbufp_index = hbufp - data->headerbuff;
newbuff = (char *)realloc(data->headerbuff, newsize);
data->state.headersize*2);
hbufp_index = hbufp - data->state.headerbuff;
newbuff = (char *)realloc(data->state.headerbuff, newsize);
if(!newbuff) {
failf (data, "Failed to alloc memory for big header!");
return CURLE_READ_ERROR;
}
data->headersize=newsize;
data->headerbuff = newbuff;
hbufp = data->headerbuff + hbufp_index;
data->state.headersize=newsize;
data->state.headerbuff = newbuff;
hbufp = data->state.headerbuff + hbufp_index;
}
strcpy (hbufp, str);
hbufp += strlen (str);
@ -378,19 +378,19 @@ Transfer(struct connectdata *c_conn)
* fit in the allocated header buffer, or else we enlarge
* it.
*/
if (hbuflen + (str - str_start) >= data->headersize) {
if (hbuflen + (str - str_start) >= data->state.headersize) {
char *newbuff;
long newsize=MAX((hbuflen+(str-str_start))*3/2,
data->headersize*2);
hbufp_index = hbufp - data->headerbuff;
newbuff = (char *)realloc(data->headerbuff, newsize);
data->state.headersize*2);
hbufp_index = hbufp - data->state.headerbuff;
newbuff = (char *)realloc(data->state.headerbuff, newsize);
if(!newbuff) {
failf (data, "Failed to alloc memory for big header!");
return CURLE_READ_ERROR;
}
data->headersize= newsize;
data->headerbuff = newbuff;
hbufp = data->headerbuff + hbufp_index;
data->state.headersize= newsize;
data->state.headerbuff = newbuff;
hbufp = data->state.headerbuff + hbufp_index;
}
/* copy to end of line */
@ -399,7 +399,7 @@ Transfer(struct connectdata *c_conn)
hbuflen += str - str_start;
*hbufp = 0;
p = data->headerbuff;
p = data->state.headerbuff;
/****
* We now have a FULL header line that p points to
@ -449,15 +449,15 @@ Transfer(struct connectdata *c_conn)
/* now, only output this if the header AND body are requested:
*/
writetype = CLIENTWRITE_HEADER;
if (data->bits.http_include_header)
if (data->set.http_include_header)
writetype |= CLIENTWRITE_BODY;
urg = Curl_client_write(data, writetype, data->headerbuff,
p - data->headerbuff);
urg = Curl_client_write(data, writetype, data->state.headerbuff,
p - data->state.headerbuff);
if(urg)
return urg;
data->header_size += p - data->headerbuff;
data->info.header_size += p - data->state.headerbuff;
if(!header) {
/*
@ -466,7 +466,7 @@ Transfer(struct connectdata *c_conn)
* If we requested a "no body", this is a good time to get
* out and return home.
*/
if(data->bits.no_body)
if(data->set.no_body)
return CURLE_OK;
if(!conn->bits.close) {
@ -489,7 +489,7 @@ Transfer(struct connectdata *c_conn)
/* We continue reading headers, so reset the line-based
header parsing variables hbufp && hbuflen */
hbufp = data->headerbuff;
hbufp = data->state.headerbuff;
hbuflen = 0;
continue;
}
@ -516,17 +516,17 @@ Transfer(struct connectdata *c_conn)
}
if (nc) {
data->progress.httpcode = httpcode;
data->progress.httpversion = httpversion;
data->info.httpcode = httpcode;
data->info.httpversion = httpversion;
/* 404 -> URL not found! */
if (
( ((data->bits.http_follow_location) &&
( ((data->set.http_follow_location) &&
(httpcode >= 400))
||
(!data->bits.http_follow_location &&
(!data->set.http_follow_location &&
(httpcode >= 300)))
&& (data->bits.http_fail_on_error)) {
&& (data->set.http_fail_on_error)) {
/* If we have been told to fail hard on HTTP-errors,
here is the check for that: */
/* serious error, go home! */
@ -624,14 +624,14 @@ Transfer(struct connectdata *c_conn)
}
else if(strnequal("Last-Modified:", p,
strlen("Last-Modified:")) &&
(data->timecondition || data->bits.get_filetime) ) {
(data->set.timecondition || data->set.get_filetime) ) {
time_t secs=time(NULL);
timeofdoc = curl_getdate(p+strlen("Last-Modified:"), &secs);
if(data->bits.get_filetime)
data->progress.filetime = timeofdoc;
if(data->set.get_filetime)
data->info.filetime = timeofdoc;
}
else if ((httpcode >= 300 && httpcode < 400) &&
(data->bits.http_follow_location) &&
(data->set.http_follow_location) &&
strnequal("Location:", p, 9)) {
/* this is the URL that the server advices us to get instead */
char *ptr;
@ -660,17 +660,17 @@ Transfer(struct connectdata *c_conn)
*/
writetype = CLIENTWRITE_HEADER;
if (data->bits.http_include_header)
if (data->set.http_include_header)
writetype |= CLIENTWRITE_BODY;
urg = Curl_client_write(data, writetype, p, hbuflen);
if(urg)
return urg;
data->header_size += hbuflen;
data->info.header_size += hbuflen;
/* reset hbufp pointer && hbuflen */
hbufp = data->headerbuff;
hbufp = data->state.headerbuff;
hbuflen = 0;
}
while (*str); /* header line within buffer */
@ -706,7 +706,7 @@ Transfer(struct connectdata *c_conn)
}
else if (conn->resume_from &&
!content_range &&
(data->httpreq==HTTPREQ_GET)) {
(data->set.httpreq==HTTPREQ_GET)) {
/* we wanted to resume a download, although the server
doesn't seem to support this and we did this with a GET
(if it wasn't a GET we did a POST or PUT resume) */
@ -714,23 +714,23 @@ Transfer(struct connectdata *c_conn)
"byte ranges. Cannot resume.");
return CURLE_HTTP_RANGE_ERROR;
}
else if(data->timecondition && !conn->range) {
else if(data->set.timecondition && !conn->range) {
/* A time condition has been set AND no ranges have been
requested. This seems to be what chapter 13.3.4 of
RFC 2616 defines to be the correct action for a
HTTP/1.1 client */
if((timeofdoc > 0) && (data->timevalue > 0)) {
switch(data->timecondition) {
if((timeofdoc > 0) && (data->set.timevalue > 0)) {
switch(data->set.timecondition) {
case TIMECOND_IFMODSINCE:
default:
if(timeofdoc < data->timevalue) {
if(timeofdoc < data->set.timevalue) {
infof(data,
"The requested document is not new enough\n");
return CURLE_OK;
}
break;
case TIMECOND_IFUNMODSINCE:
if(timeofdoc > data->timevalue) {
if(timeofdoc > data->set.timevalue) {
infof(data,
"The requested document is not old enough\n");
return CURLE_OK;
@ -801,10 +801,10 @@ Transfer(struct connectdata *c_conn)
int i, si;
size_t bytes_written;
if(data->crlf)
buf = data->buffer; /* put it back on the buffer */
if(data->set.crlf)
buf = data->state.buffer; /* put it back on the buffer */
nread = data->fread(buf, 1, conn->upload_bufsize, data->in);
nread = data->set.fread(buf, 1, conn->upload_bufsize, data->set.in);
/* the signed int typecase of nread of for systems that has
unsigned size_t */
@ -818,7 +818,7 @@ Transfer(struct connectdata *c_conn)
Curl_pgrsSetUploadCounter(data, (double)writebytecount);
/* convert LF to CRLF if so asked */
if (data->crlf) {
if (data->set.crlf) {
for(i = 0, si = 0; i < (int)nread; i++, si++) {
if (buf[i] == 0x0a) {
scratch[si++] = 0x0d;
@ -863,7 +863,7 @@ Transfer(struct connectdata *c_conn)
conn->upload_bufsize=(long)min(data->progress.ulspeed, BUFSIZE);
}
if (data->timeout && (Curl_tvdiff (now, start) > data->timeout)) {
if (data->set.timeout && (Curl_tvdiff (now, start) > data->set.timeout)) {
failf (data, "Operation timed out with %d out of %d bytes received",
bytecount, conn->size);
return CURLE_OPERATION_TIMEOUTED;
@ -876,7 +876,7 @@ Transfer(struct connectdata *c_conn)
* returning.
*/
if(!(data->bits.no_body) && contentlength &&
if(!(data->set.no_body) && contentlength &&
(bytecount != contentlength)) {
failf(data, "transfer closed with %d bytes remaining to read",
contentlength-bytecount);
@ -898,14 +898,14 @@ Transfer(struct connectdata *c_conn)
return CURLE_OK;
}
CURLcode Curl_perform(struct UrlData *data)
CURLcode Curl_perform(struct SessionHandle *data)
{
CURLcode res;
struct connectdata *conn=NULL;
bool port=TRUE; /* allow data->use_port to set port to use */
bool port=TRUE; /* allow data->set.use_port to set port to use */
char *newurl = NULL; /* possibly a new URL to follow to! */
if(!data->url)
if(!data->change.url)
/* we can't do anything wihout URL */
return CURLE_URL_MALFORMAT;
@ -913,11 +913,11 @@ CURLcode Curl_perform(struct UrlData *data)
/* Init the SSL session ID cache here. We do it here since we want to
do it after the *_setopt() calls (that could change the size) but
before any transfer. */
Curl_SSL_InitSessions(data, data->ssl.numsessions);
Curl_SSL_InitSessions(data, data->set.ssl.numsessions);
#endif
data->followlocation=0; /* reset the location-follow counter */
data->bits.this_is_a_follow = FALSE; /* reset this */
data->set.followlocation=0; /* reset the location-follow counter */
data->state.this_is_a_follow = FALSE; /* reset this */
Curl_initinfo(data); /* reset session-specific information "variables" */
@ -964,30 +964,28 @@ CURLcode Curl_perform(struct UrlData *data)
port=TRUE; /* by default we use the user set port number even after
a Location: */
if (data->maxredirs && (data->followlocation >= data->maxredirs)) {
failf(data,"Maximum (%d) redirects followed", data->maxredirs);
if (data->set.maxredirs && (data->set.followlocation >= data->set.maxredirs)) {
failf(data,"Maximum (%d) redirects followed", data->set.maxredirs);
res=CURLE_TOO_MANY_REDIRECTS;
break;
}
/* mark the next request as a followed location: */
data->bits.this_is_a_follow = TRUE;
data->state.this_is_a_follow = TRUE;
data->followlocation++; /* count location-followers */
data->set.followlocation++; /* count location-followers */
if(data->bits.http_auto_referer) {
if(data->set.http_auto_referer) {
/* We are asked to automatically set the previous URL as the
referer when we get the next URL. We pick the ->url field,
which may or may not be 100% correct */
if(data->free_referer) {
if(data->change.referer_alloc)
/* If we already have an allocated referer, free this first */
free(data->referer);
}
free(data->change.referer);
data->referer = strdup(data->url);
data->free_referer = TRUE; /* yes, free this later */
data->bits.http_set_referer = TRUE; /* might have been false */
data->change.referer = strdup(data->change.url);
data->change.referer_alloc = TRUE; /* yes, free this later */
}
if(2 != sscanf(newurl, "%15[^:]://%c", prot, &letter)) {
@ -1005,7 +1003,7 @@ CURLcode Curl_perform(struct UrlData *data)
/* we must make our own copy of the URL to play with, as it may
point to read-only data */
char *url_clone=strdup(data->url);
char *url_clone=strdup(data->change.url);
if(!url_clone)
return CURLE_OUT_OF_MEMORY;
@ -1055,16 +1053,16 @@ CURLcode Curl_perform(struct UrlData *data)
port = FALSE;
}
if(data->bits.urlstringalloc)
free(data->url);
if(data->change.url_alloc)
free(data->change.url);
else
data->change.url_alloc = TRUE; /* the URL is allocated */
/* TBD: set the URL with curl_setopt() */
data->url = newurl;
data->change.url = newurl;
newurl = NULL; /* don't free! */
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
infof(data, "Follows Location: to new URL: '%s'\n", data->change.url);
/*
* We get here when the HTTP code is 300-399. We need to perform
@ -1072,7 +1070,7 @@ CURLcode Curl_perform(struct UrlData *data)
* Discussed on the curl mailing list and posted about on the 26th
* of January 2001.
*/
switch(data->progress.httpcode) {
switch(data->info.httpcode) {
case 300: /* Multiple Choices */
case 301: /* Moved Permanently */
case 306: /* Not used */
@ -1103,7 +1101,7 @@ CURLcode Curl_perform(struct UrlData *data)
case 303: /* See Other */
/* Disable both types of POSTs, since doing a second POST when
* following isn't what anyone would want! */
data->httpreq = HTTPREQ_GET; /* enforce GET request */
data->set.httpreq = HTTPREQ_GET; /* enforce GET request */
infof(data, "Disables POST, goes with GET\n");
break;
case 304: /* Not Modified */
@ -1132,7 +1130,7 @@ CURLcode Curl_perform(struct UrlData *data)
free(newurl);
/* make sure the alarm is switched off! */
if(data->timeout || data->connecttimeout)
if(data->set.timeout || data->set.connecttimeout)
myalarm(0);
return res;

View File

@ -22,7 +22,7 @@
*
* $Id$
*****************************************************************************/
CURLcode Curl_perform(struct UrlData *data);
CURLcode Curl_perform(struct SessionHandle *data);
/* This sets up a forthcoming transfer */
CURLcode

572
lib/url.c

File diff suppressed because it is too large Load Diff

View File

@ -27,10 +27,10 @@
* Prototypes for library-wide functions provided by url.c
*/
CURLcode Curl_open(struct UrlData **curl);
CURLcode Curl_setopt(struct UrlData *data, CURLoption option, ...);
CURLcode Curl_close(struct UrlData *data); /* the opposite of curl_open() */
CURLcode Curl_connect(struct UrlData *,
CURLcode Curl_open(struct SessionHandle **curl);
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...);
CURLcode Curl_close(struct SessionHandle *data); /* the opposite of curl_open() */
CURLcode Curl_connect(struct SessionHandle *,
struct connectdata **,
bool allow_port);
CURLcode Curl_do(struct connectdata *);

View File

@ -195,8 +195,8 @@ struct ConnectBits {
bool close; /* if set, we close the connection after this request */
bool reuse; /* if set, this is a re-used connection */
bool chunk; /* if set, this is a chunked transfer-encoding */
bool httpproxy; /* if set, this transfer is done through a http proxy */
bool user_passwd; /* do we use user+password for this connection? */
bool httpproxy; /* if set, this transfer is done through a http proxy */
bool user_passwd; /* do we use user+password for this connection? */
bool proxy_user_passwd; /* user+password for the proxy? */
bool use_range;
@ -212,7 +212,7 @@ struct ConnectBits {
*/
struct connectdata {
/**** Fields set when inited and not modified again */
struct UrlData *data; /* link to the root CURL struct */
struct SessionHandle *data; /* link to the root CURL struct */
int connectindex; /* what index in the connects index this particular
struct has */
@ -348,9 +348,21 @@ struct connectdata {
void *generic;
} proto;
};
/*
* Struct to keep statistical and informational data.
*/
struct PureInfo {
int httpcode;
int httpversion;
time_t filetime; /* If requested, this is might get set. It may be 0 if
the time was unretrievable */
long header_size; /* size of read header(s) in bytes */
long request_size; /* the amount of bytes sent in the request(s) */
};
struct Progress {
long lastshow; /* time() of the last displayed progress meter or NULL to
force redraw at next call */
@ -368,17 +380,12 @@ struct Progress {
double dlspeed;
double ulspeed;
struct timeval start;
struct timeval t_startsingle;
/* various data stored for possible later report */
double t_nslookup;
double t_connect;
double t_pretransfer;
int httpcode;
int httpversion;
time_t filetime; /* If requested, this is might get set. It may be 0 if
the time was unretrievable */
struct timeval start;
struct timeval t_startsingle;
#define CURR_TIME 5
double speeder[ CURR_TIME ];
@ -395,9 +402,139 @@ typedef enum {
HTTPREQ_LAST /* last in list */
} Curl_HttpReq;
/* This struct is for boolean settings that define how to behave during
this session. */
struct Configbits {
/*
* Values that are generated, temporary or calculated internally for a
* "session handle" must be defined within the 'struct urlstate'. This struct
* will be used within the SessionHandle struct. When the 'SessionHandle'
* struct is cloned, this data MUST NOT be copied.
*
* Remember that any "state" information goes globally for the curl handle.
* Session-data MUST be put in the connectdata struct and here. */
#define MAX_CURL_USER_LENGTH 256
#define MAX_CURL_PASSWORD_LENGTH 256
struct UrlState {
/* buffers to store authentication data in, as parsed from input options */
char user[MAX_CURL_USER_LENGTH];
char passwd[MAX_CURL_PASSWORD_LENGTH];
char proxyuser[MAX_CURL_USER_LENGTH];
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
struct timeval keeps_speed; /* for the progress meter really */
/* 'connects' will be an allocated array with pointers. If the pointer is
set, it holds an allocated connection. */
struct connectdata **connects;
long numconnects; /* size of the 'connects' array */
char *headerbuff; /* allocated buffer to store headers in */
int headersize; /* size of the allocation */
char buffer[BUFSIZE+1]; /* buffer with size BUFSIZE */
double current_speed; /* the ProgressShow() funcion sets this */
bool this_is_a_follow; /* this is a followed Location: request */
char *auth_host; /* if set, this should be the host name that we will
sent authorization to, no else. Used to make Location:
following not keep sending user+password... This is
strdup() data.
*/
};
/*
* This 'DynamicStatic' struct defines dynamic states that actually change
* values in the 'UserDefined' area, which MUST be taken into consideration
* if the UserDefined struct is cloned or similar. You can probably just
* copy these, but each one indicate a special action on other data.
*/
struct DynamicStatic {
char *url; /* work URL, copied from UserDefined */
bool url_alloc; /* URL string is malloc()'ed */
char *proxy; /* work proxy, copied from UserDefined */
bool proxy_alloc; /* http proxy string is malloc()'ed */
char *referer; /* referer string */
bool referer_alloc; /* referer sting is malloc()ed */
};
/*
* This 'UserDefined' struct must only contain data that is set once to go
* for many (perhaps) independent connections. Values that are generated or
* calculated internally for the "session handle" MUST be defined within the
* 'struct urlstate' instead. The only exceptions MUST note the changes in
* the 'DynamicStatic' struct.
*/
struct UserDefined {
FILE *err; /* the stderr writes goes here */
char *errorbuffer; /* store failure messages in here */
char *proxyuserpwd; /* Proxy <user:password>, if used */
long proxyport; /* If non-zero, use this port number by default. If the
proxy string features a ":[port]" that one will override
this. */
void *out; /* the fetched file goes here */
void *in; /* the uploaded file is read from here */
void *writeheader; /* write the header to this is non-NULL */
char *set_url; /* what original URL to work on */
char *set_proxy; /* proxy to use */
long use_port; /* which port to use (when not using default) */
char *userpwd; /* <user:password>, if used */
char *set_range; /* range, if used. See README for detailed specification
on this syntax. */
long followlocation; /* as in HTTP Location: */
long maxredirs; /* maximum no. of http(s) redirects to follow */
char *set_referer; /* custom string */
bool free_referer; /* set TRUE if 'referer' points to a string we
allocated */
char *useragent; /* User-Agent string */
char *postfields; /* if POST, set the fields' values here */
size_t postfieldsize; /* if POST, this might have a size to use instead of
strlen(), and then the data *may* be binary (contain
zero bytes) */
char *ftpport; /* port to send with the FTP PORT command */
char *device; /* network interface to use */
curl_write_callback fwrite; /* function that stores the output */
curl_write_callback fwrite_header; /* function that stores headers */
curl_read_callback fread; /* function that reads the input */
curl_progress_callback fprogress; /* function for progress information */
void *progress_client; /* pointer to pass to the progress callback */
curl_passwd_callback fpasswd; /* call for password */
void *passwd_client; /* pass to the passwd callback */
long timeout; /* in seconds, 0 means no timeout */
long connecttimeout; /* in seconds, 0 means no timeout */
long infilesize; /* size of file to upload, -1 means unknown */
long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */
int set_resume_from; /* continue [ftp] transfer from here */
char *cookie; /* HTTP cookie string to send */
struct curl_slist *headers; /* linked list of extra headers */
struct HttpPost *httppost; /* linked list of POST data */
char *cert; /* PEM-formatted certificate */
char *cert_passwd; /* plain text certificate password */
char *cookiejar; /* dump all cookies to this file */
bool crlf; /* convert crlf on ftp upload(?) */
struct curl_slist *quote; /* before the transfer */
struct curl_slist *postquote; /* after the transfer */
struct curl_slist *telnet_options; /* linked list of telnet options */
TimeCond timecondition; /* kind of time/date comparison */
time_t timevalue; /* what time to compare with */
curl_closepolicy closepolicy; /* connection cache close concept */
Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
char *customrequest; /* HTTP/FTP request to use */
char *auth_host; /* if set, this is the allocated string to the host name
* to which to send the authorization data to, and no other
* host (which location-following otherwise could lead to)
*/
char *krb4_level; /* what security level */
struct ssl_config_data ssl; /* user defined SSL stuff */
/* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially
and they don't change during operations. */
bool get_filetime;
bool tunnel_thru_httpproxy;
bool ftp_append;
@ -410,182 +547,37 @@ struct Configbits {
bool http_include_header;
bool http_set_referer;
bool http_auto_referer; /* set "correct" referer when following location: */
bool httpproxy;
bool no_body;
bool set_port;
bool set_range;
bool upload;
bool use_netrc;
bool verbose;
bool this_is_a_follow; /* this is a followed Location: request */
bool krb4; /* kerberos4 connection requested */
bool proxystringalloc; /* the http proxy string is malloc()'ed */
bool urlstringalloc; /* the URL string is malloc()'ed */
bool reuse_forbid; /* if this is forbidden to be reused, close
after use */
bool reuse_fresh; /* do not re-use an existing connection for this
transfer */
bool expect100header; /* TRUE if we added Expect: 100-continue to the
HTTP header */
bool krb4; /* kerberos4 connection requested */
bool reuse_forbid; /* forbidden to be reused, close after use */
bool reuse_fresh; /* do not re-use an existing connection */
bool expect100header; /* TRUE if we added Expect: 100-continue */
};
/*
* As of April 11, 2000 we're now trying to split up the urldata struct in
* three different parts:
* In August 2001, this struct was redesigned and is since stricter than
* before. The 'connectdata' struct MUST have all the connection oriented
* stuff as we may now have several simultaneous connections and connection
* structs in memory.
*
* (Global)
* 1 - No matter how many hosts and requests that are being performed, this
* goes for all of them.
*
* (Session)
* 2 - Host and protocol-specific. No matter if we do several transfers to and
* from this host, these variables stay the same.
*
* (Request)
* 3 - Request-specific. Variables that are of interest for this particular
* transfer being made right now. THIS IS WRONG STRUCT FOR THOSE.
*
* In Febrary 2001, this is being done stricter. The 'connectdata' struct
* MUST have all the connection oriented stuff as we may now have several
* simultaneous connections and connection structs in memory.
*
* From now on, the 'UrlData' must only contain data that is set once to go
* for many (perhaps) independent connections. Values that are generated or
* calculated internally MUST NOT be a part of this struct.
*/
* From now on, the 'SessionHandle' must only contain data that is set once to
* go for many (perhaps) independent connections. Values that are generated or
* calculated internally for the "session handle" must be defined within the
* 'struct urlstate' instead. */
struct UrlData {
/*************** Global - specific items ************/
FILE *err; /* the stderr writes goes here */
char *errorbuffer; /* store failure messages in here */
/*************** Session - specific items ************/
char *proxy; /* if proxy, set it here */
char *proxyuserpwd; /* Proxy <user:password>, if used */
long proxyport; /* If non-zero, use this port number by default. If the
proxy string features a ":[port]" that one will override
this. */
long header_size; /* size of read header(s) in bytes */
long request_size; /* the amount of bytes sent in the request(s) */
void *out; /* the fetched file goes here */
void *in; /* the uploaded file is read from here */
void *writeheader; /* write the header to this is non-NULL */
char *url; /* what to get */
char *freethis; /* if non-NULL, an allocated string for the URL */
long use_port; /* which port to use (when not using default) */
struct Configbits bits; /* new-style (v7) flag data */
struct ssl_config_data ssl; /* this is for ssl-stuff */
char *userpwd; /* <user:password>, if used */
char *set_range; /* range, if used. See README for detailed specification on
this syntax. */
/* stuff related to HTTP */
long followlocation;
long maxredirs; /* maximum no. of http(s) redirects to follow */
char *referer;
bool free_referer; /* set TRUE if 'referer' points to a string we
allocated */
char *useragent; /* User-Agent string */
char *postfields; /* if POST, set the fields' values here */
size_t postfieldsize; /* if POST, this might have a size to use instead of
strlen(), and then the data *may* be binary (contain
zero bytes) */
/* stuff related to FTP */
char *ftpport; /* port to send with the PORT command */
/* general things */
char *device; /* Interface to use */
/* function that stores the output:*/
curl_write_callback fwrite;
/* optional function that stores the header output:*/
curl_write_callback fwrite_header;
/* function that reads the input:*/
curl_read_callback fread;
/* function that wants progress information */
curl_progress_callback fprogress;
void *progress_client; /* pointer to pass to the progress callback */
/* function to call instead of the internal for password */
curl_passwd_callback fpasswd;
void *passwd_client; /* pointer to pass to the passwd callback */
long timeout; /* in seconds, 0 means no timeout */
long connecttimeout; /* in seconds, 0 means no timeout */
long infilesize; /* size of file to upload, -1 means unknown */
char buffer[BUFSIZE+1]; /* buffer with size BUFSIZE */
double current_speed; /* the ProgressShow() funcion sets this */
long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */
int set_resume_from; /* continue [ftp] transfer from here */
char *cookie; /* HTTP cookie string to send */
struct curl_slist *headers; /* linked list of extra headers */
struct HttpPost *httppost; /* linked list of POST data */
char *cert; /* PEM-formatted certificate */
char *cert_passwd; /* plain text certificate password */
struct CookieInfo *cookies;
char *cookiejar; /* dump all cookies to this file */
long crlf;
struct curl_slist *quote; /* before the transfer */
struct curl_slist *postquote; /* after the transfer */
/* Telnet negotiation options */
struct curl_slist *telnet_options; /* linked list of telnet options */
TimeCond timecondition; /* kind of comparison */
time_t timevalue; /* what time to compare with */
Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
char *customrequest; /* http/ftp request to use */
char *headerbuff; /* allocated buffer to store headers in */
int headersize; /* size of the allocation */
struct Progress progress; /* for all the progress meter data */
#define MAX_CURL_USER_LENGTH 128
#define MAX_CURL_PASSWORD_LENGTH 128
char *auth_host; /* if set, this is the allocated string to the host name
* to which to send the authorization data to, and no other
* host (which location-following otherwise could lead to)
*/
/* buffers to store authentication data in */
char user[MAX_CURL_USER_LENGTH];
char passwd[MAX_CURL_PASSWORD_LENGTH];
char proxyuser[MAX_CURL_USER_LENGTH];
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
char *krb4_level; /* what security level */
struct timeval keeps_speed; /* this should be request-specific */
/* 'connects' will be an allocated array with pointers. If the pointer is
set, it holds an allocated connection. */
struct connectdata **connects;
long numconnects; /* size of the 'connects' array */
curl_closepolicy closepolicy;
struct SessionHandle {
struct UserDefined set; /* values set by the libcurl user */
struct DynamicStatic change; /* possibly modified userdefined data */
struct CookieInfo *cookies; /* the cookies, read from files and servers */
struct Progress progress; /* for all the progress meter data */
struct UrlState state; /* struct for fields used for state info and
other dynamic purposes */
struct PureInfo info; /* stats, reports and info data */
};
#define LIBCURL_NAME "libcurl"