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_NT40_ENV)
17 main() { printf("b32 not required for this operating system.\n"); exit(1); }
20 #include "../afsutil.h"
25 printf("Usage: %s -s n [n ...] (converts int to base 32 string)\n", prog);
26 printf("Usage: %s -i s [s ...] (converts base 32 string to int)\n", prog);
27 printf("Usage: %s -c n [n ...] (converts to base 32 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)
63 printf("%d\n", base32_to_int(av[2]));
66 printf("%s: %d\n", av[i], base32_to_int(av[i]));
70 void itob(int ac, char **av)
76 printf("%s\n", int_to_base32(str, atoi(av[2])));
79 printf("%d: %s\n", atoi(av[i]), int_to_base32(str, atoi(av[i])));
83 void check(int ac, char **av)
89 printf("%10s %10s %10s\n", "input", "base32", "output");
90 for (i=2; i<ac; i++) {
92 (void) int_to_base32(str, in);
93 out = base32_to_int(str);
94 printf("%10d %10s %10d\n", in, str, out);
98 #define PROGRESS 1000000
99 void verifyRange(int ac, char **av)
101 unsigned int inc, low, high;
103 unsigned int in, out;
106 if (ac != 5) Usage();
108 low = (unsigned int)atoi(av[2]);
109 high = (unsigned int)atoi(av[3]);
110 inc = (unsigned int)atoi(av[4]);
113 for (in=low; in <= high; in += inc) {
115 if (n % PROGRESS == 0)
117 (void) int_to_base32(str, in);
118 out = base32_to_int(str);
120 printf("\n\nERROR: in=%u, str='%s', out=%u\n", in, str, out);
124 printf("\nCOMPLETE - no errors found in range %u,%u,%u\n",