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>
15 #ifdef AFS_SGI_XFS_IOPS_ENV
17 static char c_xlate
[80] =
18 "+,0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
21 * Create a base 64 string representation of a number.
22 * The supplied string 's' must be at least 8 bytes long.
23 * b64_string in stds.h provides a tyepdef to get the length.
26 int_to_base64(b64_string_t s
, int a
)
42 for (; j
>= 0; j
-= 6) {
45 break; /* found highest bits set. */
47 s
[i
++] = c_xlate
[n
>> j
];
52 for (; j
>= 0; j
-= 6) {
54 s
[i
++] = c_xlate
[n
>> j
];
62 /* Mapping: +=0, ,=1, 0-9 = 2-11, A-Z = 12-37, a-z = 38-63 */
64 base64_to_int(char *s
)
73 } else if (*s
<= '9') {
74 n
= 2 + (int)(*s
- '0');
75 } else if (*s
<= 'Z') {
76 n
= 12 + (int)(*s
- 'A');
78 n
= 38 + (int)(*s
- 'a');
80 result
= (result
<< 6) + n
;
86 #endif /* AFS_SGI_XFS_IOPS_ENV */