#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>
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)
{
/* --- 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 --- */
}
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);
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);
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);
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);