X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..141c12847a1c2f8cc8db03d420551584e689fb87:/progs/cc-enc.c diff --git a/progs/cc-enc.c b/progs/cc-enc.c index 61d9805b..a008fbbf 100644 --- a/progs/cc-enc.c +++ b/progs/cc-enc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ static enc *pem_encinit(FILE *fp, const char *msg) return (&pe->e); } -int checkbdry(const char *b, void *p) { return (!p || strcmp(b, p) == 0); } +int checkbdry(const char *b, void *p) { return (!p || STRCMP(b, ==, p)); } static enc *pem_decinit(FILE *fp, encbdryp *func, void *p) { @@ -133,7 +134,7 @@ banner: /* --- Check we have the right framing --- */ if (d != 5) goto top; - if (strncmp(buf, "BEGIN ", 6) != 0 || (func && !func(buf + 6, p))) + if (STRNCMP(buf, !=, "BEGIN ", 6) || (func && !func(buf + 6, p))) goto top; /* --- Ready --- */ @@ -248,7 +249,7 @@ static int pem_decdone(enc *e) } if (d != 5) goto fail; buf[i] = 0; - if (strncmp(buf, "END ", 4) != 0 || strcmp(buf + 4, pe->msg) != 0) + if (STRNCMP(buf, !=, "END ", 4) || STRCMP(buf + 4, !=, pe->msg)) goto fail; return (0); @@ -295,7 +296,7 @@ const encops *getenc(const char *enc) const encops *eo; for (eo = enctab; eo->name; eo++) { - if (strcmp(eo->name, enc) == 0) + if (STRCMP(eo->name, ==, enc)) goto e_found; } die(EXIT_FAILURE, "couldn't find encoding `%s'", enc); @@ -399,18 +400,18 @@ int cmd_encode(int argc, char *argv[]) die(EXIT_FAILURE, "encoding `%s' not found", ef); fn = optind < argc ? argv[optind++] : "-"; - if (strcmp(fn, "-") == 0) + if (STRCMP(fn, ==, "-")) fp = stdin; else if ((fp = fopen(fn, "rb")) == 0) { die(EXIT_FAILURE, "couldn't open file `%s': %s", fn, strerror(errno)); } - if (!of || strcmp(of, "-") == 0) + if (!of || STRCMP(of, ==, "-")) ofp = stdout; else if ((ofp = fopen(of, eo->wmode)) == 0) { die(EXIT_FAILURE, "couldn't open file `%s' for output: %s", - ofp, strerror(errno)); + of, strerror(errno)); } e = initenc(eo, ofp, bd); @@ -481,18 +482,18 @@ int cmd_decode(int argc, char *argv[]) die(EXIT_FAILURE, "encoding `%s' not found", ef); fn = optind < argc ? argv[optind++] : "-"; - if (strcmp(fn, "-") == 0) + if (STRCMP(fn, ==, "-")) fp = stdin; else if ((fp = fopen(fn, eo->rmode)) == 0) { die(EXIT_FAILURE, "couldn't open file `%s': %s", fn, strerror(errno)); } - if (!of || strcmp(of, "-") == 0) + if (!of || STRCMP(of, ==, "-")) ofp = stdout; else if ((ofp = fopen(of, "wb")) == 0) { die(EXIT_FAILURE, "couldn't open file `%s' for output: %s", - ofp, strerror(errno)); + of, strerror(errno)); } e = initdec(eo, fp, checkbdry, (/*unconst*/ void *)bd);