Reformated comments and long lines
[mmh] / uip / spost.c
index 80c6183..63b49da 100644 (file)
@@ -1,13 +1,13 @@
 /*
- * spost.c -- feed messages to sendmail
- *
- * This is a simpler, faster, replacement for "post" for use
- * when "sendmail" is the transport system.
- *
- * This code is Copyright (c) 2002, by the authors of nmh.  See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** spost.c -- feed messages to sendmail
+**
+** This is a simpler, faster, replacement for "post" for use
+** when "sendmail" is the transport system.
+**
+** This code is Copyright (c) 2002, by the authors of nmh.  See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
 
 #include <h/mh.h>
 #include <signal.h>
@@ -165,16 +165,16 @@ static FILE *out;  /* output (temp) file */
 extern char *sendmail;
 
 /*
- * external prototypes
- */
+** external prototypes
+*/
 extern char *getfullname (void);
 extern char *getusername (void);
 
 extern boolean  draft_from_masquerading;  /* defined in mts.c */
 
 /*
- * static prototypes
- */
+** static prototypes
+*/
 static void putfmt (char *, char *, FILE *);
 static void start_headers (void);
 static void finish_headers (FILE *);
@@ -238,7 +238,8 @@ main (int argc, char **argv)
                                        continue;
 
                                case FILTSW:
-                                       if (!(filter = *argp++) || *filter == '-')
+                                       if (!(filter = *argp++) ||
+                                                       *filter == '-')
                                                adios (NULL, "missing argument to %s", argp[-2]);
                                        continue;
                                case NFILTSW:
@@ -283,12 +284,13 @@ main (int argc, char **argv)
                                case ALIASW:
                                        if (!(cp = *argp++) || *cp == '-')
                                                adios (NULL, "missing argument to %s", argp[-2]);
-                                       if (aliasflg < 0)
-                                               alias (AliasFile);/* load default aka's */
+                                       if (aliasflg < 0) {
+                                               /* load default aka's */
+                                               alias (AliasFile);
+                                       }
                                        aliasflg = 1;
                                        if ((state = alias(cp)) != AK_OK)
-                                               adios (NULL, "aliasing error in file %s - %s",
-                                                          cp, akerror(state) );
+                                               adios (NULL, "aliasing error in file %s - %s", cp, akerror(state) );
                                        continue;
                                case NALIASW:
                                        aliasflg = 0;
@@ -373,7 +375,8 @@ main (int argc, char **argv)
                                finish_headers (out);
                                fprintf (out, "\n%s", buf);
                                while (state == BODY) {
-                                       state = m_getfld (state, name, buf, sizeof(buf), in);
+                                       state = m_getfld (state, name, buf,
+                                                       sizeof(buf), in);
                                        fputs (buf, out);
                                }
                                break;
@@ -384,8 +387,7 @@ main (int argc, char **argv)
 
                        case LENERR:
                        case FMTERR:
-                               adios (NULL, "message format error in component #%d",
-                                               compnum);
+                               adios (NULL, "message format error in component #%d", compnum);
 
                        default:
                                adios (NULL, "getfld() returned %d", state);
@@ -409,9 +411,9 @@ main (int argc, char **argv)
        file (tmpfil);
 
        /*
-        * re-open the temp file, unlink it and exec sendmail, giving it
-        * the msg temp file as std in.
-        */
+       ** re-open the temp file, unlink it and exec sendmail, giving it
+       ** the msg temp file as std in.
+       */
        if ( freopen( tmpfil, "r", stdin) == NULL)
                adios (tmpfil, "can't reopen for sendmail");
        if (rmflg)
@@ -432,8 +434,9 @@ main (int argc, char **argv)
                        sleep(5);
                switch (pid) {
                        case NOTOK:
-                               fprintf (verbose ? stdout : stderr, "%s: can't fork to %s\n",
-                                                invo_name, sendmail);
+                               fprintf (verbose ? stdout : stderr,
+                                               "%s: can't fork to %s\n",
+                                               invo_name, sendmail);
                                exit(-1);
                        case OK:
                                /* we're the child .. */
@@ -475,7 +478,8 @@ putfmt (char *name, char *str, FILE *out)
        msgflags |= hdr->set;
 
        if (hdr->flags & HSUB)
-               subject = subject ? add (str, add ("\t", subject)) : getcpy (str);
+               subject = subject ? add (str, add ("\t", subject)) :
+                               getcpy (str);
 
        if (hdr->flags & HFCC) {
                if ((cp = strrchr(str, '\n')))
@@ -497,12 +501,13 @@ putfmt (char *name, char *str, FILE *out)
 
        if (*str != '\n' && *str != '\0') {
                if (aliasflg && hdr->flags & HTRY) {
-                       /* this header contains address(es) that we have to do
-                        * alias expansion on.  Because of the saved state in
-                        * getname we have to put all the addresses into a list.
-                        * We then let putadr munch on that list, possibly
-                        * expanding aliases.
-                        */
+                       /*
+                       ** this header contains address(es) that we have to do
+                       ** alias expansion on.  Because of the saved state in
+                       ** getname we have to put all the addresses into a
+                       ** list. We then let putadr munch on that list,
+                       ** possibly expanding aliases.
+                       **/
                        register struct mailname *f = 0;
                        register struct mailname *mp = 0;
 
@@ -521,24 +526,24 @@ putfmt (char *name, char *str, FILE *out)
                        putadr( name, f );
                } else {
                        /*
-                        * The author(s) of spost decided that alias
-                        * substitution wasn't necessary for the non-HTRY
-                        * headers.  Unfortunately, one of those headers
-                        * is "From:", and having alias substitution
-                        * work on that is extremely useful for someone
-                        * with a lot of POP3 email accounts or aliases.
-                        * post supports aliasing of "From:"...
-                        *
-                        * Since "From:"-processing is incompletely
-                        * implemented in this unsupported and
-                        * undocumented spost backend, I'm not
-                        * going to take the time to implement my new
-                        * draft-From:-based email address masquerading.
-                        * If I do ever implement it here, I'd almost
-                        * certainly want to implement "From:" line
-                        * alias processing as well.
-                        * -- Dan Harkless <dan-nmh@dilvish.speed.net>
-                        */
+                       ** The author(s) of spost decided that alias
+                       ** substitution wasn't necessary for the non-HTRY
+                       ** headers.  Unfortunately, one of those headers
+                       ** is "From:", and having alias substitution
+                       ** work on that is extremely useful for someone
+                       ** with a lot of POP3 email accounts or aliases.
+                       ** post supports aliasing of "From:"...
+                       **
+                       ** Since "From:"-processing is incompletely
+                       ** implemented in this unsupported and
+                       ** undocumented spost backend, I'm not
+                       ** going to take the time to implement my new
+                       ** draft-From:-based email address masquerading.
+                       ** If I do ever implement it here, I'd almost
+                       ** certainly want to implement "From:" line
+                       ** alias processing as well.
+                       ** -- Dan Harkless <dan-nmh@dilvish.speed.net>
+                       */
                        fprintf (out, "%s: %s", name, str );
                }
        }
@@ -555,7 +560,8 @@ start_headers (void)
 
        if ((cp = getfullname ()) && *cp) {
                strncpy (sigbuf, cp, sizeof(sigbuf));
-               snprintf (signature, sizeof(signature), "%s <%s>", sigbuf,  from);
+               snprintf (signature, sizeof(signature), "%s <%s>",
+                               sigbuf,  from);
        } else
                snprintf (signature, sizeof(signature), "%s",  from);
 }
@@ -570,17 +576,20 @@ finish_headers (FILE *out)
                                fprintf (out, "Date: %s\n", dtimenow (0));
 
                        if (msgflags & MFRM) {
-                               /* There was already a From: in the draft.  Don't add one. */
+                               /*
+                               ** There was already a From: in the draft.
+                               ** Don't add one.
+                               */
                                if (!draft_from_masquerading)
                                        /*
-                                        * mts.conf didn't contain
-                                        * "masquerade:[...]draft_from[...]"
-                                        * so we'll reveal the user's
-                                        * actual account@thismachine
-                                        * address in a Sender: header
-                                        * (and use it as the envelope
-                                        * From: later).
-                                        */
+                                       ** mts.conf didn't contain
+                                       ** "masquerade:[...]draft_from[...]"
+                                       ** so we'll reveal the user's
+                                       ** actual account@thismachine
+                                       ** address in a Sender: header
+                                       ** (and use it as the envelope
+                                       ** From: later).
+                                       */
                                        fprintf (out, "Sender: %s\n", from);
                        } else
                                fprintf (out, "From: %s\n", signature);
@@ -593,20 +602,25 @@ finish_headers (FILE *out)
 
                case resent:
                        if (!(msgflags & MRDT))
-                               fprintf (out, "Resent-Date: %s\n", dtimenow(0));
+                               fprintf (out, "Resent-Date: %s\n",
+                                               dtimenow(0));
                        if (msgflags & MRFM) {
-                               /* There was already a Resent-From: in draft.  Don't add one. */
+                               /*
+                               ** There was already a Resent-From: in draft.
+                               ** Don't add one.
+                               */
                                if (!draft_from_masquerading)
                                        /*
-                                        * mts.conf didn't contain
-                                        * "masquerade:[...]draft_from[...]"
-                                        * so we'll reveal the user's
-                                        * actual account@thismachine
-                                        * address in a Sender: header
-                                        * (and use it as the envelope
-                                        * From: later).
-                                        */
-                                       fprintf (out, "Resent-Sender: %s\n", from);
+                                       ** mts.conf didn't contain
+                                       ** "masquerade:[...]draft_from[...]"
+                                       ** so we'll reveal the user's
+                                       ** actual account@thismachine
+                                       ** address in a Sender: header
+                                       ** (and use it as the envelope
+                                       ** From: later).
+                                       */
+                                       fprintf (out, "Resent-Sender: %s\n",
+                                                       from);
                        } else
                                /* Construct a Resent-From: header. */
                                fprintf (out, "Resent-From: %s\n", signature);
@@ -636,10 +650,10 @@ get_header (char *header, struct headers *table)
 
 
 /*
- * output the address list for header "name".  The address list
- * is a linked list of mailname structs.  "nl" points to the head
- * of the list.  Alias substitution should be done on nl.
- */
+** output the address list for header "name".  The address list
+** is a linked list of mailname structs.  "nl" points to the head
+** of the list.  Alias substitution should be done on nl.
+*/
 static void
 putadr (char *name, struct mailname *nl)
 {
@@ -654,15 +668,15 @@ putadr (char *name, struct mailname *nl)
 
        for (mp = nl; mp; ) {
                if (linepos > MAX_SM_FIELD) {
-                               fprintf (out, "\n%s: ", name);
-                               linepos = namelen;
+                       fprintf (out, "\n%s: ", name);
+                       linepos = namelen;
                }
                if (mp->m_nohost) {
                        /* a local name - see if it's an alias */
                        cp = akvalue(mp->m_mbox);
                        if (cp == mp->m_mbox)
                                /* wasn't an alias - use what the user typed */
-                               linepos = putone( mp->m_text, linepos, namelen );
+                               linepos = putone(mp->m_text, linepos, namelen);
                        else
                                /* an alias - expand it */
                                while ((cp = getname(cp))) {
@@ -703,8 +717,7 @@ putone (char *adr, int pos, int indent)
                fprintf ( out, ",\n%*s", indent, "");
                linepos = indent;
                pos += indent + 2;
-       }
-       else {
+       } else {
                fputs( ", ", out );
                linepos += 2;
                pos += 2;
@@ -762,11 +775,11 @@ make_bcc_file (void)
          /* There was already a From: in the draft.  Don't add one. */
          if (!draft_from_masquerading)
                /*
-                * mts.conf didn't contain "masquerade:[...]draft_from[...]"
-                * so we'll reveal the user's actual account@thismachine
-                * address in a Sender: header (and use it as the envelope
-                * From: later).
-                */
+               ** mts.conf didn't contain "masquerade:[...]draft_from[...]"
+               ** so we'll reveal the user's actual account@thismachine
+               ** address in a Sender: header (and use it as the envelope
+               ** From: later).
+               */
                fprintf (out, "Sender: %s\n", from);
        } else
          /* Construct a From: header. */
@@ -805,7 +818,8 @@ make_bcc_file (void)
 
                        default:
                                if (status = pidwait(child_id, OK))
-                                       admonish (NULL, "%s lost (status=0%o)", vec[0], status);
+                                       admonish (NULL, "%s lost (status=0%o)",
+                                                       vec[0], status);
                                break;
                }
        }
@@ -876,8 +890,8 @@ fcc (char *file, char *folder)
 #if 0
 
 /*
- * TERMINATION
- */
+** TERMINATION
+*/
 
 static void
 die (char *what, char *fmt, ...)