- /*
- * Make sure these are defined. In particular, we need
- * vec[1] to be NULL, in case "arg" is NULL below. It
- * doesn't matter what is the value of vec[0], but we
- * set it to NULL, to help catch "off-by-one" errors.
- */
- vec[0] = NULL;
- vec[1] = NULL;
-
- /*
- * Temporarily copy arg to vec, since the brkstring() call in
- * getarguments() will wipe it out before it is merged in.
- * Also, we skip the first element of vec, since getarguments()
- * skips it. Then we count the number of arguments
- * copied. The value of "n" will be one greater than
- * this in order to simulate the standard argc/argv.
- */
- if (arg) {
- char **bp;
-
- copyip (arg, vec+1, MAXARGS-1);
- bp = vec+1;
- while (*bp++)
- n++;
- }
-
- /*
- * Merge any arguments from command line (now in vec)
- * and arguments from profile.
- */
- arguments = getarguments (sp, n, vec, 1);
- argp = arguments;
-
- debugsw = 0;
- forwsw = 1;
- inplace = 1;
- unique = 0;
-
- altmsg = NULL;
- annotext = NULL;
- distfile = NULL;
-
- vecp = 1; /* we'll get the zero'th element later */
- vec[vecp++] = "-library";
- vec[vecp++] = getcpy (m_maildir (""));
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, sendswitches)) {
- case AMBIGSW:
- ambigsw (cp, sendswitches);
- return;
- case UNKWNSW:
- advise (NULL, "-%s unknown\n", cp);
- return;
-
- case SHELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", sp);
- print_help (buf, sendswitches, 1);
- return;
- case SVERSIONSW:
- print_version (invo_name);
- return;
-
- case SPSHSW:
- pushed++;
- continue;
- case NSPSHSW:
- pushed = 0;
- continue;
-
- case SPLITSW:
- if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1) {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- continue;
-
- case UNIQSW:
- unique++;
- continue;
- case NUNIQSW:
- unique = 0;
- continue;
- case FORWSW:
- forwsw++;
- continue;
- case NFORWSW:
- forwsw = 0;
- continue;
-
- case VERBSW:
- verbsw++;
- vec[vecp++] = --cp;
- continue;
- case NVERBSW:
- verbsw = 0;
- vec[vecp++] = --cp;
- continue;
-
- case DEBUGSW:
- debugsw++; /* fall */
- case NFILTSW:
- case FRMTSW:
- case NFRMTSW:
- case BITSTUFFSW:
- case NBITSTUFFSW:
- case MIMESW:
- case NMIMESW:
- case MSGDSW:
- case NMSGDSW:
- case WATCSW:
- case NWATCSW:
- case MAILSW:
- case SAMLSW:
- case SSNDSW:
- case SOMLSW:
- case SNOOPSW:
- case SASLSW:
- case TLSSW:
- vec[vecp++] = --cp;
- continue;
-
- case ALIASW:
- case FILTSW:
- case WIDTHSW:
- case CLIESW:
- case SERVSW:
- case SASLMECHSW:
- case USERSW:
- case PORTSW:
- vec[vecp++] = --cp;
- if (!(cp = *argp++) || *cp == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- vec[vecp++] = cp;
- continue;
-
- case SDRFSW:
- case SDRMSW:
- if (!(cp = *argp++) || *cp == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- case SNDRFSW:
- continue;
-
- case SNDATTACHSW:
- if (!(attach = *argp++) || *attach == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- continue;
-
- case SNDATTACHFORMAT:
- if (! *argp || **argp == '-')
- adios (NULL, "missing argument to %s", argp[-1]);
- else {
- attachformat = atoi (*argp);
- if (attachformat < 0 ||
- attachformat > ATTACHFORMATS - 1) {
- advise (NULL, "unsupported attachformat %d",
- attachformat);
- continue;
- }
- }
- ++argp;
- continue;
- }
- }
- advise (NULL, "usage: %s [switches]", sp);
- return;
- }
-
- /* allow Aliasfile: profile entry */
- if ((cp = context_find ("Aliasfile"))) {
- char **ap, *dp;
-
- dp = getcpy (cp);
- for (ap = brkstring (dp, " ", "\n"); ap && *ap; ap++) {
- vec[vecp++] = "-alias";
- vec[vecp++] = *ap;
- }
- }
-
- if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
- if ((cp = context_find ("signature")) && *cp)
- m_putenv ("SIGNATURE", cp);
-#ifdef UCI
- else {
- snprintf (buf, sizeof(buf), "%s/.signature", mypath);
- if ((fp = fopen (buf, "r")) != NULL
- && fgets (buf, sizeof(buf), fp) != NULL) {
- fclose (fp);
- if (cp = strchr (buf, '\n'))
- *cp = 0;
- m_putenv ("SIGNATURE", buf);
- }
+ /*
+ ** Make sure these are defined. In particular, we need
+ ** vec[1] to be NULL, in case "arg" is NULL below. It
+ ** doesn't matter what is the value of vec[0], but we
+ ** set it to NULL, to help catch "off-by-one" errors.
+ */
+ vec[0] = NULL;
+ vec[1] = NULL;
+
+ /*
+ ** Temporarily copy arg to vec, since the brkstring() call in
+ ** getarguments() will wipe it out before it is merged in.
+ ** Also, we skip the first element of vec, since getarguments()
+ ** skips it. Then we count the number of arguments
+ ** copied. The value of "n" will be one greater than
+ ** this in order to simulate the standard argc/argv.
+ */
+ if (arg) {
+ char **bp;
+
+ copyip(arg, vec+1, MAXARGS-1);
+ bp = vec+1;
+ while (*bp++)
+ n++;