--- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\include\curl\curl.h Sun Dec 04 11:04:44 2005 +++ C:\dev\ExtLibs\Curl\include\curl\curl.h Mon Jan 16 08:56:24 2006 @@ -910,7 +910,13 @@ CINIT(FTP_SKIP_PASV_IP, LONG, 137), /* Select "file method" to use when doing FTP */ - CINIT(FTP_FILEMETHOD, LONG, 138), + CINIT(FTP_FILEMETHOD, LONG, 138), + + /* Allen Chan + ** whether to connect to the server only and do nothing or not + */ + CINIT(CONNECT_ONLY, LONG, 139), + /* End */ CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -1265,10 +1271,17 @@ CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, - CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, + CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, + + /* Allen Chan */ + CURLINFO_SOCKET = CURLINFO_LONG + 29, + CURLINFO_LOCAL_PORT = CURLINFO_LONG + 30, + /* End */ + /* Fill in new entries below here! */ - CURLINFO_LASTONE = 28 + CURLINFO_LASTONE = 30 // Allen Chan + } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as --- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\lib\getinfo.c Thu Jul 28 00:17:16 2005 +++ C:\dev\ExtLibs\Curl\lib\getinfo.c Mon Jan 16 08:57:02 2006 @@ -185,8 +185,54 @@ *param_slistp = Curl_ssl_engines_list(data); break; case CURLINFO_COOKIELIST: - *param_slistp = Curl_cookie_list(data); - break; + *param_slistp = Curl_cookie_list(data); + break; + /* Allen Chan (mod) from Vadim Lebedev*/ + case CURLINFO_SOCKET: + case CURLINFO_LOCAL_PORT: + { + int i; + struct connectdata *conn; + struct timeval now; + long lowscore, score; + int winner = -1; + + now = Curl_tvnow(); + + for(i=0; i< data->state.numconnects; i++) { + conn = data->state.connects[i]; + + if(!conn) + continue; + + score = Curl_tvdiff(now, conn->now); + if ((winner == -1) || (score < lowscore)) { + lowscore = score; + winner = i; + } + } + if (winner == -1) + return CURLE_GOT_NOTHING; + + if(info==CURLINFO_LOCAL_PORT) { + SOCKADDR_IN SockaddrOut; + int nSockaddrOutLen = sizeof(SockaddrOut); + + if (data->state.connects[winner]->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) { + *param_longp = INVALID_SOCKET; + } + else { + getsockname(data->state.connects[winner]->sock[FIRSTSOCKET], (LPSOCKADDR)&SockaddrOut, &nSockaddrOutLen); + *param_longp = ntohs(SockaddrOut.sin_port)+1; + } + break; + } + else { + *param_longp = data->state.connects[winner]->sock[FIRSTSOCKET]; + } + break; + } + /* End */ default: return CURLE_BAD_FUNCTION_ARGUMENT; } --- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\lib\multi.c Tue Mar 08 23:22:00 2005 +++ C:\dev\ExtLibs\Curl\lib\multi.c Mon Jan 16 09:33:34 2006 @@ -522,8 +522,19 @@ break; case CURLM_STATE_DO: - /* Perform the protocol's DO action */ - easy->result = Curl_do(&easy->easy_conn, &dophase_done); + /* Allen Chan */ + if(easy->easy_handle->set.connect_only) { + printf("Connect only enabled\n"); + multistate(easy, CURLM_STATE_DONE); + easy->result = CURLE_OK; + easy->state = CURLM_STATE_COMPLETED; + result = CURLM_OK; + break; + } + /* End */ + + /* Perform the protocol's DO action */ + easy->result = Curl_do(&easy->easy_conn, &dophase_done); if(CURLE_OK == easy->result) { --- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\lib\transfer.c Thu Nov 24 11:22:48 2005 +++ C:\dev\ExtLibs\Curl\lib\transfer.c Mon Jan 16 09:24:18 2006 @@ -2155,7 +2155,14 @@ conn->sec_conn = NULL; } - if(res == CURLE_OK) { + /* Allen Chan */ + if(data->set.connect_only) { + printf("Connect only enabled\n"); + return CURLE_OK; + } + /* End */ + + if(res == CURLE_OK) { bool do_done; res = Curl_do(&conn, &do_done); --- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\lib\url.c Wed Dec 07 00:05:52 2005 +++ C:\dev\ExtLibs\Curl\lib\url.c Fri Jan 13 17:54:55 2006 @@ -1458,7 +1458,13 @@ case CURLOPT_IGNORE_CONTENT_LENGTH: data->set.ignorecl = va_arg(param, long)?TRUE:FALSE; - break; + break; + + /* Allen Chan */ + case CURLOPT_CONNECT_ONLY: + data->set.connect_only = va_arg(param, long)?TRUE:FALSE; + break; + /* End */ default: /* unknown tag and its companion, just ignore: */ @@ -3807,7 +3813,7 @@ if conn->bits.close is TRUE, it means that the connection should be closed in spite of all our efforts to be nice, due to protocol - restrictions in our or the server's end */ + restrictions in our or the server's end */ if(data->set.reuse_forbid || conn->bits.close) { CURLcode res2; res2 = Curl_disconnect(conn); /* close the connection */ @@ -3832,10 +3838,10 @@ { CURLcode result=CURLE_OK; struct connectdata *conn = *connp; - struct SessionHandle *data=conn->data; + struct SessionHandle *data=conn->data; conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */ - + if(conn->curl_do) { /* generic protocol-specific function pointer set in curl_connect() */ result = conn->curl_do(conn, done); --- C:\Documents and Settings\allen.ISA\デスクトップ\curl-7.15.1\curl-7.15.1\lib\urldata.h Tue Nov 29 00:06:00 2005 +++ C:\dev\ExtLibs\Curl\lib\urldata.h Fri Jan 13 15:49:00 2006 @@ -746,7 +746,7 @@ /* These three are used for chunked-encoding trailer support */ char *trailer; /* allocated buffer to store trailer in */ int trlMax; /* allocated buffer size */ - int trlPos; /* index of where to store data */ + int trlPos; /* index of where to store data */ }; @@ -771,7 +771,7 @@ long numconnects; /* how many new connection did libcurl created */ - char *contenttype; /* the content type of the object */ + char *contenttype; /* the content type of the object */ }; @@ -1084,7 +1084,11 @@ bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */ bool ignorecl; /* ignore content length */ bool ftp_skip_ip; /* skip the IP address the FTP server passes on to - us */ + us */ + + /* Allen Chan */ + bool connect_only; /* whether to connect to the server only and do nothing or not */ + }; /*