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 #if !defined(AFS_NAMEI_ENV)
18 printf("fb64 not required for this operating system.\n");
30 printf("Usage: %s -s n [n ...] (converts int to base 64 string)\n", prog
);
31 printf("Usage: %s -i s [s ...] (converts base 64 string to int)\n", prog
);
32 printf("Usage: %s -c n [n ...] (converts to base 64 and back)\n", prog
);
34 ("Usage: %s -r low high inc (verify converter using range and inc)\n",
39 void btoi(int ac
, char **av
);
40 void itob(int ac
, char **av
);
41 void check(int ac
, char **av
);
42 void verifyRange(int ac
, char **av
);
45 main(int ac
, char **av
)
50 if (!strcmp(av
[1], "-s"))
52 else if (!strcmp(av
[1], "-i"))
54 else if (!strcmp(av
[1], "-c"))
56 else if (!strcmp(av
[1], "-r"))
65 btoi(int ac
, char **av
)
71 printf("%Lu\n", flipbase64_to_int64(av
[2]));
73 for (i
= 2; i
< ac
; i
++)
74 printf("%s: %Lu\n", av
[i
], flipbase64_to_int64(av
[i
]));
79 itob(int ac
, char **av
)
86 sscanf(av
[2], "%Ld", &in
);
87 printf("%s\n", int64_to_flipbase64(str
, in
));
89 for (i
= 2; i
< ac
; i
++) {
90 sscanf(av
[i
], "%Ld", &in
);
91 printf("%Ld: %s\n", in
, int64_to_flipbase64(str
, in
));
97 check(int ac
, char **av
)
103 printf("%10s %10s %10s\n", "input", "base64", "output");
104 for (i
= 2; i
< ac
; i
++) {
105 sscanf(av
[i
], "%Ld", &in
);
106 (void)int64_to_flipbase64(str
, in
);
107 out
= flipbase64_to_int64(str
);
108 printf("%10Ld %10s %10Ld\n", in
, str
, out
);
112 #define PROGRESS 1000000
114 verifyRange(int ac
, char **av
)
116 u_int64_t inc
, low
, high
;
124 sscanf(av
[2], "%lu", &low
);
125 sscanf(av
[3], "%lu", &high
);
126 sscanf(av
[4], "%lu", &inc
);
129 for (in
= low
; in
<= high
; in
+= inc
) {
131 if (n
% PROGRESS
== 0)
133 (void)int64_to_flipbase64(str
, in
);
134 out
= flipbase64_to_int64(str
);
136 printf("\n\nERROR: in=%Lu, str='%s', out=%Lu\n", in
, str
, out
);
140 printf("\nCOMPLETE - no errors found in range %Lu,%Lu,%Lu\n", low
, high
,
145 #endif /* AFS_NAMEI_ENV */