]> sjero.net Git - wget/blobdiff - src/wget.h
[svn] * *.{gmo,po,pot}: Regenerated after modifying wget --help output.
[wget] / src / wget.h
index ab37507ee6a12a256989409991a0283b007dca6d..ffcee1cae97d92462783077f8c10b33708f3a228 100644 (file)
@@ -113,7 +113,7 @@ char *xstrdup PARAMS ((const char *));
 
 /* ASCII char -> HEX digit */
 #define ASC2HEXD(x) (((x) >= '0' && (x) <= '9') ?               \
-                    ((x) - '0') : (toupper(x) - 'A' + 10))
+                    ((x) - '0') : (TOUPPER(x) - 'A' + 10))
 
 /* HEX digit -> ASCII char */
 #define HEXD2ASC(x) (((x) < 10) ? ((x) + '0') : ((x) - 10 + 'A'))
@@ -160,10 +160,43 @@ char *xstrdup PARAMS ((const char *));
     XREALLOC_ARRAY (basevar, type, do_realloc_newsize);                \
 } while (0)
 
+/* Use this for small stack-allocated memory chunks that might grow.
+   The initial array is created using alloca(), and this macro
+   requests it to grow.  If the needed size is larger than the array,
+   this macro will use malloc to allocate it to new size, and copy the
+   old contents.  After that, successive invocations behave just like
+   DO_REALLOC.  */
+#define DO_REALLOC_FROM_ALLOCA(basevar, sizevar, needed_size, allocap, type) do        \
+{                                                                              \
+  /* Avoid side-effectualness.  */                             \
+  long do_realloc_needed_size = (needed_size);                 \
+  long do_realloc_newsize = 0;                                 \
+  while ((sizevar) < (do_realloc_needed_size)) {               \
+    do_realloc_newsize = 2*(sizevar);                          \
+    if (do_realloc_newsize < 16)                               \
+      do_realloc_newsize = 16;                                 \
+    (sizevar) = do_realloc_newsize;                            \
+  }                                                            \
+  if (do_realloc_newsize)                                      \
+    if (!allocap)                                              \
+      XREALLOC_ARRAY (basevar, type, do_realloc_newsize);      \
+    else                                                       \
+      {                                                                \
+       void *drfa_new_basevar = xmalloc (do_realloc_newsize);  \
+       memcpy (drfa_new_basevar, basevar, sizevar);            \
+       (basevar) = drfa_new_basevar;                           \
+       allocap = 0;                                            \
+      }                                                                \
+} while (0)
+
 /* Free FOO if it is non-NULL.  */
 #define FREE_MAYBE(foo) do { if (foo) free (foo); } while (0)
 
 /* #### Hack: OPTIONS_DEFINED_HERE is defined in main.c.  */
+/* [Is this weird hack really necessary on any compilers?  No ANSI C compiler
+    should complain about "extern const char *exec_name;" followed by
+    "const char *exec_name;".  Are we doing this for K&R compilers, or...??
+    -- Dan Harkless <dan-wget@dilvish.speed.net>] */
 #ifndef OPTIONS_DEFINED_HERE
 extern const char *exec_name;
 #endif
@@ -210,4 +243,11 @@ typedef unsigned char  boolean;
    the really awful !strcmp(a, b). */
 #define EQ 0
 
+/* For most options, 0 means no limits, but with -p in the picture, that causes
+   a problem on the maximum recursion depth variable.  To retain backwards
+   compatibility we allow users to consider "0" to be synonymous with "inf" for
+   -l, but internally infinite recursion is specified by -1 and 0 means to only
+   retrieve the requisites of a single document. */
+#define INFINITE_RECURSION -1
+
 #endif /* WGET_H */