]> sjero.net Git - wget/blobdiff - src/wget.h
[svn] Implemented and documented new -E / --html-extension / html_extension option.
[wget] / src / wget.h
index cdc301cfced6a39e10c72a7868ab530d30a925fd..5dd71d21cde23a4ca4108a0dbd459ca63efe3cef 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,23 +160,57 @@ 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
 
 \f
-/* Document-type flags */
+/* Document type ("dt") flags */
 enum
 {
-  TEXTHTML      = 0x0001,      /* document is of type text/html */
-  RETROKF       = 0x0002,      /* retrieval was OK */
-  HEAD_ONLY     = 0x0004,      /* only send the HEAD request */
-  SEND_NOCACHE  = 0x0008,      /* send Pragma: no-cache directive */
-  ACCEPTRANGES  = 0x0010       /* Accept-ranges header was found */
+  TEXTHTML             = 0x0001,       /* document is of type text/html */
+  RETROKF              = 0x0002,       /* retrieval was OK */
+  HEAD_ONLY            = 0x0004,       /* only send the HEAD request */
+  SEND_NOCACHE         = 0x0008,       /* send Pragma: no-cache directive */
+  ACCEPTRANGES         = 0x0010,       /* Accept-ranges header was found */
+  ADDED_HTML_EXTENSION = 0x0020,        /* added ".html" extension due to -E */
 };
 
 /* Universal error type -- used almost everywhere.
@@ -198,4 +232,23 @@ typedef enum
   ROBOTSOK, NOROBOTS, PROXERR, AUTHFAILED, QUOTEXC, WRITEFAILED
 } uerr_t;
 
+typedef unsigned char  boolean;
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE  1
+#endif
+
+/* So we can say strcmp(a, b) == EQ rather than strcmp(a, b) == 0 or
+   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 */