[svn] Define the IF_DEBUG macro.

This commit is contained in:
hniksic 2005-06-21 18:26:22 -07:00
parent 6895126a68
commit 976cc5bfca
7 changed files with 28 additions and 22 deletions

View File

@ -1,3 +1,13 @@
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
* openssl.c, connect.c, host.c: Replace instances of #ifdef
ENABLE_DEBUG if (opt.debug) {...} #endif with IF_DEBUG {...}.
* main.c: Rename the IF_DEBUG defined here to WHEN_DEBUG.
* wget.h (IF_DEBUG): New macro.
(DEBUGP): Define in terms of IF_DEBUG.
2005-06-22 Hrvoje Niksic <hniksic@xemacs.org>
* http.c (gethttp): Only handle --set-cookies (and assert that

View File

@ -278,10 +278,9 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
int on = 1;
/* In case of error, we will go on anyway... */
int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on));
#ifdef ENABLE_DEBUG
if (err < 0)
DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno)));
#endif
IF_DEBUG
if (err < 0)
DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno)));
}
#endif

View File

@ -258,8 +258,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
hash_table_put (jar->chains, chain_key, cookie);
++jar->cookie_count;
#ifdef ENABLE_DEBUG
if (opt.debug)
IF_DEBUG
{
time_t exptime = cookie->expiry_time;
DEBUGP (("\nStored cookie %s %d%s %s <%s> <%s> [expiry %s] %s %s\n",
@ -271,7 +270,6 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
cookie->expiry_time ? datetime_str (&exptime) : "none",
cookie->attr, cookie->value));
}
#endif
}
/* Discard a cookie matching COOKIE's domain, port, path, and

View File

@ -622,8 +622,7 @@ cache_store (const char *host, struct address_list *al)
++al->refcount;
hash_table_put (host_name_addresses_map, xstrdup_lower (host), al);
#ifdef ENABLE_DEBUG
if (opt.debug)
IF_DEBUG
{
int i;
debug_logprintf ("Caching %s =>", host);
@ -631,7 +630,6 @@ cache_store (const char *host, struct address_list *al)
debug_logprintf (" %s", pretty_print_address (al->addresses + i));
debug_logprintf ("\n");
}
#endif
}
/* Remove HOST from the DNS cache. Does nothing is HOST is not in

View File

@ -112,9 +112,9 @@ static void print_version (void);
#endif
#ifdef ENABLE_DEBUG
# define IF_DEBUG(x) x
# define WHEN_DEBUG(x) x
#else
# define IF_DEBUG(x) NULL
# define WHEN_DEBUG(x) NULL
#endif
struct cmdline_option {
@ -158,7 +158,7 @@ struct cmdline_option option_data[] =
{ "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
{ "cookies", 0, OPT_BOOLEAN, "cookies", -1 },
{ "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 },
{ IF_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
{ WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
{ "delete-after", 0, OPT_BOOLEAN, "deleteafter", -1 },
{ "directories", 0, OPT_BOOLEAN, "dirstruct", -1 },
{ "directory-prefix", 'P', OPT_VALUE, "dirprefix", -1 },
@ -254,7 +254,7 @@ struct cmdline_option option_data[] =
{ "waitretry", 0, OPT_VALUE, "waitretry", -1 },
};
#undef IF_DEBUG
#undef WHEN_DEBUG
#undef IF_SSL
/* Return a string that contains S with "no-" prepended. The string

View File

@ -422,8 +422,7 @@ ssl_check_certificate (int fd, const char *host)
goto no_cert; /* must bail out since CERT is NULL */
}
#ifdef ENABLE_DEBUG
if (opt.debug)
IF_DEBUG
{
char *subject = X509_NAME_oneline (X509_get_subject_name (cert), 0, 0);
char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0);
@ -432,7 +431,6 @@ ssl_check_certificate (int fd, const char *host)
OPENSSL_free (subject);
OPENSSL_free (issuer);
}
#endif
vresult = SSL_get_verify_result (ssl);
if (vresult != X509_V_OK)

View File

@ -98,13 +98,16 @@ so, delete this exception statement from your version. */
# define UNLIKELY(exp) (exp)
#endif
/* Print X if debugging is enabled; a no-op otherwise. */
/* Execute the following statement if debugging is both enabled at
compile-time and requested at run-time; a no-op otherwise. */
#ifdef ENABLE_DEBUG
# define DEBUGP(x) do if (UNLIKELY (opt.debug)) {debug_logprintf x;} while (0)
#else /* not ENABLE_DEBUG */
# define DEBUGP(x) do {} while (0)
#endif /* not ENABLE_DEBUG */
# define IF_DEBUG if (UNLIKELY (opt.debug))
#else
# define IF_DEBUG if (0)
#endif
#define DEBUGP(x) do { IF_DEBUG { debug_logprintf x; } } while (0)
/* Define an integer type that works for file sizes, content lengths,
and such. Normally we could just use off_t, but off_t is always