Deploy the new <ctype.h> and `foocmp' macros from mLib.
[catacomb] / progs / cc-enc.c
index f4b6119..a008fbb 100644 (file)
@@ -35,6 +35,7 @@
 #include <mLib/alloc.h>
 #include <mLib/base64.h>
 #include <mLib/dstr.h>
+#include <mLib/macros.h>
 #include <mLib/mdwopt.h>
 #include <mLib/report.h>
 #include <mLib/sub.h>
@@ -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,14 +400,14 @@ 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",
@@ -481,14 +482,14 @@ 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",