Reformated comments and long lines
[mmh] / sbr / addrsbr.c
index 4ab3fec..c8eb0c8 100644 (file)
@@ -1,65 +1,65 @@
 /*
- * addrsbr.c -- parse addresses 822-style
- *
- * 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.
- */
+** addrsbr.c -- parse addresses 822-style
+**
+** 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 <h/addrsbr.h>
 #include <h/mf.h>
 
 /*
- * High level parsing of addresses:
- *
- * The routines in sbr/mf.c parse the syntactic representations of
- * addresses.  The routines in sbr/addrsbr.c associate semantics with those
- * addresses.
- *
- * If #ifdef DUMB is in effect, a full 822-style parser is called
- * for syntax recongition.  This breaks each address into its components.
- * Note however that no semantics are assumed about the parts or their
- * totality.  This means that implicit hostnames aren't made explicit,
- * and explicit hostnames aren't expanded to their "official" represenations.
- *
- * If DUMB is not in effect, then this module does some
- * high-level thinking about what the addresses are.
- *
- * 1. for MMDF systems:
- *
- *      string%<uucp>@<local>  ->  string
- *
- * 2. for non-MMDF systems:
- *
- *      string@host.<uucp>  ->  host!string
- *
- * 3. for any system, an address interpreted relative to the local host:
- *
- *      string@<uucp>  ->  string
- *
- * For cases (1) and (3) above, the leftmost host is extracted.  If it's not
- * present, the local host is used.  If the tests above fail, the address is
- * considered to be a real 822-style address.
- *
- * If an explicit host is not present, then MH checks for a bang to indicate
- * an explicit UUCP-style address.  If so, this is noted.  If not, the host is
- * defaulted, typically to the local host.  The lack of an explict host is
- * also noted.
- *
- * If an explicit 822-style host is present, then MH checks to see if it
- * can expand this to the official name for the host.  If the hostname is
- * unknown, the address is so typed.
- *
- * To summarize, when we're all done, here's what MH knows about the address:
- *
- * DUMB - type: local, uucp, or network
- *              host:  not locally defaulted, not explicitly expanded
- *              everything else
- *
- * other - type: local, uucp, network, unknown
- *               everything else
- */
+** High level parsing of addresses:
+**
+** The routines in sbr/mf.c parse the syntactic representations of
+** addresses.  The routines in sbr/addrsbr.c associate semantics with those
+** addresses.
+**
+** If #ifdef DUMB is in effect, a full 822-style parser is called
+** for syntax recongition.  This breaks each address into its components.
+** Note however that no semantics are assumed about the parts or their
+** totality.  This means that implicit hostnames aren't made explicit,
+** and explicit hostnames aren't expanded to their "official" represenations.
+**
+** If DUMB is not in effect, then this module does some
+** high-level thinking about what the addresses are.
+**
+** 1. for MMDF systems:
+**
+**      string%<uucp>@<local>  ->  string
+**
+** 2. for non-MMDF systems:
+**
+**      string@host.<uucp>  ->  host!string
+**
+** 3. for any system, an address interpreted relative to the local host:
+**
+**      string@<uucp>  ->  string
+**
+** For cases (1) and (3) above, the leftmost host is extracted.  If it's not
+** present, the local host is used.  If the tests above fail, the address is
+** considered to be a real 822-style address.
+**
+** If an explicit host is not present, then MH checks for a bang to indicate
+** an explicit UUCP-style address.  If so, this is noted.  If not, the host is
+** defaulted, typically to the local host.  The lack of an explict host is
+** also noted.
+**
+** If an explicit 822-style host is present, then MH checks to see if it
+** can expand this to the official name for the host.  If the hostname is
+** unknown, the address is so typed.
+**
+** To summarize, when we're all done, here's what MH knows about the address:
+**
+** DUMB - type: local, uucp, or network
+**              host:  not locally defaulted, not explicitly expanded
+**              everything else
+**
+** other - type: local, uucp, network, unknown
+**               everything else
+*/
 
 
 static int  ingrp = 0;
@@ -77,8 +77,8 @@ extern boolean  username_extension_masquerading;  /* defined in mts.c */
 
 
 /*
- * external prototypes
- */
+** external prototypes
+*/
 char *getusername (void);
 
 
@@ -262,7 +262,7 @@ mnfree (struct mailname *mp)
 #define empty(s) ((s) ? (s) : "")
 
 char *
-auxformat (struct mailname *mp, int extras)
+adrformat (struct mailname *mp)
 {
        static char addr[BUFSIZ];
        static char buffer[BUFSIZ];
@@ -281,9 +281,6 @@ auxformat (struct mailname *mp, int extras)
 #endif /* not BANG */
                snprintf (addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox);
 
-       if (!extras)
-               return addr;
-
        if (mp->m_pers || mp->m_path) {
                if (mp->m_note)
                        snprintf (buffer, sizeof(buffer), "%s %s <%s>",
@@ -302,65 +299,6 @@ auxformat (struct mailname *mp, int extras)
 }
 
 
-/*
- * address specific "sprintf"
- */
-
-char *
-adrsprintf (char *username, char *domain)
-{
-       int snprintf_return;
-       static char addr[BUFSIZ];
-
-       if (username == NULL)
-               username = getusername();
-
-       if (username_extension_masquerading) {
-               /* mts.conf contains "masquerade:[...]username_extension[...]",
-                * so tack on the value of the $USERNAME_EXTENSION environment
-                * variable, if set, to username.
-                */
-               char* extension = getenv("USERNAME_EXTENSION");
-               static char username_with_extension[BUFSIZ];
-
-               if (extension != NULL && *extension != '\0') {
-                       snprintf_return = snprintf(username_with_extension,
-                               sizeof(username_with_extension),
-                               "%s%s", username, extension);
-
-                       if (snprintf_return < 0 ||
-                               snprintf_return >= sizeof(username_with_extension))
-                               adios(NULL, "snprintf() error writing username (%d chars) and"
-                                         " $USERNAME_EXTENSION (%d chars) to array of BUFSIZ (%d)"
-                                         " chars",
-                                         strlen(username), strlen(extension), BUFSIZ);
-
-                       username = username_with_extension;
-               }
-       }
-
-#ifdef REALLYDUMB
-       return username;
-#endif
-
-       if (domain == NULL)
-               domain = LocalName();
-
-#ifndef BANG
-       snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain);
-#else /* BANG */
-       snprintf_return = snprintf (addr, sizeof(addr), "%s!%s", domain, username);
-#endif /* BANG */
-
-       if (snprintf_return < 0 || snprintf_return >= sizeof(addr))
-               adios(NULL, "snprintf() error writing username (%d chars), domain (%d"
-                         " chars), and 1 separator char to array of BUFSIZ (%d) chars",
-                         strlen(username), strlen(domain), BUFSIZ);
-
-       return addr;
-}
-
-
 #define W_NIL   0x0000
 #define W_MBEG  0x0001
 #define W_MEND  0x0002
@@ -371,8 +309,8 @@ adrsprintf (char *username, char *domain)
 #define WBITS   "\020\01MBEG\02MEND\03HBEG\04HEND"
 
 /*
- * Check if this is my address
- */
+** Check if this is my address
+*/
 
 int
 ismymbox (struct mailname *np)
@@ -387,9 +325,9 @@ ismymbox (struct mailname *np)
        static struct mailname mq={NULL};
 
        /*
-        * If this is the first call, initialize
-        * list of alternate mailboxes.
-        */
+       ** If this is the first call, initialize
+       ** list of alternate mailboxes.
+       */
        if (am == NULL) {
                mq.m_next = NULL;
                mq.m_mbox = getusername ();
@@ -459,9 +397,9 @@ local_test: ;
        }
 
        /*
-        * Now scan through list of alternate
-        * mailboxes, and check for a match.
-        */
+       ** Now scan through list of alternate
+       ** mailboxes, and check for a match.
+       */
        for (mp = &mq; mp->m_next;) {
                mp = mp->m_next;
                if (!np->m_mbox)
@@ -521,15 +459,15 @@ local_test: ;
 
 
 /*
- * Moved from hosts.c -- find out the official name of a host
- */
+** Moved from hosts.c -- find out the official name of a host
+*/
 
 /*
- * In the SendMail world, we really don't know what the valid
- * hosts are.  We could poke around in the sendmail.cf file, but
- * that still isn't a guarantee.  As a result, we'll say that
- * everything is a valid host, and let SendMail worry about it.
- */
+** In the SendMail world, we really don't know what the valid
+** hosts are.  We could poke around in the sendmail.cf file, but
+** that still isn't a guarantee.  As a result, we'll say that
+** everything is a valid host, and let SendMail worry about it.
+*/
 
 #include <h/mts.h>
 #include <netdb.h>