diff options
| author | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:45:44 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:48:24 +0000 |
| commit | 5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a (patch) | |
| tree | f96b55a27088ae71d74dc83d7cc3731c5d5bf6dc /obfusc.c | |
| parent | a550ea0a47374705a37f36b0f05ffe9e4c8161fb (diff) | |
| download | puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.zip puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.gz puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.bz2 puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.xz | |
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.
Diffstat (limited to 'obfusc.c')
| -rw-r--r-- | obfusc.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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); |