]> sjero.net Git - wget/blobdiff - src/wget.h
[svn] Remove K&R support.
[wget] / src / wget.h
index aa133ccd540fc12dad60cba5536302922daca829..759825e7f46e362fff89c090512c75ea0875e097 100644 (file)
@@ -40,21 +40,15 @@ so, delete this exception statement from your version.  */
 # define NDEBUG
 #endif
 
-#ifndef PARAMS
-# if PROTOTYPES
-#  define PARAMS(args) args
-# else
-#  define PARAMS(args) ()
-# endif
-#endif
-
 /* `gettext (FOO)' is long to write, so we use `_(FOO)'.  If NLS is
    unavailable, _(STRING) simply returns STRING.  */
 #ifdef HAVE_NLS
 # define _(string) gettext (string)
 # ifdef HAVE_LIBINTL_H
 #  include <libintl.h>
-# endif /* HAVE_LIBINTL_H */
+# else  /* not HAVE_LIBINTL_H */
+   const char *gettext ();
+# endif /* not HAVE_LIBINTL_H */
 #else  /* not HAVE_NLS */
 # define _(string) (string)
 #endif /* not HAVE_NLS */
@@ -91,23 +85,31 @@ so, delete this exception statement from your version.  */
 /* locale independent replacement for ctype.h */
 #include "safe-ctype.h"
 
-#define DO_NOTHING do {} while (0)
+/* Conditionalize the use of GCC's __attribute__((format)) and
+   __builtin_expect features using macros.  */
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+# define GCC_FORMAT_ATTR(a, b) __attribute__ ((format (printf, a, b)))
+# define LIKELY(exp)   __builtin_expect (!!(exp), 1)
+# define UNLIKELY(exp) __builtin_expect ((exp), 0)
+#else
+# define GCC_FORMAT_ATTR(a, b)
+# define LIKELY(exp)   (exp)
+# define UNLIKELY(exp) (exp)
+#endif
 
 /* Print X if debugging is enabled; a no-op otherwise.  */
+
 #ifdef ENABLE_DEBUG
-# define DEBUGP(x) do { if (opt.debug) { debug_logprintf x; } } while (0)
+# define DEBUGP(x) do if (UNLIKELY (opt.debug)) {debug_logprintf x;} while (0)
 #else  /* not ENABLE_DEBUG */
-# define DEBUGP(x) DO_NOTHING
+# define DEBUGP(x) do {} while (0)
 #endif /* not ENABLE_DEBUG */
 
-#ifdef __GNUC__
-# define GCC_FORMAT_ATTR(a, b) __attribute__ ((format (printf, a, b)))
-#else  /* not __GNUC__ */
-# define GCC_FORMAT_ATTR(a, b)
-#endif /* not __GNUC__ */
+/* 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
+   32-bit on Windows.  */
 
-/* Define an integer type that works for LFS.  off_t would be perfect
-   for this, but off_t is always 32-bit under Windows.  */
 #ifndef WINDOWS
 typedef off_t wgint;
 # define SIZEOF_WGINT SIZEOF_OFF_T
@@ -214,6 +216,12 @@ typedef off_t wgint;
     basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type));  \
 } while (0)
 
+/* Used to print pointers (usually for debugging).  Print pointers
+   using printf ("%0*lx", PTR_FORMAT (p)).  (%p is too unpredictable;
+   some implementations prepend 0x, while some don't, and most don't
+   0-pad the address.)  */
+#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p)
+
 extern const char *exec_name;
 \f
 /* Document type ("dt") flags */
@@ -244,8 +252,7 @@ typedef enum
   CONTNOTSUPPORTED, RETRUNNEEDED, RETRFINISHED, READERR, TRYLIMEXC,
   URLBADPATTERN, FILEBADFILE, RANGEERR, RETRBADPATTERN,
   RETNOTSUP, ROBOTSOK, NOROBOTS, PROXERR, AUTHFAILED,
-  QUOTEXC, WRITEFAILED,
-  SSLERRCERTFILE,SSLERRCERTKEY,SSLERRCTXCREATE
+  QUOTEXC, WRITEFAILED, SSLINITFAILED
 } uerr_t;
 
 #endif /* WGET_H */