]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - lib/uudecode.c
SourceFormat Enforcement
[thirdparty/squid.git] / lib / uudecode.c
index dab0a5babf3e186a56e03f9f29529f19cb5826d7..cf63ce8d2a14359a999ee91b5cb1064065823148 100644 (file)
@@ -1,11 +1,16 @@
-#include "config.h"
-#include "util.h"
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
 
-extern char **environ;
+#include "squid.h"
+#include "uudecode.h"
 
 /* aaaack but it's fast and const should make it shared text page. */
-const int pr2six[256] =
-{
+const int pr2six[256] = {
     64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
     64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
     52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
@@ -31,14 +36,14 @@ uudecode(const char *bufcoded)
     /* Strip leading whitespace. */
 
     while (*bufcoded == ' ' || *bufcoded == '\t')
-       bufcoded++;
+        bufcoded++;
 
     /* Figure out how many characters are in the input buffer.
      * Allocate this many from the per-transaction pool for the result.
      */
     bufin = (const unsigned char *) bufcoded;
     while (pr2six[*(bufin++)] <= 63);
-    nprbytes = (char *) bufin - bufcoded - 1;
+    nprbytes = (const char *) bufin - bufcoded - 1;
     nbytesdecoded = ((nprbytes + 3) / 4) * 3;
 
     bufplain = xmalloc(nbytesdecoded + 1);
@@ -46,22 +51,23 @@ uudecode(const char *bufcoded)
     bufin = (const unsigned char *) bufcoded;
 
     while (nprbytes > 0) {
-       *(bufout++) =
-           (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
-       *(bufout++) =
-           (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
-       *(bufout++) =
-           (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
-       bufin += 4;
-       nprbytes -= 4;
+        *(bufout++) =
+            (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
+        *(bufout++) =
+            (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
+        *(bufout++) =
+            (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
+        bufin += 4;
+        nprbytes -= 4;
     }
 
     if (nprbytes & 03) {
-       if (pr2six[bufin[-2]] > 63)
-           nbytesdecoded -= 2;
-       else
-           nbytesdecoded -= 1;
+        if (pr2six[bufin[-2]] > 63)
+            nbytesdecoded -= 2;
+        else
+            nbytesdecoded -= 1;
     }
     bufplain[nbytesdecoded] = '\0';
     return bufplain;
 }
+