]> sjero.net Git - wget/blobdiff - src/utils.c
[svn] Added sanity checks for -k, -p, -r and -N when -O is given. Added fixes for...
[wget] / src / utils.c
index 8900b5b32561d2873121f6ab748a7361962a865e..6419009eb92b58b6df1372229cebc873d89b8ff4 100644 (file)
@@ -1,5 +1,5 @@
 /* Various utility functions.
-   Copyright (C) 1996-2005 Free Software Foundation, Inc.
+   Copyright (C) 1996-2006 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -1903,15 +1903,13 @@ base64_encode (const void *data, int length, char *dest)
 {
   /* Conversion table.  */
   static const char tbl[64] = {
-    'A','B','C','D','E','F','G','H',
-    'I','J','K','L','M','N','O','P',
-    'Q','R','S','T','U','V','W','X',
-    'Y','Z','a','b','c','d','e','f',
-    'g','h','i','j','k','l','m','n',
-    'o','p','q','r','s','t','u','v',
-    'w','x','y','z','0','1','2','3',
-    '4','5','6','7','8','9','+','/'
+    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
+    'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
+    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
+    'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
   };
+  /* Access bytes in DATA as unsigned char, otherwise the shifts below
+     don't work for data with MSB set. */
   const unsigned char *s = data;
   /* Theoretical ANSI violation when length < 3. */
   const unsigned char *end = (const unsigned char *) data + length - 2;
@@ -1956,14 +1954,17 @@ base64_encode (const void *data, int length, char *dest)
 
 #define IS_ASCII(c) (((c) & 0x80) == 0)
 
-/* Decode data from BASE64 (pointer to \0-terminated text) into memory
-   pointed to by DEST.  DEST should be large enough to accomodate the
-   decoded data, which is guaranteed to be less than strlen(base64).
+/* Decode data from BASE64 (a null-terminated string) into memory
+   pointed to by DEST.  DEST is assumed to be large enough to
+   accomodate the decoded data, which is guaranteed to be no more than
+   3/4*strlen(base64).
 
    Since DEST is assumed to contain binary data, it is not
    NUL-terminated.  The function returns the length of the data
    written to TO.  -1 is returned in case of error caused by malformed
-   base64 input.  */
+   base64 input.
+
+   This function originates from Free Recode.  */
 
 int
 base64_decode (const char *base64, void *dest)