diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-06-11 11:13:01 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-06-11 11:13:01 +0000 |
commit | 08ef208fb78fb2eabc5cec08c23e74e251eac898 (patch) | |
tree | c52fa36be6197717f9ab12031a623091d785b51c /lib | |
parent | 8c45e2a6415a3a12231b88cd2791141ec809d163 (diff) |
added disable-[protocol] support, largely provided by Miklos Nemeth
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arpa_telnet.h | 4 | ||||
-rw-r--r-- | lib/cookie.c | 4 | ||||
-rw-r--r-- | lib/dict.h | 3 | ||||
-rw-r--r-- | lib/file.c | 2 | ||||
-rw-r--r-- | lib/file.h | 2 | ||||
-rw-r--r-- | lib/formdata.c | 4 | ||||
-rw-r--r-- | lib/ftp.c | 4 | ||||
-rw-r--r-- | lib/ftp.h | 8 | ||||
-rw-r--r-- | lib/http.c | 2 | ||||
-rw-r--r-- | lib/http.h | 4 | ||||
-rw-r--r-- | lib/http_chunks.c | 2 | ||||
-rw-r--r-- | lib/krb4.c | 2 | ||||
-rw-r--r-- | lib/ldap.c | 2 | ||||
-rw-r--r-- | lib/ldap.h | 3 | ||||
-rw-r--r-- | lib/security.c | 2 | ||||
-rw-r--r-- | lib/setup.h | 12 | ||||
-rw-r--r-- | lib/telnet.c | 2 | ||||
-rw-r--r-- | lib/telnet.h | 3 | ||||
-rw-r--r-- | lib/url.c | 72 |
19 files changed, 127 insertions, 10 deletions
diff --git a/lib/arpa_telnet.h b/lib/arpa_telnet.h index 063bc6fc1..caf6c7f03 100644 --- a/lib/arpa_telnet.h +++ b/lib/arpa_telnet.h @@ -22,7 +22,7 @@ * * $Id$ *****************************************************************************/ - +#ifndef CURL_DISABLE_TELNET /* * Telnet option defines. Add more here if in need. */ @@ -97,5 +97,5 @@ static const char *telnetcmds[]= #define TELCMD_OK(x) ( ((unsigned int)(x) >= TELCMD_MINIMUM) && \ ((unsigned int)(x) <= TELCMD_MAXIMUM) ) #define TELCMD(x) telnetcmds[(x)-TELCMD_MINIMUM] - +#endif #endif diff --git a/lib/cookie.c b/lib/cookie.c index 2a90d0b8b..e7628a9b3 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -79,6 +79,8 @@ Example set of cookies: #include "setup.h" +#ifndef CURL_DISABLE_HTTP + #include <stdlib.h> #include <string.h> #include <ctype.h> @@ -761,6 +763,8 @@ int main(int argc, char **argv) #endif +#endif /* CURL_DISABLE_HTTP */ + /* * local variables: * eval: (load-file "../curl-mode.el") diff --git a/lib/dict.h b/lib/dict.h index ca76d36c1..cee36e073 100644 --- a/lib/dict.h +++ b/lib/dict.h @@ -23,7 +23,8 @@ * * $Id$ *****************************************************************************/ +#ifndef CURL_DISABLE_DICT CURLcode Curl_dict(struct connectdata *conn); CURLcode Curl_dict_done(struct connectdata *conn); - +#endif #endif diff --git a/lib/file.c b/lib/file.c index 4515d9d94..b3ab757fd 100644 --- a/lib/file.c +++ b/lib/file.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_FILE /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -204,3 +205,4 @@ CURLcode Curl_file(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif diff --git a/lib/file.h b/lib/file.h index f0dcf8ff3..4a26893e8 100644 --- a/lib/file.h +++ b/lib/file.h @@ -23,6 +23,8 @@ * * $Id$ *****************************************************************************/ +#ifndef CURL_DISABLE_FILE CURLcode Curl_file(struct connectdata *conn); CURLcode Curl_file_connect(struct connectdata *conn); #endif +#endif diff --git a/lib/formdata.c b/lib/formdata.c index a5d367cd5..5c1575e57 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -109,6 +109,8 @@ Content-Disposition: form-data; name="FILECONTENT" #include "setup.h" +#ifndef CURL_DISABLE_HTTP + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1505,6 +1507,8 @@ int main(int argc, char **argv) #endif +#endif /* CURL_DISABLE_HTTP */ + /* * local variables: * eval: (load-file "../curl-mode.el") @@ -23,6 +23,8 @@ #include "setup.h" +/* MN 06/07/02 */ +#ifndef CURL_DISABLE_FTP #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -2141,3 +2143,5 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ + +#endif /* CURL_DISABLE_FTP */ @@ -23,6 +23,10 @@ * * $Id$ *****************************************************************************/ + +/* MN 06/07/02 */ +#ifndef CURL_DISABLE_FTP + CURLcode Curl_ftp(struct connectdata *conn); CURLcode Curl_ftp_done(struct connectdata *conn); CURLcode Curl_ftp_connect(struct connectdata *conn); @@ -34,4 +38,8 @@ CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...); int Curl_GetFTPResponse(char *buf, struct connectdata *conn, int *ftpcode); +/* MN 06/07/02 */ +#endif + + #endif diff --git a/lib/http.c b/lib/http.c index b135912bb..763b90a3a 100644 --- a/lib/http.c +++ b/lib/http.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_HTTP /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -987,3 +988,4 @@ CURLcode Curl_http(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif diff --git a/lib/http.h b/lib/http.h index ef5bedebb..2650106cc 100644 --- a/lib/http.h +++ b/lib/http.h @@ -23,7 +23,7 @@ * * $Id$ *****************************************************************************/ - +#ifndef CURL_DISABLE_HTTP /* ftp can use this as well */ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn, int tunnelsocket, @@ -38,5 +38,5 @@ CURLcode Curl_http_connect(struct connectdata *conn); void Curl_httpchunk_init(struct connectdata *conn); CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap, ssize_t length, ssize_t *wrote); - +#endif #endif diff --git a/lib/http_chunks.c b/lib/http_chunks.c index a49e405e7..939e86a91 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -22,6 +22,7 @@ *****************************************************************************/ #include "setup.h" +#ifndef CURL_DISABLE_HTTP /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -228,3 +229,4 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif /* CURL_DISABLE_HTTP */ diff --git a/lib/krb4.c b/lib/krb4.c index 10b386fbe..b59638310 100644 --- a/lib/krb4.c +++ b/lib/krb4.c @@ -40,6 +40,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_FTP #ifdef KRB4 #include "security.h" @@ -391,6 +392,7 @@ void Curl_krb_kauth(struct connectdata *conn) } #endif /* KRB4 */ +#endif /* CURL_DISABLE_FTP */ /* * local variables: diff --git a/lib/ldap.c b/lib/ldap.c index 910907f58..331ba1622 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_LDAP /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -229,3 +230,4 @@ CURLcode Curl_ldap(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif diff --git a/lib/ldap.h b/lib/ldap.h index 9bc487551..084fd1024 100644 --- a/lib/ldap.h +++ b/lib/ldap.h @@ -23,7 +23,8 @@ * * $Id$ *****************************************************************************/ +#ifndef CURL_DISABLE_LDAP CURLcode Curl_ldap(struct connectdata *conn); CURLcode Curl_ldap_done(struct connectdata *conn); - +#endif #endif /* __LDAP_H */ diff --git a/lib/security.c b/lib/security.c index 1be54c8b8..06dec3258 100644 --- a/lib/security.c +++ b/lib/security.c @@ -40,6 +40,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_FTP #ifdef KRB4 #define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */ @@ -552,6 +553,7 @@ Curl_sec_end(struct connectdata *conn) } #endif /* KRB4 */ +#endif /* CURL_DISABLE_FTP */ /* * local variables: diff --git a/lib/setup.h b/lib/setup.h index fef994297..2bd0588e8 100644 --- a/lib/setup.h +++ b/lib/setup.h @@ -23,7 +23,17 @@ * $Id$ *****************************************************************************/ - +/* MN 06/07/02 */ +/* #define HTTP_ONLY +*/ +#ifdef HTTP_ONLY +#define CURL_DISABLE_FTP +#define CURL_DISABLE_LDAP +#define CURL_DISABLE_TELNET +#define CURL_DISABLE_DICT +#define CURL_DISABLE_FILE +#define CURL_DISABLE_GOPHER +#endif #if !defined(WIN32) && defined(_WIN32) /* This _might_ be a good Borland fix. Please report whether this works or diff --git a/lib/telnet.c b/lib/telnet.c index 5b6423fb7..e658a5e2d 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_TELNET /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -1211,3 +1212,4 @@ CURLcode Curl_telnet(struct connectdata *conn) * vim600: fdm=marker * vim: et sw=2 ts=2 sts=2 tw=78 */ +#endif diff --git a/lib/telnet.h b/lib/telnet.h index c566b4a56..41ec79df1 100644 --- a/lib/telnet.h +++ b/lib/telnet.h @@ -23,7 +23,8 @@ * * $Id$ *****************************************************************************/ +#ifndef CURL_DISABLE_TELNET CURLcode Curl_telnet(struct connectdata *conn); CURLcode Curl_telnet_done(struct connectdata *conn); - +#endif #endif @@ -139,10 +139,16 @@ static unsigned int ConnectionStore(struct SessionHandle *data, #define RETSIGTYPE void #endif static +RETSIGTYPE sigintfunc(int signal) +{ + (void)signal; /* ignored */ + return; +} RETSIGTYPE alarmfunc(int signal) { /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */ (void)signal; + kill(getpid(), SIGINT); return; } #endif @@ -182,11 +188,13 @@ CURLcode Curl_close(struct SessionHandle *data) if(data->state.headerbuff) free(data->state.headerbuff); +#ifndef CURL_DISABLE_HTTP if(data->set.cookiejar) /* we have a "destination" for all the cookies to get dumped to */ Curl_cookie_output(data->cookies, data->set.cookiejar); Curl_cookie_cleanup(data->cookies); +#endif /* free the connection cache */ free(data->state.connects); @@ -514,6 +522,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) data->set.cookiesession = (bool)va_arg(param, long); break; +#ifndef CURL_DISABLE_HTTP case CURLOPT_COOKIEFILE: /* * Set cookie file to read and parse. Can be used multiple times. @@ -537,6 +546,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) data->cookies = Curl_cookie_init(NULL, data->cookies, data->set.cookiesession); break; +#endif + case CURLOPT_WRITEHEADER: /* * Custom pointer to pass the header write callback function @@ -1712,6 +1723,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->protocol &= ~PROT_MISSING; /* switch that one off again */ } +#ifndef CURL_DISABLE_HTTP /************************************************************ * RESUME on a HTTP page is a tricky business. First, let's just check that * 'range' isn't used, then set the range parameter and leave the resume as @@ -1730,12 +1742,13 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->bits.use_range = 1; /* switch on range usage */ } } - +#endif /************************************************************* * Setup internals depending on protocol *************************************************************/ if (strequal(conn->protostr, "HTTP")) { +#ifndef CURL_DISABLE_HTTP conn->port = (data->set.use_port && data->state.allow_port)? data->set.use_port:PORT_HTTP; conn->remote_port = PORT_HTTP; @@ -1743,9 +1756,14 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->curl_do = Curl_http; conn->curl_done = Curl_http_done; conn->curl_connect = Curl_http_connect; +#else + failf(data, LIBCURL_NAME + " was built with HTTP disabled, http: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif } else if (strequal(conn->protostr, "HTTPS")) { -#ifdef USE_SSLEAY +#if defined(USE_SSLEAY) && !defined(CURL_DISABLE_HTTP) conn->port = (data->set.use_port && data->state.allow_port)? data->set.use_port:PORT_HTTPS; @@ -1763,6 +1781,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, #endif /* !USE_SSLEAY */ } else if (strequal(conn->protostr, "GOPHER")) { +#ifndef CURL_DISABLE_GOPHER conn->port = (data->set.use_port && data->state.allow_port)? data->set.use_port:PORT_GOPHER; conn->remote_port = PORT_GOPHER; @@ -1775,9 +1794,16 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->protocol |= PROT_GOPHER; conn->curl_do = Curl_http; conn->curl_done = Curl_http_done; +#else + failf(data, LIBCURL_NAME + " was built with GOPHER disabled, gopher: not supported!"); +#endif } else if(strequal(conn->protostr, "FTP") || strequal(conn->protostr, "FTPS")) { + +/* MN 06/07/02 */ +#ifndef CURL_DISABLE_FTP char *type; if(strequal(conn->protostr, "FTPS")) { @@ -1805,8 +1831,13 @@ static CURLcode CreateConnection(struct SessionHandle *data, failf(data, "ftps does not work through http proxy!"); return CURLE_UNSUPPORTED_PROTOCOL; } +#ifndef CURL_DISABLE_HTTP conn->curl_do = Curl_http; conn->curl_done = Curl_http_done; +#else + failf(data, "FTP over http proxy requires HTTP support built-in!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif } else { conn->curl_do = Curl_ftp; @@ -1841,8 +1872,16 @@ static CURLcode CreateConnection(struct SessionHandle *data, break; } } + +/* MN 06/07/02 */ +#else /* CURL_DISABLE_FTP */ + failf(data, LIBCURL_NAME + " was built with FTP disabled, ftp/ftps: not supported!"); + return CURLE_UNSUPPORTED_PROTOCOL; +#endif } else if(strequal(conn->protostr, "TELNET")) { +#ifndef CURL_DISABLE_TELNET /* telnet testing factory */ conn->protocol |= PROT_TELNET; @@ -1851,24 +1890,39 @@ static CURLcode CreateConnection(struct SessionHandle *data, conn->remote_port = PORT_TELNET; conn->curl_do = Curl_telnet; conn->curl_done = Curl_telnet_done; +#else + failf(data, LIBCURL_NAME + " was built with TELNET disabled!"); +#endif } else if (strequal(conn->protostr, "DICT")) { +#ifndef CURL_DISABLE_DICT conn->protocol |= PROT_DICT; conn->port = (data->set.use_port && data->state.allow_port)? data->set.use_port:PORT_DICT; conn->remote_port = PORT_DICT; conn->curl_do = Curl_dict; conn->curl_done = NULL; /* no DICT-specific done */ +#else + failf(data, LIBCURL_NAME + " was built with DICT disabled!"); +#endif } else if (strequal(conn->protostr, "LDAP")) { +#ifndef CURL_DISABLE_LDAP conn->protocol |= PROT_LDAP; conn->port = (data->set.use_port && data->state.allow_port)? data->set.use_port:PORT_LDAP; conn->remote_port = PORT_LDAP; conn->curl_do = Curl_ldap; conn->curl_done = NULL; /* no LDAP-specific done */ +#else + failf(data, LIBCURL_NAME + " was built with LDAP disabled!"); +#endif } else if (strequal(conn->protostr, "FILE")) { +#ifndef CURL_DISABLE_FILE conn->protocol |= PROT_FILE; conn->curl_do = Curl_file; @@ -1885,6 +1939,10 @@ static CURLcode CreateConnection(struct SessionHandle *data, } return result; +#else + failf(data, LIBCURL_NAME + " was built with FILE disabled!"); +#endif } else { /* We fell through all checks and thus we don't support the specified @@ -2203,6 +2261,16 @@ static CURLcode CreateConnection(struct SessionHandle *data, #ifdef HAVE_SIGACTION struct sigaction sigact; + sigaction(SIGINT, NULL, &sigact); + keep_sigact = sigact; + sigact.sa_handler = sigintfunc; +#ifdef SA_RESTART + /* HPUX doesn't have SA_RESTART but defaults to that behaviour! */ + sigact.sa_flags &= ~SA_RESTART; +#endif + /* now set the new struct */ + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGALRM, NULL, &sigact); keep_sigact = sigact; keep_copysig = TRUE; /* yes, we have a copy */ |