X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/912ebbc5f3e9f9485c476a34566c62ad11b8daa3..HEAD:/progs/pixie.c diff --git a/progs/pixie.c b/progs/pixie.c index 3fd32081..f827c201 100644 --- a/progs/pixie.c +++ b/progs/pixie.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -229,7 +230,7 @@ static phrase *p_find(const char *tag) 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); @@ -311,7 +312,7 @@ static void p_flush(const char *tag) 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); @@ -445,7 +446,7 @@ static int p_request(const char *msg, const char *tag, char *buf, size_t sz) ok: { char *p = buf; size_t len; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; len = strlen(p); memmove(buf, p, len); @@ -517,7 +518,7 @@ static int p_get(const char **q, const char *tag, unsigned mode, time_t exp) 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); @@ -677,11 +678,11 @@ static void pixserv_line(char *s, size_t len, void *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\ @@ -698,7 +699,7 @@ OK\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) { @@ -718,8 +719,8 @@ OK\n\ /* --- 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; @@ -747,7 +748,7 @@ OK\n\ /* --- 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; @@ -755,7 +756,7 @@ OK\n\ /* --- 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) { @@ -763,14 +764,14 @@ OK\n\ } 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 { @@ -783,7 +784,7 @@ OK\n\ /* --- 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"); @@ -1076,14 +1077,14 @@ static void c_sline(char *s, size_t len, void *p) 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);