X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fwget.h;h=f7467bb7cd9e96cbbdf1888d2b93bd77996772da;hb=8f935cf74ce95a631788fb8a4cce4114df935a78;hp=6cdfbeb0125f0dd79d468f70454c99df789c6d9a;hpb=0f99d1f2201f70ae688b1bfd8a33c503ece42cb1;p=wget diff --git a/src/wget.h b/src/wget.h index 6cdfbeb0..f7467bb7 100644 --- a/src/wget.h +++ b/src/wget.h @@ -88,19 +88,52 @@ so, delete this exception statement from your version. */ /* 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 /* 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 */ +/* 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 + +#include "options.h" + /* Everything uses this, so include them here directly. */ #include "xmalloc.h" @@ -213,25 +246,13 @@ typedef enum 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 */