From 710e370c34497100873dcf6252c862d77ef8c25b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Nov 2004 16:34:24 +0000 Subject: Dan Fandrich added --disable-verbose --- CHANGES | 4 ++++ configure.ac | 42 ++++++++++++++++++++++++++++++++---------- lib/krb4.c | 6 +++--- lib/sendf.h | 10 ++++++++++ lib/strerror.c | 35 +++++++++++++++++++++++++++++++++++ lib/telnet.c | 58 +++++++++++++++++++++++++++++----------------------------- 6 files changed, 113 insertions(+), 42 deletions(-) diff --git a/CHANGES b/CHANGES index 890f64b9e..16648d3aa 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,10 @@ Changelog Daniel (11 November 2004) +- Dan Fandrich added --disable-verbose to the configure script to allow builds + without verbose strings in the code, to save some 12KB space. Makes sense + only for systems with very little memory resources. + - Jeff Phillips found out that a date string with a year beyond 2038 could crash the new date parser on systems with 32bit time_t. We now check for this case and deal with it. diff --git a/configure.ac b/configure.ac index 473e4341d..e9f206c03 100644 --- a/configure.ac +++ b/configure.ac @@ -55,16 +55,17 @@ AC_SUBST(PKGADD_NAME) AC_SUBST(PKGADD_VENDOR) dnl -dnl initialize all the info variables to 'no' - curl_ssl_msg="no (--with-ssl)" - curl_zlib_msg="no (--with-zlib)" - curl_krb4_msg="no (--with-krb4*)" - curl_gss_msg="no (--with-gssapi)" - curl_spnego_msg="no (--with-spnego)" - curl_ares_msg="no (--enable-ares)" - curl_ipv6_msg="no (--enable-ipv6)" - curl_idn_msg="no (--with-libidn)" - curl_manual_msg="no (--enable-manual)" +dnl initialize all the info variables + curl_ssl_msg="no (--with-ssl)" + curl_zlib_msg="no (--with-zlib)" + curl_krb4_msg="no (--with-krb4*)" + curl_gss_msg="no (--with-gssapi)" + curl_spnego_msg="no (--with-spnego)" + curl_ares_msg="no (--enable-ares)" + curl_ipv6_msg="no (--enable-ipv6)" + curl_idn_msg="no (--with-libidn)" + curl_manual_msg="no (--enable-manual)" +curl_verbose_msg="enabled (--disable-verbose)" dnl dnl Detect the canonical host and target build environment @@ -1426,6 +1427,26 @@ int main(void) AC_MSG_RESULT(no) ) +dnl ************************************************************ +dnl disable verbose text strings +dnl +AC_MSG_CHECKING([whether to enable verbose strings]) +AC_ARG_ENABLE(verbose, +AC_HELP_STRING([--enable-verbose],[Enable verbose strings]) +AC_HELP_STRING([--disable-verbose],[Disable verbose strings]), +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings]) + AC_SUBST(CURL_DISABLE_VERBOSE_STRINGS) + curl_verbose_msg="no" + ;; + *) AC_MSG_RESULT(yes) + ;; + esac ], + AC_MSG_RESULT(yes) +) + dnl ************************************************************ dnl lame option to switch on debug options dnl @@ -1497,4 +1518,5 @@ AC_MSG_NOTICE([Configured to build curl/libcurl: IDN support: ${curl_idn_msg} Build libcurl: Shared=${enable_shared}, Static=${enable_static} Built-in manual: ${curl_manual_msg} + Verbose errors: ${curl_verbose_msg} ]) diff --git a/lib/krb4.c b/lib/krb4.c index 904ca774f..37da95df3 100644 --- a/lib/krb4.c +++ b/lib/krb4.c @@ -220,7 +220,7 @@ krb4_auth(void *app_data, struct connectdata *conn) if(ret == KDC_PR_UNKNOWN) ret = mk_auth(d, &adat, "rcmd", host, checksum); if(ret) { - Curl_infof(data, "%s\n", krb_get_err_text(ret)); + infof(data, "%s\n", krb_get_err_text(ret)); return AUTH_CONTINUE; } @@ -232,7 +232,7 @@ krb4_auth(void *app_data, struct connectdata *conn) if (krb_get_our_ip_for_realm(krb_realmofhost(host), &natAddr) != KSUCCESS && krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS) - Curl_infof(data, "Can't get address for realm %s\n", + infof(data, "Can't get address for realm %s\n", krb_realmofhost(host)); else { if (natAddr.s_addr != localaddr->sin_addr.s_addr) { @@ -242,7 +242,7 @@ krb4_auth(void *app_data, struct connectdata *conn) #else char *ip = (char *)inet_ntoa(natAddr); #endif - Curl_infof(data, "Using NAT IP address (%s) for kerberos 4\n", ip); + infof(data, "Using NAT IP address (%s) for kerberos 4\n", ip); localaddr->sin_addr = natAddr; } } diff --git a/lib/sendf.h b/lib/sendf.h index 155c1193f..1d7b3522d 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -28,7 +28,17 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *, void Curl_infof(struct SessionHandle *, const char *fmt, ...); void Curl_failf(struct SessionHandle *, const char *fmt, ...); +#if defined(CURL_DISABLE_VERBOSE_STRINGS) +#if defined(__GNUC__) +/* Variable argument macros is a C99 feature long supported by gcc */ +#define infof(...) /*ignore*/ +#else +/* Cast the args to void to make them a noop, side effects notwithstanding */ +#define infof (void) +#endif +#else #define infof Curl_infof +#endif #define failf Curl_failf #define CLIENTWRITE_BODY 1 diff --git a/lib/strerror.c b/lib/strerror.c index fa84a1731..d8e085880 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -48,6 +48,7 @@ extern char *strerror_r(int errnum, char *buf, size_t buflen); const char * curl_easy_strerror(CURLcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLE_OK: return "no error"; @@ -252,11 +253,18 @@ curl_easy_strerror(CURLcode error) * is why it is here, and not at the start of the switch. */ return "unknown error"; +#else + if (error == CURLE_OK) + return "no error"; + else + return "error"; +#endif } const char * curl_multi_strerror(CURLMcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLM_CALL_MULTI_PERFORM: return "please call curl_multi_perform() soon"; @@ -281,11 +289,18 @@ curl_multi_strerror(CURLMcode error) } return "unknown error"; +#else + if (error == CURLM_OK) + return "no error"; + else + return "error"; +#endif } const char * curl_share_strerror(CURLSHcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLSHE_OK: return "no error"; @@ -307,6 +322,12 @@ curl_share_strerror(CURLSHcode error) } return "CURLSH unknown"; +#else + if (error == CURLSHE_OK) + return "no error"; + else + return "error"; +#endif } #if defined(WIN32) && !defined(__CYGWIN__) @@ -318,6 +339,7 @@ get_winsock_error (int err, char *buf, size_t len) { char *p; +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (err) { case WSAEINTR: p = "Call interrupted."; @@ -485,6 +507,12 @@ get_winsock_error (int err, char *buf, size_t len) default: return NULL; } +#else + if (error == CURLE_OK) + return NULL; + else + p = "error"; +#endif strncpy (buf, p, len); buf [len-1] = '\0'; return buf; @@ -594,6 +622,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch ((Idna_rc)err) { case IDNA_SUCCESS: str = "No error"; @@ -636,6 +665,12 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) str = NULL; break; } +#else + if ((Idna_rc)err == IDNA_SUCCESS) + str = "No error"; + else + str = "error"; +#endif if (str) strncpy(buf, str, max); buf[max] = '\0'; diff --git a/lib/telnet.c b/lib/telnet.c index c2813fa2a..a2208f67a 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -262,9 +262,9 @@ static void printoption(struct SessionHandle *data, if (cmd == CURL_IAC) { if (CURL_TELCMD_OK(option)) - Curl_infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option)); + infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option)); else - Curl_infof(data, "%s IAC %d\n", direction, option); + infof(data, "%s IAC %d\n", direction, option); } else { @@ -280,12 +280,12 @@ static void printoption(struct SessionHandle *data, opt = NULL; if(opt) - Curl_infof(data, "%s %s %s\n", direction, fmt, opt); + infof(data, "%s %s %s\n", direction, fmt, opt); else - Curl_infof(data, "%s %s %d\n", direction, fmt, option); + infof(data, "%s %s %d\n", direction, fmt, option); } else - Curl_infof(data, "%s %d %d\n", direction, cmd, option); + infof(data, "%s %d %d\n", direction, cmd, option); } } } @@ -675,7 +675,7 @@ static void printsub(struct SessionHandle *data, { if (direction) { - Curl_infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT"); + infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT"); if (length >= 3) { int j; @@ -685,27 +685,27 @@ static void printsub(struct SessionHandle *data, if (i != CURL_IAC || j != CURL_SE) { - Curl_infof(data, "(terminated by "); + infof(data, "(terminated by "); if (CURL_TELOPT_OK(i)) - Curl_infof(data, "%s ", CURL_TELOPT(i)); + infof(data, "%s ", CURL_TELOPT(i)); else if (CURL_TELCMD_OK(i)) - Curl_infof(data, "%s ", CURL_TELCMD(i)); + infof(data, "%s ", CURL_TELCMD(i)); else - Curl_infof(data, "%d ", i); + infof(data, "%d ", i); if (CURL_TELOPT_OK(j)) - Curl_infof(data, "%s", CURL_TELOPT(j)); + infof(data, "%s", CURL_TELOPT(j)); else if (CURL_TELCMD_OK(j)) - Curl_infof(data, "%s", CURL_TELCMD(j)); + infof(data, "%s", CURL_TELCMD(j)); else - Curl_infof(data, "%d", j); - Curl_infof(data, ", not IAC SE!) "); + infof(data, "%d", j); + infof(data, ", not IAC SE!) "); } } length -= 2; } if (length < 1) { - Curl_infof(data, "(Empty suboption?)"); + infof(data, "(Empty suboption?)"); return; } @@ -714,28 +714,28 @@ static void printsub(struct SessionHandle *data, case CURL_TELOPT_TTYPE: case CURL_TELOPT_XDISPLOC: case CURL_TELOPT_NEW_ENVIRON: - Curl_infof(data, "%s", CURL_TELOPT(pointer[0])); + infof(data, "%s", CURL_TELOPT(pointer[0])); break; default: - Curl_infof(data, "%s (unsupported)", CURL_TELOPT(pointer[0])); + infof(data, "%s (unsupported)", CURL_TELOPT(pointer[0])); break; } } else - Curl_infof(data, "%d (unknown)", pointer[i]); + infof(data, "%d (unknown)", pointer[i]); switch(pointer[1]) { case CURL_TELQUAL_IS: - Curl_infof(data, " IS"); + infof(data, " IS"); break; case CURL_TELQUAL_SEND: - Curl_infof(data, " SEND"); + infof(data, " SEND"); break; case CURL_TELQUAL_INFO: - Curl_infof(data, " INFO/REPLY"); + infof(data, " INFO/REPLY"); break; case CURL_TELQUAL_NAME: - Curl_infof(data, " NAME"); + infof(data, " NAME"); break; } @@ -743,21 +743,21 @@ static void printsub(struct SessionHandle *data, case CURL_TELOPT_TTYPE: case CURL_TELOPT_XDISPLOC: pointer[length] = 0; - Curl_infof(data, " \"%s\"", &pointer[2]); + infof(data, " \"%s\"", &pointer[2]); break; case CURL_TELOPT_NEW_ENVIRON: if(pointer[1] == CURL_TELQUAL_IS) { - Curl_infof(data, " "); + infof(data, " "); for(i = 3;i < length;i++) { switch(pointer[i]) { case CURL_NEW_ENV_VAR: - Curl_infof(data, ", "); + infof(data, ", "); break; case CURL_NEW_ENV_VALUE: - Curl_infof(data, " = "); + infof(data, " = "); break; default: - Curl_infof(data, "%c", pointer[i]); + infof(data, "%c", pointer[i]); break; } } @@ -765,13 +765,13 @@ static void printsub(struct SessionHandle *data, break; default: for (i = 2; i < length; i++) - Curl_infof(data, " %.2x", pointer[i]); + infof(data, " %.2x", pointer[i]); break; } if (direction) { - Curl_infof(data, "\n"); + infof(data, "\n"); } } } -- cgit v1.2.3