- int i, isdf = 0;
- int anot = 0, inplace = 1;
- int nedit = 0, nwhat = 0;
- char *cp, *cwd, *dp, *maildir, *file = NULL;
- char *folder = NULL, *msg = NULL, *dfolder = NULL;
- char *dmsg = NULL, *ed = NULL, drft[BUFSIZ], buf[BUFSIZ];
- char **argp, **arguments;
- struct msgs *mp = NULL;
- struct stat st;
- FILE *in;
-
-#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] [msg] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (0);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case GROUPSW:
- groupreply++;
- continue;
- case NGROUPSW:
- groupreply = 0;
- continue;
-
- case ANNOSW:
- anot++;
- continue;
- case NANNOSW:
- anot = 0;
- continue;
-
- case CCSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- docc (cp, 1);
- continue;
- case NCCSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- docc (cp, 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 FCCSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- dp = NULL;
- if (*cp == '@')
- cp = dp = path (cp + 1, TSUBCWF);
- if (fcc)
- fcc = add (", ", fcc);
- fcc = add (cp, fcc);
- if (dp)
- free (dp);
- 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 (mhlreply));
- mime = 0;
- 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 QURYSW:
- querysw++;
- continue;
- case NQURYSW:
- querysw = 0;
- continue;
-
- case WIDTHSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if ((outputlinelen = atoi (cp)) < 10)
- adios (NULL, "impossible width %d", outputlinelen);
- 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;
- }