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 main() { printf("fb64 not required for this operating system.\n"); exit(1); }
25 printf("Usage: %s -s n [n ...] (converts int to base 64 string)\n", prog);
26 printf("Usage: %s -i s [s ...] (converts base 64 string to int)\n", prog);
27 printf("Usage: %s -c n [n ...] (converts to base 64 and back)\n", prog);
28 printf("Usage: %s -r low high inc (verify converter using range and inc)\n",
33 void btoi(int ac, char **av);
34 void itob(int ac, char **av);
35 void check(int ac, char **av);
36 void verifyRange(int ac, char **av);
39 main(int ac, char **av)
44 if (!strcmp(av[1], "-s"))
46 else if (!strcmp(av[1], "-i"))
48 else if (!strcmp(av[1], "-c"))
50 else if (!strcmp(av[1], "-r"))
58 void btoi(int ac, char **av)
64 printf("%Lu\n", flipbase64_to_int64(av[2]));
68 printf("%s: %Lu\n", av[i], flipbase64_to_int64(av[i]));
72 void itob(int ac, char **av)
79 sscanf(av[2], "%Ld", &in);
80 printf("%s\n", int64_to_flipbase64(str, in));
83 for (i=2; i<ac; i++) {
84 sscanf(av[i], "%Ld", &in);
85 printf("%Ld: %s\n", in, int64_to_flipbase64(str, in));
90 void check(int ac, char **av)
96 printf("%10s %10s %10s\n", "input", "base64", "output");
97 for (i=2; i<ac; i++) {
98 sscanf(av[i], "%Ld", &in);
99 (void) int64_to_flipbase64(str, in);
100 out = flipbase64_to_int64(str);
101 printf("%10Ld %10s %10Ld\n", in, str, out);
105 #define PROGRESS 1000000
106 void verifyRange(int ac, char **av)
108 u_int64_t inc, low, high;
113 if (ac != 5) Usage();
115 sscanf(av[2], "%lu", &low);
116 sscanf(av[3], "%lu", &high);
117 sscanf(av[4], "%lu", &inc);
120 for (in=low; in <= high; in += inc) {
122 if (n % PROGRESS == 0)
124 (void) int64_to_flipbase64(str, in);
125 out = flipbase64_to_int64(str);
127 printf("\n\nERROR: in=%Lu, str='%s', out=%Lu\n", in, str, out);
131 printf("\nCOMPLETE - no errors found in range %Lu,%Lu,%Lu\n",
136 #endif /* AFS_NAMEI_ENV */