- switch (smatch (*argp, aleqs)) {
- case DISPSW:
- /* display the message being replied to, or distributed */
- if (msgnam)
- showfile (++argp, msgnam);
- else
- advise (NULL, "no alternate message to display");
- break;
-
- case BUILDMIMESW:
- /* Translate MIME composition file */
- buildfile (++argp, drft);
- break;
-
- case EDITSW:
- /* Call an editor on the draft file */
- if (*++argp)
- ed = *argp++;
- if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK)
- done (1);
- break;
-
- case LISTSW:
- /* display the draft file */
- showfile (++argp, drft);
- break;
-
- case WHOMSW:
- /* Check to whom the draft would be sent */
- whomfile (++argp, drft);
- break;
-
- case QUITSW:
- /* Quit, and possibly delete the draft */
- if (*++argp && (*argp[0] == 'd' ||
- ((*argp)[0] == '-' && (*argp)[1] == 'd'))) {
- removefile (drft);
- } else {
- if (stat (drft, &st) != NOTOK)
- advise (NULL, "draft left on %s", drft);
- }
- done (1);
-
- case DELETESW:
- /* Delete draft and exit */
- removefile (drft);
- done (1);
-
- case PUSHSW:
- /* Send draft in background */
- if (sendfile (++argp, drft, 1))
- done (1);
- break;
-
- case SENDSW:
- /* Send draft */
- sendfile (++argp, drft, 0);
- break;
-
- case REFILEOPT:
- /* Refile the draft */
- if (refile (++argp, drft) == 0)
- done (0);
- break;
-
- case CDCMDSW:
- /* Change the working directory for attachments
- *
- * Run the directory through the user's shell so that
- * we can take advantage of any syntax that the user
- * is accustomed to. Read back the absolute path.
- */
-
- if (*++argp == (char *)0) {
- (void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
- }
- else if (strlen(*argp) >= BUFSIZ) {
- adios((char *)0, "arguments too long");
- }
- else {
- (void)sprintf(buf, "$SHELL -c \"cd %s;cd %s;pwd\"", cwd, *argp);
- }
- if ((f = popen(buf, "r")) != (FILE *)0) {
- fgets(cwd, sizeof (cwd), f);
-
- if (strchr(cwd, '\n') != (char *)0)
- *strchr(cwd, '\n') = '\0';
-
- pclose(f);
- }
- else {
- advise("popen", "could not get directory");
- }
-
- break;
-
- case PWDCMDSW:
- /* Print the working directory for attachments */
- printf("%s\n", cwd);
- break;
-
- case LSCMDSW:
- /* List files in the current attachment working directory
- *
- * Use the user's shell so that we can take advantage of any
- * syntax that the user is accustomed to.
- */
-
- cp = buf + sprintf(buf, "$SHELL -c \" cd %s;ls", cwd);
-
- while (*++argp != (char *)0) {
- if (cp + strlen(*argp) + 2 >= buf + BUFSIZ)
- adios((char *)0, "arguments too long");
-
- cp += sprintf(cp, " %s", *argp);
- }
-
- (void)strcat(cp, "\"");
- (void)system(buf);
- break;
-
- case ALISTCMDSW:
- /*
- * List attachments on current draft. Options are:
- *
- * -l long listing (full path names)
- * -n numbers listing
- */
-
- if (attach == (char *)0) {
- advise((char *)0, "can't list because no header field name was given.");
- break;
- }