#include <mLib/alloc.h>
#include <mLib/dstr.h>
#include <mLib/fdflags.h>
+#include <mLib/macros.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
phrase *p;
for (p = p_head; p; p = p->next) {
- if (strcmp(p->tag, tag) == 0) {
+ if (STRCMP(p->tag, ==, tag)) {
if (p->t) {
struct timeval tv;
sel_rmtimer(&p->timer);
phrase *pp = p->next;
if (!tag)
p_free(p);
- else if (strcmp(p->tag, tag) == 0) {
+ else if (STRCMP(p->tag, ==, tag)) {
if (verbose > 1)
pxlog("flushing passphrase `%s'", tag);
p_free(p);
ok: {
char *p = buf;
size_t len;
- while (isspace((unsigned char)*p))
+ while (ISSPACE(*p))
p++;
len = strlen(p);
memmove(buf, p, len);
goto fail;
if (p_request("Verify passphrase", tag, pp, LBUFSZ) < 0)
goto fail;
- if (strcmp(pp, p->p) != 0) {
+ if (STRCMP(pp, !=, p->p)) {
if (verbose)
pxlog("passphrases for `%s' don't match", tag);
p_free(p);
if ((q = str_getword(&s)) == 0)
return;
for (qq = q; *qq; qq++)
- *qq = tolower((unsigned char)*qq);
+ *qq = TOLOWER(*qq);
/* --- Handle a help request --- */
- if (strcmp(q, "help") == 0) {
+ if (STRCMP(q, ==, "help")) {
if (pixserv_write(px, "\
INFO Commands supported:\n\
INFO flush [TAG]\n\
/* --- List the passphrases --- */
- else if (strcmp(q, "list") == 0) {
+ else if (STRCMP(q, ==, "list")) {
phrase *p;
for (p = p_head; p; p = p->next) {
/* --- Request a passphrase --- */
- else if ((mode = PMODE_READ, strcmp(q, "pass") == 0) ||
- (mode = PMODE_VERIFY, strcmp(q, "verify") == 0)) {
+ else if ((mode = PMODE_READ, STRCMP(q, ==, "pass")) ||
+ (mode = PMODE_VERIFY, STRCMP(q, ==, "verify"))) {
unsigned long t;
const char *p;
int rc;
/* --- Flush existing passphrases --- */
- else if (strcmp(q, "flush") == 0) {
+ else if (STRCMP(q, ==, "flush")) {
q = str_getword(&s);
p_flush(q);
if (pixserv_write(px, "OK\n")) goto close;
/* --- Set a passphrase --- */
- else if (strcmp(q, "set") == 0) {
+ else if (STRCMP(q, ==, "set")) {
char *tag;
unsigned long t;
if ((tag = str_getword(&s)) == 0) {
} else if ((q = str_getword(&s)) == 0) {
if (pixserv_write(px, "FAIL no passphrase\n")) goto close;
} else {
- if (strcmp(q, "--") != 0) {
+ if (STRCMP(q, !=, "--")) {
t = pixserv_timeout(q);
q = str_getword(&s);
} else
t = pixserv_timeout(0);
if (!q) {
if (pixserv_write(px, "FAIL no passphrase\n")) goto close;
- } else if (strcmp(q, "--") != 0) {
+ } else if (STRCMP(q, !=, "--")) {
if (pixserv_write(px, "FAIL rubbish found before passphrase\n"))
goto close;
} else {
/* --- Shut the server down --- */
- else if (strcmp(q, "quit") == 0) {
+ else if (STRCMP(q, ==, "quit")) {
if (verbose) {
pxlog("%s client requested shutdown",
px->f & px_stdin ? "local" : "remote");
puts(s);
else {
char *q = str_getword(&s);
- if (strcmp(q, "FAIL") == 0)
+ if (STRCMP(q, ==, "FAIL"))
die(1, "%s", s);
- else if (strcmp(q, "INFO") == 0 ||
- strcmp(q, "ITEM") == 0)
+ else if (STRCMP(q, ==, "INFO") ||
+ STRCMP(q, ==, "ITEM"))
puts(s);
- else if (strcmp(q, "OK") == 0) {
+ else if (STRCMP(q, ==, "OK")) {
if (s && *s) puts(s);
- } else if (strcmp(q, "MISSING") == 0)
+ } else if (STRCMP(q, ==, "MISSING"))
;
else
moan("unexpected output: %s %s", q, s);