2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #if defined(AFS_NAMEI_ENV)
17 #include <sys/types.h>
20 /* This version of base64 gets it right and starts converting from the low
21 * bits to the high bits.
23 /* This table needs to be in lexical order to efficiently map back from
24 * characters to the numerical value.
26 static char c_xlate[80] =
27 "+=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
30 * Create a base 64 string representation of a number.
31 * The supplied string 's' must be at least 12 bytes long.
32 * lb64_string in stds.h provides a typedef to get the length.
35 char *int64_to_flipbase64(lb64_string_t s, afs_int64 a)
37 char *int64_to_flipbase64(lb64_string_t s, u_int64_t a)
51 for (n = a & 0x3f; a; n = ((a>>=6) & 0x3f)) {
60 /* Mapping: +=0, ==1, 0-9 = 2-11, A-Z = 12-37, a-z = 38-63 */
62 afs_int64 flipbase64_to_int64(char *s)
64 int64_t flipbase64_to_int64(char *s)
76 for (shift = 0; *s; s++, shift += 6) {
78 else if (*s == '=') n = 1;
80 n = 2 + (int)(*s - '0');
83 n = 12 + (int)(*s - 'A');
86 n = 38 + (int)(*s - 'a');
95 #endif /* AFS_NAMEI_ENV */