]> diplodocus.org Git - nmh/blobdiff - uip/mhical.c
fdcompare.c: Move interface to own file.
[nmh] / uip / mhical.c
index 6cf7c0e17b14bfdf7803789011ecbd286ceaa297..bb5a9eee39dfab58cf5acb4ecc9d149e687150f4 100644 (file)
@@ -6,9 +6,14 @@
  */
 
 #include "h/mh.h"
+#include "sbr/ambigsw.h"
+#include "sbr/path.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/error.h"
 #include "h/icalendar.h"
 #include "sbr/icalparse.h"
-#include <h/fmt_scan.h>
+#include "h/fmt_scan.h"
 #include "h/addrsbr.h"
 #include "h/mts.h"
 #include "h/done.h"
@@ -60,7 +65,8 @@ vevent vevents = { NULL, NULL, NULL};
 int parser_status = 0;
 
 int
-main (int argc, char *argv[]) {
+main (int argc, char *argv[])
+{
     /* RFC 5322 § 3.3 date-time format, including the optional
        day-of-week and not including the optional seconds.  The
        zone is required by the RFC but not always output by this
@@ -70,7 +76,8 @@ main (int argc, char *argv[]) {
     act action = ACT_NONE;
     char *infile = NULL, *outfile = NULL;
     FILE *inputfile = NULL, *outputfile = NULL;
-    int contenttype = 0, unfold = 0;
+    bool contenttype = false;
+    bool unfold = false;
     vevent *v, *nextvevent;
     char *form = "mhical.24hour", *format = NULL;
     char **argp, **arguments, *cp;
@@ -150,14 +157,14 @@ main (int argc, char *argv[]) {
                 continue;
 
             case CONTENTTYPESW:
-                contenttype = 1;
+                contenttype = true;
                 continue;
             case NCONTENTTYPESW:
-                contenttype = 0;
+                contenttype = false;
                 continue;
 
             case UNFOLDSW:
-                unfold = 1;
+                unfold = true;
                 continue;
             }
         }
@@ -256,9 +263,10 @@ main (int argc, char *argv[]) {
  * - Excise VALARM sections.
  */
 static void
-convert_to_reply (contentline *clines, act action) {
+convert_to_reply (contentline *clines, act action)
+{
     char *partstat = NULL;
-    int found_my_attendee_line = 0;
+    bool found_my_attendee_line = false;
     contentline *node;
 
     convert_common (clines, action);
@@ -302,7 +310,7 @@ convert_to_reply (contentline *clines, act action) {
             while (getname ("")) { continue; }
 
             if (ismymbox (mn)) {
-                found_my_attendee_line = 1;
+                found_my_attendee_line = true;
                 for (p = node->params; p && p->param_name; p = p->next) {
                     value_list *v;
 
@@ -362,7 +370,8 @@ convert_to_reply (contentline *clines, act action) {
  * - Excise VALARM sections.
  */
 static void
-convert_to_cancellation (contentline *clines) {
+convert_to_cancellation (contentline *clines)
+{
     contentline *node;
 
     convert_common (clines, ACT_CANCEL);
@@ -384,9 +393,10 @@ convert_to_cancellation (contentline *clines) {
 }
 
 static void
-convert_common (contentline *clines, act action) {
+convert_common (contentline *clines, act action)
+{
     contentline *node;
-    int in_valarm;
+    bool in_valarm;
 
     if ((node = find_contentline (clines, "METHOD", 0))) {
         free (node->value);
@@ -470,7 +480,7 @@ convert_common (contentline *clines, act action) {
     }
 
     /* Excise X- lines and VALARM section(s). */
-    in_valarm = 0;
+    in_valarm = false;
     for (node = clines; node; node = node->next) {
         /* node->name will be NULL if the line was deleted. */
         if (! node->name) { continue; }
@@ -478,13 +488,13 @@ convert_common (contentline *clines, act action) {
         if (in_valarm) {
             if (! strcasecmp ("END", node->name)  &&
                 ! strcasecmp ("VALARM", node->value)) {
-                in_valarm = 0;
+                in_valarm = false;
             }
             remove_contentline (node);
         } else {
             if (! strcasecmp ("BEGIN", node->name)  &&
                 ! strcasecmp ("VALARM", node->value)) {
-                in_valarm = 1;
+                in_valarm = true;
                 remove_contentline (node);
             } else if (! strncasecmp ("X-", node->name, 2)) {
                 remove_contentline (node);
@@ -495,7 +505,8 @@ convert_common (contentline *clines, act action) {
 
 /* Echo the input, but with unfolded lines. */
 static void
-dump_unfolded (FILE *file, contentline *clines) {
+dump_unfolded (FILE *file, contentline *clines)
+{
     contentline *node;
 
     for (node = clines; node; node = node->next) {
@@ -504,7 +515,8 @@ dump_unfolded (FILE *file, contentline *clines) {
 }
 
 static void
-output (FILE *file, contentline *clines, int contenttype) {
+output (FILE *file, contentline *clines, int contenttype)
+{
     contentline *node;
 
     if (contenttype) {
@@ -557,10 +569,11 @@ output (FILE *file, contentline *clines, int contenttype) {
  *   - attendees (limited to number specified in initialization)
  */
 static void
-display (FILE *file, contentline *clines, char *nfs) {
+display (FILE *file, contentline *clines, char *nfs)
+{
     tzdesc_t timezones = load_timezones (clines);
-    int in_vtimezone;
-    int in_valarm;
+    bool in_vtimezone;
+    bool in_valarm;
     contentline *node;
     struct format *fmt;
     int dat[5] = { 0, 0, 0, INT_MAX, 0 };
@@ -595,7 +608,7 @@ display (FILE *file, contentline *clines, char *nfs) {
     }
 
     /* Only display DESCRIPTION lines that are outside VALARM section(s). */
-    in_valarm = 0;
+    in_valarm = false;
     if ((c = fmt_findcomp ("description"))) {
         for (node = clines; node; node = node->next) {
             /* node->name will be NULL if the line was deleted. */
@@ -606,12 +619,12 @@ display (FILE *file, contentline *clines, char *nfs) {
             } else if (in_valarm) {
                 if (! strcasecmp ("END", node->name)  &&
                     ! strcasecmp ("VALARM", node->value)) {
-                    in_valarm = 0;
+                    in_valarm = false;
                 }
             } else {
                 if (! strcasecmp ("BEGIN", node->name)  &&
                     ! strcasecmp ("VALARM", node->value)) {
-                    in_valarm = 1;
+                    in_valarm = true;
                 }
             }
         }
@@ -626,7 +639,7 @@ display (FILE *file, contentline *clines, char *nfs) {
 
     if ((c = fmt_findcomp ("dtstart"))) {
         /* Find DTSTART outsize of a VTIMEZONE section. */
-        in_vtimezone = 0;
+        in_vtimezone = false;
         for (node = clines; node; node = node->next) {
             /* node->name will be NULL if the line was deleted. */
             if (! node->name) { continue; }
@@ -634,12 +647,12 @@ display (FILE *file, contentline *clines, char *nfs) {
             if (in_vtimezone) {
                 if (! strcasecmp ("END", node->name)  &&
                     ! strcasecmp ("VTIMEZONE", node->value)) {
-                    in_vtimezone = 0;
+                    in_vtimezone = false;
                 }
             } else {
                 if (! strcasecmp ("BEGIN", node->name)  &&
                     ! strcasecmp ("VTIMEZONE", node->value)) {
-                    in_vtimezone = 1;
+                    in_vtimezone = true;
                 } else if (! strcasecmp ("DTSTART", node->name)) {
                     /* Got it:  DTSTART outside of a VTIMEZONE section. */
                     char *datetime = format_datetime (timezones, node);
@@ -726,7 +739,8 @@ display (FILE *file, contentline *clines, char *nfs) {
 }
 
 static const char *
-identity (const contentline *node) {
+identity (const contentline *node)
+{
     /* According to RFC 5545 § 3.3.3, an email address in the value
        must be a mailto URI. */
     if (! strncasecmp (node->value, "mailto:", 7)) {
@@ -756,7 +770,8 @@ identity (const contentline *node) {
 }
 
 static char *
-format_params (char *line, param_list *p) {
+format_params (char *line, param_list *p)
+{
     for ( ; p && p->param_name; p = p->next) {
         value_list *v;
         size_t num_values = 0;
@@ -789,7 +804,8 @@ format_params (char *line, param_list *p) {
 }
 
 static char *
-fold (char *line, int uses_cr) {
+fold (char *line, int uses_cr)
+{
     size_t remaining = strlen (line);
     size_t current_line_len = 0;
     charstring_t folded_line = charstring_create (2 * remaining);