diff --git a/lib/arpa_telnet.h b/lib/arpa_telnet.h index 063bc6fc1aaa5eb08b68ba8ab9ce95104f85879e..caf6c7f03d21e7105ca6db29ca071d352b94483e 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 2a90d0b8b68dbfdae1eb8db515085c3ce3def710..e7628a9b324c7844fd146495bbc1de7ec1b2fc8f 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 #include #include @@ -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 ca76d36c14674f6d2796ac20c4440ae5bb03a0e0..cee36e073f44ab1f938b091df73823497a39fc24 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 4515d9d94c8d18da2aee1bd4ff70e3de20284c94..b3ab757fdcd85d7379c63613e2f37856dd4bc5c3 100644 --- a/lib/file.c +++ b/lib/file.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_FILE /* -- WIN32 approved -- */ #include #include @@ -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 f0dcf8ff362a11eeb1a038313f808c5b5df92c14..4a26893e8103feccdbcd5d2a312fa98378895673 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 a5d367cd504ea4426eaf0eb6ee74b85e085ce8c4..5c1575e574ba2bb0b98feae5e824ea8cdef19100 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 #include #include @@ -1505,6 +1507,8 @@ int main(int argc, char **argv) #endif +#endif /* CURL_DISABLE_HTTP */ + /* * local variables: * eval: (load-file "../curl-mode.el") diff --git a/lib/ftp.c b/lib/ftp.c index d86a344e5c2cd258abfaf1f2f6699ed5670d2398..388bba3999d8531a3aaccfa9e698cd4f18c4205d 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -23,6 +23,8 @@ #include "setup.h" +/* MN 06/07/02 */ +#ifndef CURL_DISABLE_FTP #include #include #include @@ -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 */ diff --git a/lib/ftp.h b/lib/ftp.h index 6f91da53f834aace3e3dcfe089aa9208b5d71e29..baf9f40e68cde927db93704cd958e239e0316d61 100644 --- a/lib/ftp.h +++ b/lib/ftp.h @@ -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 b135912bb58fda380f071be7f75fcc9db65932c6..763b90a3a7038a76c16d0f196a327f9981b4427a 100644 --- a/lib/http.c +++ b/lib/http.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_HTTP /* -- WIN32 approved -- */ #include #include @@ -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 ef5bedebbe4ccebfcc289d6f05ba5aa9bfcd1f15..2650106cc52202b0f29fbe5e5e120cbef966ef94 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 a49e405e752966e0ec23e0abf76809106130e6cc..939e86a91a5f72a940fc919c09ac8918fd446a67 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 #include @@ -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 10b386fbeae5ab92ef6961bd759745defe8eb483..b5963831092decf89f8060161ffdafa80a0b7ddf 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 910907f589837a0f5dceaf9347e1495a705fc735..331ba1622aa193712f706f443c45400da445e783 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_LDAP /* -- WIN32 approved -- */ #include #include @@ -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 9bc48755104e9f9fb1e8224ff1d61be425a27f9f..084fd1024b19c02bc7ac1d599477f058241cd91d 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 1be54c8b8de06a27ca8d39d3b23ee78f5b948ce2..06dec3258c97a1bfb80f08c8f1baa4c299c07d81 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 fef994297916557458a9333dc7a717f67be76828..2bd0588e8906b3a023a62ce7c05cd3f23f0c6941 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 5b6423fb7871c80f8fd3dfa55a94ad4f7bd86fa2..e658a5e2d43a1ad244366ec4d576e9c49578c73f 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -23,6 +23,7 @@ #include "setup.h" +#ifndef CURL_DISABLE_TELNET /* -- WIN32 approved -- */ #include #include @@ -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 c566b4a562219d7eb9aadc3c202780223a5d32d6..41ec79df1305fa817489a5cd7426cd52bf8d270e 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 diff --git a/lib/url.c b/lib/url.c index d008ba459f04029192928a151544cc48a9113858..dd55d861d33f061a8f2439e67fcadbddba918eff 100644 --- a/lib/url.c +++ b/lib/url.c @@ -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 */