Loading lib/dict.c +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading lib/easy.c +5 −8 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -186,9 +186,6 @@ CURL *curl_easy_init(void) if(res != CURLE_OK) return NULL; /* SAC */ data->device = NULL; return data; } Loading @@ -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); Loading Loading @@ -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); } Loading @@ -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 *); Loading lib/file.c +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading lib/ftp.c +74 −77 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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 */ Loading @@ -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"); Loading Loading @@ -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 */ } Loading Loading @@ -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; Loading @@ -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); Loading Loading @@ -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"); Loading Loading @@ -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 } Loading Loading @@ -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; } } Loading @@ -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; Loading @@ -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); Loading @@ -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; } Loading @@ -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; Loading @@ -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; Loading @@ -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 */ Loading @@ -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"); Loading @@ -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"); Loading @@ -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); Loading @@ -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) Loading @@ -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; } Loading @@ -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; Loading @@ -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! */ Loading @@ -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; Loading @@ -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", Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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 Loading Loading @@ -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]; Loading Loading @@ -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; Loading Loading @@ -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); Loading @@ -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; Loading Loading @@ -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 Loading @@ -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) { Loading @@ -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 */ Loading @@ -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 Loading @@ -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 ) Loading @@ -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); Loading Loading @@ -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. */ Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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() */ Loading Loading @@ -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 */ Loading @@ -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); } Loading lib/getinfo.c +12 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading Loading
lib/dict.c +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
lib/easy.c +5 −8 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -186,9 +186,6 @@ CURL *curl_easy_init(void) if(res != CURLE_OK) return NULL; /* SAC */ data->device = NULL; return data; } Loading @@ -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); Loading Loading @@ -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); } Loading @@ -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 *); Loading
lib/file.c +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading
lib/ftp.c +74 −77 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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 */ Loading @@ -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"); Loading Loading @@ -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 */ } Loading Loading @@ -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; Loading @@ -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); Loading Loading @@ -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"); Loading Loading @@ -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 } Loading Loading @@ -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; } } Loading @@ -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; Loading @@ -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); Loading @@ -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; } Loading @@ -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; Loading @@ -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; Loading @@ -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 */ Loading @@ -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"); Loading @@ -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"); Loading @@ -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); Loading @@ -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) Loading @@ -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; } Loading @@ -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; Loading @@ -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! */ Loading @@ -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; Loading @@ -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", Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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 Loading Loading @@ -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]; Loading Loading @@ -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; Loading Loading @@ -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); Loading @@ -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; Loading Loading @@ -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 Loading @@ -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) { Loading @@ -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 */ Loading @@ -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 Loading @@ -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 ) Loading @@ -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); Loading Loading @@ -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. */ Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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() */ Loading Loading @@ -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 */ Loading @@ -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); } Loading
lib/getinfo.c +12 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading