X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fsend.c;h=043e05ed3bd29f17b2118d650827c3e1e0e19633;hp=91f1c168cfb5fe202d8f3e3d36363a7e29c2ead2;hb=ced6090a330d3d83d0bce709f756aa3d7d65fea4;hpb=a485ed478abbd599d8c9aab48934e7a26733ecb1 diff --git a/uip/send.c b/uip/send.c index 91f1c16..043e05e 100644 --- a/uip/send.c +++ b/uip/send.c @@ -1,10 +1,10 @@ /* - * send.c -- send a composed message - * - * 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. - */ +** send.c -- send a composed message +** +** 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 #include @@ -17,100 +17,79 @@ static struct swit switches[] = { { "alias aliasfile", 0 }, #define DEBUGSW 1 { "debug", -5 }, -#define DRAFTSW 2 - { "draft", 0 }, -#define DFOLDSW 3 - { "draftfolder +folder", 6 }, -#define DMSGSW 4 - { "draftmessage msg", 6 }, -#define NDFLDSW 5 - { "nodraftfolder", 0 }, -#define FILTSW 6 +#define FILTSW 2 { "filter filterfile", 0 }, -#define NFILTSW 7 +#define NFILTSW 3 { "nofilter", 0 }, -#define FRMTSW 8 +#define FRMTSW 4 { "format", 0 }, -#define NFRMTSW 9 +#define NFRMTSW 5 { "noformat", 0 }, -#define FORWSW 10 +#define FORWSW 6 { "forward", 0 }, -#define NFORWSW 11 +#define NFORWSW 7 { "noforward", 0 }, -#define MIMESW 12 +#define MIMESW 8 { "mime", 0 }, -#define NMIMESW 13 +#define NMIMESW 9 { "nomime", 0 }, -#define MSGDSW 14 +#define MSGDSW 10 { "msgid", 0 }, -#define NMSGDSW 15 +#define NMSGDSW 11 { "nomsgid", 0 }, -#define PUSHSW 16 +#define PUSHSW 12 { "push", 0 }, -#define NPUSHSW 17 +#define NPUSHSW 13 { "nopush", 0 }, -#define SPLITSW 18 - { "split seconds", 0 }, -#define UNIQSW 19 +#define UNIQSW 14 { "unique", -6 }, -#define NUNIQSW 20 +#define NUNIQSW 15 { "nounique", -8 }, -#define VERBSW 21 +#define VERBSW 16 { "verbose", 0 }, -#define NVERBSW 22 +#define NVERBSW 17 { "noverbose", 0 }, -#define WATCSW 23 +#define WATCSW 18 { "watch", 0 }, -#define NWATCSW 24 +#define NWATCSW 19 { "nowatch", 0 }, -#define WIDTHSW 25 +#define WIDTHSW 20 { "width columns", 0 }, -#define VERSIONSW 26 +#define VERSIONSW 21 { "version", 0 }, -#define HELPSW 27 +#define HELPSW 22 { "help", 0 }, -#define BITSTUFFSW 28 +#define BITSTUFFSW 23 { "dashstuffing", -12 }, -#define NBITSTUFFSW 29 +#define NBITSTUFFSW 24 { "nodashstuffing", -14 }, -#define MAILSW 30 +#define MAILSW 25 { "mail", -4 }, -#define SAMLSW 31 +#define SAMLSW 26 { "saml", -4 }, -#define SENDSW 32 +#define SENDSW 27 { "send", -4 }, -#define SOMLSW 33 +#define SOMLSW 28 { "soml", -4 }, -#define CLIESW 34 +#define CLIESW 29 { "client host", -6 }, -#define SERVSW 35 +#define SERVSW 30 { "server host", 6 }, -#define SNOOPSW 36 +#define SNOOPSW 31 { "snoop", 5 }, -#define ATTACHSW 40 +#define ATTACHSW 32 { "attach", 6 }, -#define ATTACHFORMATSW 41 +#define ATTACHFORMATSW 33 { "attachformat", 7 }, -#define PORTSW 42 +#define PORTSW 34 { "port server-port-name/number" , 4 }, { NULL, 0 } }; -static struct swit anyl[] = { -#define NOSW 0 - { "no", 0 }, -#define YESW 1 - { "yes", 0 }, -#define LISTDSW 2 - { "list", 0 }, - { NULL, 0 } -}; - extern int debugsw; /* from sendsbr.c */ extern int forwsw; extern int inplace; extern int pushsw; -extern int splitsw; extern int unique; extern int verbsw; @@ -123,9 +102,9 @@ int main (int argc, char **argv) { int msgp = 0, distsw = 0, vecp = 1; - int isdf = 0, mime = 0; + int mime = 0; int msgnum, status; - char *cp, *dfolder = NULL, *maildir = NULL; + char *cp, *maildir = NULL; char buf[BUFSIZ], **ap, **argp, **arguments; char *msgs[MAXARGS], *vec[MAXARGS]; struct msgs *mp; @@ -160,35 +139,15 @@ main (int argc, char **argv) adios (NULL, "-%s unknown\n", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [file] [switches]", invo_name); + snprintf (buf, sizeof(buf), + "%s [file] [switches]", + invo_name); print_help (buf, switches, 1); done (1); case VERSIONSW: print_version(invo_name); done (1); - case DRAFTSW: - msgs[msgp++] = draft; - continue; - - case DFOLDSW: - if (dfolder) - adios (NULL, "only one draft folder at a time!"); - if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); - dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp, - *cp != '@' ? TFOLDER : TSUBCWF); - continue; - case DMSGSW: - if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", argp[-2]); - msgs[msgp++] = cp; - continue; - case NDFLDSW: - dfolder = NULL; - isdf = NOTOK; - continue; - case PUSHSW: pushsw++; continue; @@ -196,11 +155,6 @@ main (int argc, char **argv) pushsw = 0; continue; - case SPLITSW: - if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1) - adios (NULL, "missing argument to %s", argp[-2]); - continue; - case UNIQSW: unique++; continue; @@ -290,88 +244,51 @@ main (int argc, char **argv) } /* - * check for "Aliasfile:" profile entry - */ + ** check for "Aliasfile:" profile entry + */ if ((cp = context_find ("Aliasfile"))) { char *dp = NULL; - for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) { + for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; + ap++) { vec[vecp++] = "-alias"; vec[vecp++] = *ap; } } - if (dfolder == NULL) { - if (msgp == 0) { -#ifdef WHATNOW - if ((cp = getenv ("mhdraft")) && *cp) { - msgs[msgp++] = cp; - goto go_to_it; - } -#endif /* WHATNOW */ - msgs[msgp++] = getcpy (m_draft (NULL, NULL, 1, &isdf)); - if (stat (msgs[0], &st) == NOTOK) - adios (msgs[0], "unable to stat draft file"); - cp = concat ("Use \"", msgs[0], "\"? ", NULL); - for (status = LISTDSW; status != YESW;) { - if (!(argp = getans (cp, anyl))) - done (1); - switch (status = smatch (*argp, anyl)) { - case NOSW: - done (0); - case YESW: - break; - case LISTDSW: - showfile (++argp, msgs[0]); - break; - default: - advise (NULL, "say what?"); - break; - } - } - } else { - for (msgnum = 0; msgnum < msgp; msgnum++) - msgs[msgnum] = getcpy (m_maildir (msgs[msgnum])); - } - } else { - if (!context_find ("path")) - free (path ("./", TFOLDER)); - - if (!msgp) - msgs[msgp++] = "cur"; - maildir = m_maildir (dfolder); - - if (chdir (maildir) == NOTOK) - adios (maildir, "unable to change directory to"); - - /* read folder and create message structure */ - if (!(mp = folder_read (dfolder))) - adios (NULL, "unable to read folder %s", dfolder); - - /* check for empty folder */ - if (mp->nummsg == 0) - adios (NULL, "no messages in %s", dfolder); - - /* parse all the message ranges/sequences and set SELECTED */ - for (msgnum = 0; msgnum < msgp; msgnum++) - if (!m_convert (mp, msgs[msgnum])) - done (1); - seq_setprev (mp); /* set the previous-sequence */ - - for (msgp = 0, msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected (mp, msgnum)) { - msgs[msgp++] = getcpy (m_name (msgnum)); - unset_exists (mp, msgnum); - } - } + if (!context_find ("path")) + free (path ("./", TFOLDER)); + + if (!msgp) + msgs[msgp++] = "cur"; + maildir = m_maildir (draftfolder); + + if (chdir (maildir) == NOTOK) + adios (maildir, "unable to change directory to"); + + /* read folder and create message structure */ + if (!(mp = folder_read (draftfolder))) + adios (NULL, "unable to read draft folder %s", draftfolder); - mp->msgflags |= SEQMOD; - seq_save (mp); + /* check for empty folder */ + if (mp->nummsg == 0) + adios (NULL, "no messages in draft folder %s", draftfolder); + + /* parse all the message ranges/sequences and set SELECTED */ + for (msgnum = 0; msgnum < msgp; msgnum++) + if (!m_convert (mp, msgs[msgnum])) + done (1); + seq_setprev (mp); /* set the previous-sequence */ + + for (msgp = 0, msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { + if (is_selected (mp, msgnum)) { + msgs[msgp++] = getcpy (m_name (msgnum)); + unset_exists (mp, msgnum); + } } -#ifdef WHATNOW -go_to_it: -#endif /* WHATNOW */ + mp->msgflags |= SEQMOD; + seq_save (mp); if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0) if ((cp = context_find ("signature")) && *cp) @@ -379,8 +296,8 @@ go_to_it: #ifdef UCI else { snprintf (buf, sizeof(buf), "%s/.signature", mypath); - if ((fp = fopen (buf, "r")) != NULL - && fgets (buf, sizeof buf, fp) != NULL) { + if ((fp = fopen (buf, "r")) != NULL && + fgets(buf, sizeof buf, fp) != NULL) { fclose (fp); if (cp = strchr (buf, '\n')) *cp = 0; @@ -412,9 +329,11 @@ go_to_it: && errno != EISREMOTE #endif /* EISREMOTE */ ) - adios (distfile, "unable to link %s to", altmsg); + adios (distfile, "unable to link %s to", + altmsg); free (distfile); - distfile = getcpy (m_mktemp2(NULL, invo_name, NULL, NULL)); + distfile = getcpy (m_mktemp2(NULL, invo_name, + NULL, NULL)); { int in, out; struct stat st; @@ -422,7 +341,9 @@ go_to_it: if ((in = open (altmsg, O_RDONLY)) == NOTOK) adios (altmsg, "unable to open"); fstat(in, &st); - if ((out = creat (distfile, (int) st.st_mode & 0777)) == NOTOK) + if ((out = creat (distfile, + (int) st.st_mode & 0777)) + == NOTOK) adios (distfile, "unable to write"); cpydata (in, out, altmsg, distfile); close (in); @@ -447,7 +368,7 @@ go_to_it: for (msgnum = 0; msgnum < msgp; msgnum++) { switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1, attach, - attachformat)) { + attachformat)) { case DONE: done (++status); case NOTOK: