]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/base64.c
Fix header file includes.
[bacula/bacula] / bacula / src / lib / base64.c
index 08b95d485194dd35d49b4f7afe0e1e16035a7611..19e83ce49d7820517cc72b0c0290f316d5e7ba06 100644 (file)
 
 #include "bacula.h"
 
+/*
+ * If compatible is true, the bin_to_base64 routine will be compatible
+ * with what the rest of the world uses.  However, this would destroy
+ * existing database compatibility.
+ */
 const bool compatible = false;
 
 #ifdef TEST_MODE
@@ -144,23 +149,27 @@ bin_to_base64(char *buf, char *bin, int len)
       if (rem < 6) {
          reg <<= 8;
          if (compatible) {
-            reg |= (int8_t)bin[i++] & 0xFF;
+            reg |= (uint8_t)bin[i++];
          } else {
-           reg |= (int8_t)bin[i++];
+            reg |= (int8_t)bin[i++];
          }
          rem += 8;
       }
       save = reg;
       reg >>= (rem - 6);
-      buf[j++] = base64_digits[reg & (uint32_t)0x3F];
+      buf[j++] = base64_digits[reg & 0x3F];
       reg = save;
       rem -= 6;
    }
    if (rem) {
+#ifdef OLDxxxx
       mask = 1;
       for (i=1; i<rem; i++) {
          mask = (mask << 1) | 1;
       }
+#else 
+      mask = (1 << rem) - 1;
+#endif
       if (compatible) {
          buf[j++] = base64_digits[(reg & mask) << 6 - rem];
       } else {