]> diplodocus.org Git - nmh/blobdiff - uip/imaptest.c
Fixed mhical(1) exit status to reflect return status of icalparse().
[nmh] / uip / imaptest.c
index cd11aab55870e3bb3291243ab37fd03f594fcb01..9ad2234111bd417805856105fb37ba8e961bffe8 100644 (file)
@@ -5,9 +5,18 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/utils.h>
-#include <h/netsec.h>
+#include "h/mh.h"
+#include "sbr/getarguments.h"
+#include "sbr/smatch.h"
+#include "sbr/client.h"
+#include "sbr/getcpy.h"
+#include "sbr/brkstring.h"
+#include "sbr/ambigsw.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/error.h"
+#include "h/utils.h"
+#include "h/netsec.h"
 #include <stdarg.h>
 #include <sys/time.h>
 #include "h/done.h"
@@ -33,6 +42,7 @@
     X("batch filename", 0, BATCHSW) \
     X("timestamp", 0, TIMESTAMPSW) \
     X("notimestamp", 0, NOTIMESTAMPSW) \
+    X("timeout", 0, TIMEOUTSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
 
@@ -106,7 +116,7 @@ main (int argc, char **argv)
 {
     bool sasl = false, tls = false, initialtls = false;
     bool snoop = false, queue = false;
-    int fd;
+    int fd, timeout = 0;
     char *saslmech = NULL, *host = NULL, *port = "143", *user = NULL;
     char *cp, **argp, buf[BUFSIZ], *oauth_svc = NULL, *errstr, **arguments, *p;
     char *afolder = NULL;
@@ -169,11 +179,18 @@ main (int argc, char **argv)
                batchfile(*argp++, afolder, queue);
                continue;
 
+           case TIMEOUTSW:
+               if (! *argp || (**argp == '-'))
+                   die("missing argument to %s", argp[-1]);
+               if (! (timeout = atoi(*argp++)))
+                   die("Invalid timeout: %s", argp[-1]);
+               continue;
+
            case SNOOPSW:
                snoop = true;
                continue;
            case NOSNOOPSW:
-               snoop = false;
+               snoop = false;
                continue;
            case SASLSW:
                sasl = true;
@@ -186,7 +203,7 @@ main (int argc, char **argv)
                    die("missing argument to %s", argp[-2]);
                continue;
            case AUTHSERVICESW:
-               if (!(oauth_svc = *argp++) || *oauth_svc == '-')
+               if (!(oauth_svc = *argp++) || *oauth_svc == '-')
                    die("missing argument to %s", argp[-2]);
                continue;
            case TLSSW:
@@ -233,6 +250,9 @@ main (int argc, char **argv)
 
     netsec_set_hostname(nsc, host);
 
+    if (timeout)
+       netsec_set_timeout(nsc, timeout);
+
     if (snoop)
        netsec_set_snoop(nsc, 1);
 
@@ -629,7 +649,7 @@ imap_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata,
            *outdata = NULL;
            *outdatalen = 0;
        } else {
-           rc = decodeBase64(line + 2, outdata, &len, 0, NULL);
+           rc = decodeBase64(line + 2, outdata, &len, 0);
            *outdatalen = len;
            if (rc != OK) {
                netsec_err(errstr, "Unable to decode base64 response");
@@ -733,7 +753,7 @@ send_imap_command(netsec_context *nsc, bool noflush, char **errstr,
        vsnprintf(cmd->prefix, sizeof(cmd->prefix), fmt, ap);
        va_end(ap);
 
-       p = strchr(cmd->prefix, ' ');
+       p = strchr(cmd->prefix, ' ');
 
        if (p)
            *p = '\0';