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.
This commit is contained in:
Simon Tatham
2018-11-13 21:45:44 +00:00
parent a550ea0a47
commit 5f5b284c0b
61 changed files with 2297 additions and 1973 deletions

View File

@ -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);