+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
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
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",
cookie->expiry_time ? datetime_str (&exptime) : "none",
cookie->attr, cookie->value));
}
-#endif
}
/* Discard a cookie matching COOKIE's domain, port, path, and
++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);
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
#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 {
{ "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 },
{ "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
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);
OPENSSL_free (subject);
OPENSSL_free (issuer);
}
-#endif
vresult = SSL_get_verify_result (ssl);
if (vresult != X509_V_OK)
# 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