- int msgp = 0, anot = 0, inplace = 1, mime = 0;
- int issue = 0, volume = 0, dashstuff = 0;
- int nedit = 0, nwhat = 0, i, in;
- int out, isdf = 0, msgnum;
- char *cp, *cwd, *maildir, *dfolder = NULL;
- char *dmsg = NULL, *digest = NULL, *ed = NULL;
- char *file = NULL, *filter = NULL, *folder = NULL;
- char *form = NULL, buf[BUFSIZ], value[10];
- char **argp, **arguments, *msgs[MAXARGS];
- struct stat st;
-
-#ifdef MHE
- int buildsw = 0;
-#endif /* MHE */
-
-#ifdef LOCALE
- setlocale(LC_ALL, "");
-#endif
- invo_name = r1bindex (argv[0], '/');
-
- /* read user profile/context */
- context_read();
-
- arguments = getarguments (invo_name, argc, argv, 1);
- argp = arguments;
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, switches)) {
- case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case ANNOSW:
- anot++;
- continue;
- case NANNOSW:
- anot = 0;
- continue;
-
- case EDITRSW:
- if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
- continue;
-
- case WHATSW:
- if (!(whatnowproc = *argp++) || *whatnowproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- nwhat = 0;
- continue;
-#ifdef MHE
- case BILDSW:
- buildsw++; /* fall... */
-#endif /* MHE */
- case NWHATSW:
- nwhat++;
- continue;
-
- case FILESW:
- if (file)
- adios (NULL, "only one file at a time!");
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- file = path (cp, TFILE);
- continue;
- case FILTSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- filter = getcpy (etcpath (cp));
- mime = 0;
- continue;
- case FORMSW:
- if (!(form = *argp++) || *form == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
-
- case FRMTSW:
- filter = getcpy (etcpath (mhlforward));
- continue;
- case NFRMTSW:
- filter = NULL;
- continue;
-
- case INPLSW:
- inplace++;
- continue;
- case NINPLSW:
- inplace = 0;
- continue;
-
- case MIMESW:
- mime++;
- filter = NULL;
- continue;
- case NMIMESW:
- mime = 0;
- continue;
-
- case DGSTSW:
- if (!(digest = *argp++) || *digest == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- mime = 0;
- continue;
- case ISSUESW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((issue = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- continue;
- case VOLUMSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((volume = atoi (cp)) < 1)
- adios (NULL, "bad argument %s %s", argp[-2], cp);
- 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 (dmsg)
- adios (NULL, "only one draft message at a time!");
- if (!(dmsg = *argp++) || *dmsg == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case NDFLDSW:
- dfolder = NULL;
- isdf = NOTOK;
- continue;
-
- case BITSTUFFSW:
- dashstuff = 1; /* trinary logic */
- continue;
- case NBITSTUFFSW:
- dashstuff = -1; /* trinary logic */
- continue;
- }
- }
- if (*cp == '+' || *cp == '@') {
- if (folder)
- adios (NULL, "only one folder at a time!");
- else
- folder = pluspath (cp);
- } else {
- msgs[msgp++] = cp;
- }
- }
-
- cwd = getcpy (pwd ());
-
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
- if (file && (msgp || folder))
- adios (NULL, "can't mix files and folders/msgs");
-
-try_it_again:
-
-#ifdef MHE
- strncpy (drft, buildsw ? m_maildir ("draft")
- : m_draft (dfolder, NULL, NOUSE, &isdf), sizeof(drft));
-
- /* Check if a draft already exists */
- if (!buildsw && stat (drft, &st) != NOTOK) {
-#else
- strncpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf), sizeof(drft));
-
- /* Check if a draft already exists */
- if (stat (drft, &st) != NOTOK) {
-#endif /* MHE */
- printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
- for (i = LISTDSW; i != YESW;) {
- if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
- done (1);
- switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
- case NOSW:
- done (0);
- case NEWSW:
- dmsg = NULL;
- goto try_it_again;
- case YESW:
- break;
- case LISTDSW:
- showfile (++argp, drft);
- break;
- case REFILSW:
- if (refile (++argp, drft) == 0)
- i = YESW;
- break;
- default:
- advise (NULL, "say what?");
- break;
- }
+ int msgp = 0, anot = 0;
+ int issue = 0, volume = 0;
+ int in;
+ int out, msgnum;
+ char *cp, *cwd, *maildir;
+ char *digest = NULL, *ed = NULL;
+ char *folder = NULL;
+ char *form = NULL, buf[BUFSIZ], value[10];
+ char **argp, **arguments, *msgs[MAXARGS];
+ char *fmtstr;
+ int buildsw = 0;
+
+ setlocale(LC_ALL, "");
+ invo_name = mhbasename(argv[0]);
+
+ /* read user profile/context */
+ context_read();
+
+ arguments = getarguments(invo_name, argc, argv, 1);
+ argp = arguments;
+
+ while ((cp = *argp++)) {
+ if (*cp == '-') {
+ switch (smatch(++cp, switches)) {
+ case AMBIGSW:
+ ambigsw(cp, switches);
+ done(1);
+ case UNKWNSW:
+ adios(NULL, "-%s unknown", cp);
+
+ case HELPSW:
+ snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ done(1);
+ case VERSIONSW:
+ print_version(invo_name);
+ done(1);
+
+ case ANNOSW:
+ anot++;
+ continue;
+ case NANNOSW:
+ anot = 0;
+ continue;
+
+ case EDITRSW:
+ if (!(ed = *argp++) || *ed == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ continue;
+
+ case WHATSW:
+ if (!(whatnowproc = *argp++) ||
+ *whatnowproc == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ continue;
+
+ case BILDSW:
+ buildsw++;
+ continue;
+
+ case FORMSW:
+ if (!(form = *argp++) || *form == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ continue;
+
+ case DGSTSW:
+ if (!(digest = *argp++) || *digest == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ //mime = 0;
+ continue;
+ case ISSUESW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ if ((issue = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s",
+ argp[-2], cp);
+ continue;
+ case VOLUMSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ if ((volume = atoi(cp)) < 1)
+ adios(NULL, "bad argument %s %s",
+ argp[-2], cp);
+ continue;
+ }
+ }
+ if (*cp == '+' || *cp == '@') {
+ if (folder)
+ adios(NULL, "only one folder at a time!");
+ else
+ folder = getcpy(expandfol(cp));
+ } else {
+ msgs[msgp++] = cp;
+ }