]> sjero.net Git - wget/blobdiff - src/wget.h
[svn] Update FSF's address and copyright years.
[wget] / src / wget.h
index 38c8fbdeba8afde932f3ca2431cd178a9864c2a4..bfe60c8ab58a2b6dcf97c8a1d25ad8c56566cf76 100644 (file)
@@ -1,5 +1,5 @@
 /* Miscellaneous declarations.
-   Copyright (C) 1995, 1996, 1997, 1998, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1996-2005 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -14,8 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+along with Wget; if not, write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
 In addition, as a special exception, the Free Software Foundation
 gives permission to link the code of its release of Wget with the
@@ -40,14 +40,6 @@ 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
@@ -106,13 +98,21 @@ 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
+
+/* 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
@@ -134,6 +134,24 @@ typedef off_t wgint;
 # 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 */
+typedef wgint SUM_SIZE_INT;
+#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.  */
@@ -221,14 +239,14 @@ typedef off_t wgint;
     (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) 2 * sizeof (void *), (unsigned long) (p)
+#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p)
 
 extern const char *exec_name;
 \f