aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-01-15 02:42:02 -0600
committerRob Landley <rob@landley.net>2021-01-15 02:42:02 -0600
commitaf50278fc92ce5846d727eaa2b66b85063f53cae (patch)
tree87c8295c3a9c5d4b8e2dbd41cf2655d913b252a3 /toys
parentb3910f4871f05ed3c90dab7aa7e9cc25abae2c91 (diff)
downloadtoybox-af50278fc92ce5846d727eaa2b66b85063f53cae.tar.gz
Cleanup base32 slightly.
Diffstat (limited to 'toys')
-rw-r--r--toys/other/base64.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/toys/other/base64.c b/toys/other/base64.c
index 25e37d41..22652fd0 100644
--- a/toys/other/base64.c
+++ b/toys/other/base64.c
@@ -2,8 +2,9 @@
*
* Copyright 2014 Rob Landley <rob@landley.net>
*
- * No standard
+ * See https://tools.ietf.org/html/rfc4648
+// These optflags have to match. Todo: cleanup and collapse together?
USE_BASE64(NEWTOY(base64, "diw#<0=76[!dw]", TOYFLAG_USR|TOYFLAG_BIN))
USE_BASE32(NEWTOY(base32, "diw#<0=76[!dw]", TOYFLAG_USR|TOYFLAG_BIN))
@@ -33,6 +34,7 @@ config BASE32
*/
#define FOR_base64
+#define FORCE_FLAGS
#include "toys.h"
GLOBALS(
@@ -52,7 +54,7 @@ static void wraputchar(int c, int *x)
};
}
-static void do_base_n(int fd, char *name)
+static void do_base(int fd, char *name)
{
int out = 0, bits = 0, x = 0, i, len;
char *buf = toybuf+128;
@@ -106,17 +108,15 @@ void base64_main(void)
TT.n = 6;
TT.align = 3;
base64_init(toybuf);
- loopfiles(toys.optargs, do_base_n);
+ loopfiles(toys.optargs, do_base);
}
-#define CLEANUP_base64
-#define FOR_base32
-#include "generated/flags.h"
-
void base32_main(void)
{
+ int i;
+
TT.n = 5;
TT.align = 7;
- base32_init(toybuf);
- loopfiles(toys.optargs, do_base_n);
+ for (i = 0; i<32; i++) toybuf[i] = i+(i<26 ? 'A' : 24);
+ loopfiles(toys.optargs, do_base);
}