From 5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 13 Nov 2018 21:45:44 +0000 Subject: Use C99 bool within source modules. This is the main bulk of this boolification work, but although it's making the largest actual change, it should also be the least disruptive to anyone interacting with this code base downstream of me, because it doesn't modify any interface between modules: all the inter-module APIs were updated one by one in the previous commits. This just cleans up the code within each individual source file to use bool in place of int where I think that makes things clearer. --- obfusc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'obfusc.c') diff --git a/obfusc.c b/obfusc.c index acd1945..c62189c 100644 --- a/obfusc.c +++ b/obfusc.c @@ -36,8 +36,8 @@ int main(int argc, char **argv) char *inhex = NULL; unsigned char *data; int datalen; - int decode = -1; - int doing_opts = true; + enum { UNKNOWN, DECODE, ENCODE } mode = UNKNOWN; + bool doing_opts = true; while (--argc > 0) { char *p = *++argv; @@ -51,10 +51,10 @@ int main(int argc, char **argv) while (*p) { switch (*p) { case 'e': - decode = 0; + mode = ENCODE; break; case 'd': - decode = 1; + mode = DECODE; break; case 'b': outputmode = BINARY; @@ -79,13 +79,13 @@ int main(int argc, char **argv) } } - if (decode < 0) { + if (mode == UNKNOWN) { fprintf(stderr, "usage: obfusc < -e | -d > [ -b | -h ] [hex data]\n"); return 0; } if (outputmode == DEFAULT) - outputmode = (decode ? BINARY : HEX); + outputmode = (mode == DECODE ? BINARY : HEX); if (inhex) { datalen = strlen(inhex) / 2; @@ -111,7 +111,7 @@ int main(int argc, char **argv) } } - obfuscate_bitmap(data, datalen * 8, decode); + obfuscate_bitmap(data, datalen * 8, mode == DECODE); if (outputmode == BINARY) { int ret = fwrite(data, 1, datalen, stdout); -- cgit v1.1