]> diplodocus.org Git - nmh/blobdiff - uip/popsbr.c
test-nocreate: Don't use run_test and run_prog together.
[nmh] / uip / popsbr.c
index 50cdf09b12c79bc546f4e3470cad3fc4a72727f2..54aa36843ba7e3e4595347080a0a321909deb2e7 100644 (file)
@@ -15,7 +15,6 @@
 #include <h/signals.h>
 
 #define        TRM     "."
-#define        TRMLEN  (sizeof TRM - 1)
 
 static int poprint = 0;
 
@@ -240,6 +239,8 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
            if (poprint)
                fprintf (stderr, "<--- %s\n", response);
            if (*response == '+') {
+                nmh_creds_t creds;
+
                if (sasl) {
                    char server_mechs[256];
                    if (check_mech(server_mechs, sizeof(server_mechs)) != OK)
@@ -252,21 +253,19 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
                        return NOTOK;
                    }
                    return OK;
-               } else {
-                   nmh_creds_t creds;
-
-                   if (!(creds = nmh_get_credentials(host, user)))
-                       return NOTOK;
-                   if (command ("USER %s", nmh_cred_get_user(creds))
-                                                               != NOTOK) {
-                       if (command("PASS %s", nmh_cred_get_password(creds))
-                                                               != NOTOK) {
-                           nmh_credentials_free(creds);
-                           return OK;
-                       }
-                   }
-                   nmh_credentials_free(creds);
                }
+
+                if (!(creds = nmh_get_credentials(host, user)))
+                    return NOTOK;
+                if (command ("USER %s", nmh_cred_get_user(creds))
+                                                            != NOTOK) {
+                    if (command("PASS %s", nmh_cred_get_password(creds))
+                                                            != NOTOK) {
+                        nmh_credentials_free(creds);
+                        return OK;
+                    }
+                }
+                nmh_credentials_free(creds);
            }
            strncpy (buffer, response, sizeof(buffer));
            command ("QUIT");
@@ -434,7 +433,7 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata,
        if (line == NULL)
            return NOTOK;
 
-       if (strncmp(line, "+OK", 3) != 0) {
+       if (!HasPrefix(line, "+OK")) {
            netsec_err(errstr, "Authentication failed: %s", line);
            return NOTOK;
        }
@@ -686,15 +685,14 @@ vcommand (const char *fmt, va_list ap)
 int
 multiline (void)
 {
-    char buffer[BUFSIZ + TRMLEN];
+    char buffer[BUFSIZ + LEN(TRM)];
 
     if (pop_getline (buffer, sizeof buffer, nsc) != OK)
        return NOTOK;
-    if (strncmp (buffer, TRM, TRMLEN) == 0) {
-       if (buffer[TRMLEN] == 0)
+    if (HasPrefix(buffer, TRM)) {
+       if (buffer[LEN(TRM)] == 0)
            return DONE;
-       else
-           strncpy (response, buffer + TRMLEN, sizeof(response));
+        strncpy (response, buffer + LEN(TRM), sizeof(response));
     }
     else
        strncpy (response, buffer, sizeof(response));