# 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 */
/* Include these, so random files need not include them. */
#include "sysdep.h"
-#include "options.h"
/* 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
+
+/* Execute the following statement if debugging is both enabled at
+ compile-time and requested at run-time; a no-op otherwise. */
-/* 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)
-#else /* not ENABLE_DEBUG */
-# define DEBUGP(x) DO_NOTHING
-#endif /* not ENABLE_DEBUG */
+# define IF_DEBUG if (UNLIKELY (opt.debug))
+#else
+# define IF_DEBUG if (0)
+#endif
+
+/* Print ARGS if debugging is enabled and requested, otherwise do
+ nothing. This must be called with an extra level of parentheses
+ because it's not possible to pass a variable number of arguments to
+ a macro (in portable C89). ARGS are like arguments to printf. */
+
+#define DEBUGP(args) do { IF_DEBUG { debug_logprintf args; } } 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
+ 32-bit on Windows. */
+
+#ifndef WINDOWS
+typedef off_t wgint;
+# define SIZEOF_WGINT SIZEOF_OFF_T
+#endif
+
+/* Define a strtol/strtoll clone that works with wgint. */
+#ifndef str_to_wgint /* mswindows.h defines its own alias */
+# if SIZEOF_WGINT == SIZEOF_LONG
+# define str_to_wgint strtol
+# define WGINT_MAX LONG_MAX
+# else
+# define str_to_wgint strtoll
+# define WGINT_MAX LLONG_MAX
+# endif
+#endif
+
+/* Now define a large integral type useful for storing sizes of *sums*
+ of downloads, such as the value of the --quota option. This should
+ be a type able to hold 2G+ values even on systems without large
+ file support. (It is useful to limit Wget's download quota to say
+ 10G even if a single file cannot be that large.)
+
+ To make sure we get the largest size possible, we use `double' on
+ systems without a 64-bit integral type. (Since it is used in very
+ few places in Wget, this is acceptable.) */
+
+#if SIZEOF_WGINT >= 8
+/* just use wgint, which we already know how to print */
+typedef wgint SUM_SIZE_INT;
+# define with_thousand_seps_sum with_thousand_seps
+#else
+/* On systems without LFS, use double, which buys us integers up to 2^53. */
+typedef double SUM_SIZE_INT;
+#endif
+
+#include "options.h"
/* Everything uses this, so include them here directly. */
#include "xmalloc.h"
(sizevar) = DR_newsize; \
} \
if (DR_newsize) \
- basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type)); \
+ basevar = 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) (int) (2 * sizeof (void *)), (unsigned long) (p)
+
extern const char *exec_name;
\f
/* Document type ("dt") flags */
{
NOCONERROR, HOSTERR, CONSOCKERR, CONERROR, CONSSLERR,
CONIMPOSSIBLE, NEWLOCATION, NOTENOUGHMEM, CONPORTERR,
- BINDERR, BINDOK, LISTENERR, ACCEPTERR, ACCEPTOK,
- CONCLOSED, FTPOK, FTPLOGINC, FTPLOGREFUSED, FTPPORTERR,
+ CONCLOSED, FTPOK, FTPLOGINC, FTPLOGREFUSED, FTPPORTERR, FTPSYSERR,
FTPNSFOD, FTPRETROK, FTPUNKNOWNTYPE, FTPRERR,
FTPREXC, FTPSRVERR, FTPRETRINT, FTPRESTFAIL, URLERROR,
- FOPENERR, FWRITEERR, HOK, HLEXC, HEOF,
+ FOPENERR, FOPEN_EXCL_ERR, FWRITEERR, HOK, HLEXC, HEOF,
HERR, RETROK, RECLEVELEXC, FTPACCDENIED, WRONGCODE,
FTPINVPASV, FTPNOPASV,
CONTNOTSUPPORTED, RETRUNNEEDED, RETRFINISHED, READERR, TRYLIMEXC,
URLBADPATTERN, FILEBADFILE, RANGEERR, RETRBADPATTERN,
RETNOTSUP, ROBOTSOK, NOROBOTS, PROXERR, AUTHFAILED,
- QUOTEXC, WRITEFAILED,
- SSLERRCERTFILE,SSLERRCERTKEY,SSLERRCTXCREATE
+ QUOTEXC, WRITEFAILED, SSLINITFAILED
} uerr_t;
-/* In case old systems don't have EAFNOSUPPORT, which we use below. */
-#ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT EINVAL
-#endif
-
-#define CONNECT_ERROR(err) (( (err) == EAFNOSUPPORT \
- || (err) == EINVAL \
- || ((err) == ECONNREFUSED \
- && !opt.retry_connrefused)) \
- ? CONIMPOSSIBLE : CONERROR)
-
#endif /* WGET_H */