diff options
Diffstat (limited to 'Source/CTest/Curl/telnet.c')
-rw-r--r-- | Source/CTest/Curl/telnet.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/Source/CTest/Curl/telnet.c b/Source/CTest/Curl/telnet.c index 29c2110..42a1780 100644 --- a/Source/CTest/Curl/telnet.c +++ b/Source/CTest/Curl/telnet.c @@ -1,28 +1,29 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2000, Daniel Stenberg, <daniel@haxx.se>, et al. - * - * In order to be useful for every potential user, curl and libcurl are - * dual-licensed under the MPL and the MIT/X-derivate licenses. + * Copyright (C) 1998 - 2002, Daniel Stenberg, <daniel@haxx.se>, et al. * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the MPL or the MIT/X-derivate - * licenses. You may pick one of these licenses. + * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * $Id$ - *****************************************************************************/ + ***************************************************************************/ #include "setup.h" +#ifndef CURL_DISABLE_TELNET /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -1049,6 +1050,7 @@ CURLcode Curl_telnet(struct connectdata *conn) char *buf = data->state.buffer; ssize_t nread; struct TELNET *tn; + struct timeval now; /* current time */ code = init_telnet(conn); if(code) @@ -1148,9 +1150,13 @@ CURLcode Curl_telnet(struct connectdata *conn) keepfd = readfd; while (keepon) { + struct timeval interval; + readfd = keepfd; /* set this every lap in the loop */ + interval.tv_sec = 1; + interval.tv_usec = 0; - switch (select (sockfd + 1, &readfd, NULL, NULL, NULL)) { + switch (select (sockfd + 1, &readfd, NULL, NULL, &interval)) { case -1: /* error, stop reading */ keepon = FALSE; continue; @@ -1198,10 +1204,20 @@ CURLcode Curl_telnet(struct connectdata *conn) } } } + if(data->set.timeout) { + now = Curl_tvnow(); + if(Curl_tvdiff(now, conn->created)/1000 >= data->set.timeout) { + failf(data, "Time-out"); + code = CURLE_OPERATION_TIMEOUTED; + keepon = FALSE; + } + } } #endif /* mark this as "no further transfer wanted" */ - return Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL); + + return code; } /* @@ -1211,3 +1227,4 @@ CURLcode Curl_telnet(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif |