- int anot = 0, inplace = 1, nedit = 0;
- int nwhat = 0, i, in, isdf = 0, out;
- char *cp, *cwd, *maildir, *msgnam, *dfolder = NULL;
- char *dmsg = NULL, *ed = NULL, *file = NULL, *folder = NULL;
- char *form = NULL, *msg = NULL, buf[BUFSIZ], drft[BUFSIZ];
- char **argp, **arguments;
- struct msgs *mp = NULL;
- struct stat st;
-
-#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 (1);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case ANNOSW:
- anot++;
- continue;
- case NANNOSW:
- anot = 0;
- continue;
+ int anot = 0;
+ int in, out;
+ char *cp, *cwd, *maildir, *msgnam;
+ char *ed = NULL, *folder = NULL;
+ char *form = NULL, *msg = NULL, buf[BUFSIZ], drft[BUFSIZ];
+ char **argp, **arguments;
+ struct msgs *mp = NULL;
+ char *fmtstr;
+
+ 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);
+ exit(EX_USAGE);
+ case UNKWNSW:
+ adios(EX_USAGE, NULL, "-%s unknown", cp);
+
+ case HELPSW:
+ snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
+ print_help(buf, switches, 1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
+
+ case VERSIONSW:
+ print_version(invo_name);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
+
+ case ANNOSW:
+ anot++;
+ continue;
+ case NANNOSW:
+ anot = 0;
+ continue;
+
+ case EDITRSW:
+ if (!(ed = *argp++) || *ed == '-')
+ adios(EX_USAGE, NULL, "missing argument to %s",
+ argp[-2]);
+ continue;
+
+ case WHATSW:
+ if (!(whatnowproc = *argp++) || *whatnowproc == '-') {
+ adios(EX_USAGE, NULL, "missing argument to %s",
+ argp[-2]);
+ }
+ continue;
+
+ case FORMSW:
+ if (!(form = *argp++) || *form == '-') {
+ adios(EX_USAGE, NULL, "missing argument to %s",
+ argp[-2]);
+ }
+ continue;
+ }
+ }
+ if (*cp == '+' || *cp == '@') {
+ if (folder) {
+ adios(EX_USAGE, NULL, "only one folder at a time!");
+ } else {
+ folder = getcpy(expandfol(cp));
+ }
+ } else {
+ if (msg) {
+ adios(EX_USAGE, NULL, "only one message at a time!");
+ } else {
+ msg = cp;
+ }
+ }
+ }