]> diplodocus.org Git - nmh/blobdiff - uip/mhical.c
mts/smtp/smtp.c: Replace int with bool.
[nmh] / uip / mhical.c
index 650b982131c226d48dd00682b7d98ecc029a4fff..6cf7c0e17b14bfdf7803789011ecbd286ceaa297 100644 (file)
@@ -11,6 +11,7 @@
 #include <h/fmt_scan.h>
 #include "h/addrsbr.h"
 #include "h/mts.h"
 #include <h/fmt_scan.h>
 #include "h/addrsbr.h"
 #include "h/mts.h"
+#include "h/done.h"
 #include "h/utils.h"
 #include <time.h>
 
 #include "h/utils.h"
 #include <time.h>
 
@@ -29,7 +30,7 @@ static void convert_common (contentline *, act);
 static void dump_unfolded (FILE *, contentline *);
 static void output (FILE *, contentline *, int);
 static void display (FILE *, contentline *, char *);
 static void dump_unfolded (FILE *, contentline *);
 static void output (FILE *, contentline *, int);
 static void display (FILE *, contentline *, char *);
-static const char *identity (const contentline *);
+static const char *identity (const contentline *) PURE;
 static char *format_params (char *, param_list *);
 static char *fold (char *, int);
 
 static char *format_params (char *, param_list *);
 static char *fold (char *, int);
 
@@ -76,7 +77,7 @@ main (int argc, char *argv[]) {
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
-    if (nmh_init(argv[0], 2)) { return 1; }
+    if (nmh_init(argv[0], true, false)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
@@ -91,7 +92,7 @@ main (int argc, char *argv[]) {
                 ambigsw (cp, switches);
                 done (1);
             case UNKWNSW:
                 ambigsw (cp, switches);
                 done (1);
             case UNKWNSW:
-                adios (NULL, "-%s unknown", cp);
+                die("-%s unknown", cp);
 
             case HELPSW: {
                 char buf[128];
 
             case HELPSW: {
                 char buf[128];
@@ -108,7 +109,7 @@ main (int argc, char *argv[]) {
 
             case REPLYSW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
 
             case REPLYSW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
-                    adios (NULL, "missing argument to %s", argp[-2]);
+                    die("missing argument to %s", argp[-2]);
                 if (! strcasecmp (cp, "accept")) {
                     action = ACT_ACCEPT;
                 } else if (! strcasecmp (cp, "decline")) {
                 if (! strcasecmp (cp, "accept")) {
                     action = ACT_ACCEPT;
                 } else if (! strcasecmp (cp, "decline")) {
@@ -118,7 +119,7 @@ main (int argc, char *argv[]) {
                 } else if (! strcasecmp (cp, "delegate")) {
                     action = ACT_DELEGATE;
                 } else {
                 } else if (! strcasecmp (cp, "delegate")) {
                     action = ACT_DELEGATE;
                 } else {
-                    adios (NULL, "Unknown action: %s", cp);
+                    die("Unknown action: %s", cp);
                 }
                 continue;
 
                 }
                 continue;
 
@@ -128,23 +129,23 @@ main (int argc, char *argv[]) {
 
             case FORMSW:
                 if (! (form = *argp++) || *form == '-')
 
             case FORMSW:
                 if (! (form = *argp++) || *form == '-')
-                    adios (NULL, "missing argument to %s", argp[-2]);
+                    die("missing argument to %s", argp[-2]);
                 format = NULL;
                 continue;
             case FMTSW:
                 if (! (format = *argp++) || *format == '-')
                 format = NULL;
                 continue;
             case FMTSW:
                 if (! (format = *argp++) || *format == '-')
-                    adios (NULL, "missing argument to %s", argp[-2]);
+                    die("missing argument to %s", argp[-2]);
                 form = NULL;
                 continue;
 
             case INFILESW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
                 form = NULL;
                 continue;
 
             case INFILESW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
-                    adios (NULL, "missing argument to %s", argp[-2]);
+                    die("missing argument to %s", argp[-2]);
                 infile = *cp == '-'  ?  mh_xstrdup(cp)  :  path (cp, TFILE);
                 continue;
             case OUTFILESW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
                 infile = *cp == '-'  ?  mh_xstrdup(cp)  :  path (cp, TFILE);
                 continue;
             case OUTFILESW:
                 if (! (cp = *argp++) || (*cp == '-' && cp[1]))
-                    adios (NULL, "missing argument to %s", argp[-2]);
+                    die("missing argument to %s", argp[-2]);
                 outfile = *cp == '-'  ?  mh_xstrdup(cp)  :  path (cp, TFILE);
                 continue;
 
                 outfile = *cp == '-'  ?  mh_xstrdup(cp)  :  path (cp, TFILE);
                 continue;
 
@@ -425,7 +426,7 @@ convert_common (contentline *clines, act action) {
             insert = "Tentative: ";
             break;
         case ACT_DELEGATE:
             insert = "Tentative: ";
             break;
         case ACT_DELEGATE:
-            adios (NULL, "Delegate replies are not supported");
+            die("Delegate replies are not supported");
             break;
         case ACT_CANCEL:
             insert = "Cancelled:";
             break;
         case ACT_CANCEL:
             insert = "Cancelled:";
@@ -444,7 +445,7 @@ convert_common (contentline *clines, act action) {
             node->value = tmp;
         } else {
             /* Should never get here. */
             node->value = tmp;
         } else {
             /* Should never get here. */
-            adios (NULL, "Unknown action: %d", action);
+            die("Unknown action: %d", action);
         }
     }
 
         }
     }
 
@@ -535,11 +536,10 @@ output (FILE *file, contentline *clines, int contenttype) {
             line = fold (add (node->value, line),
                          clines->cr_before_lf == CR_BEFORE_LF);
 
             line = fold (add (node->value, line),
                          clines->cr_before_lf == CR_BEFORE_LF);
 
-            if (clines->cr_before_lf == LF_ONLY) {
-                fprintf (file, "%s\n", line);
-            } else {
-                fprintf (file, "%s\r\n", line);
-            }
+            fputs(line, file);
+            if (clines->cr_before_lf != LF_ONLY)
+                putc('\r', file);
+            putc('\n', file);
             free (line);
         }
     }
             free (line);
         }
     }
@@ -714,7 +714,7 @@ display (FILE *file, contentline *clines, char *nfs) {
     }
 
     /* Don't call on the END:VCALENDAR line. */
     }
 
     /* Don't call on the END:VCALENDAR line. */
-    if (clines->next) {
+    if (clines  &&  clines->next) {
       (void) fmt_scan (fmt, buffer, INT_MAX, dat, NULL);
       fputs (charstring_buffer (buffer), file);
       fmt_free (fmt, 1);
       (void) fmt_scan (fmt, buffer, INT_MAX, dat, NULL);
       fputs (charstring_buffer (buffer), file);
       fmt_free (fmt, 1);