X("prompt string", 4, PRMPTSW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
- X("attach header-field-name", 0, ATTACHSW) \
- X("noattach", 0, NOATTACHSW) \
+ X("attach header-field-name", -6, ATTACHSW) \
+ X("noattach", -8, NOATTACHSW) \
+
#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(WHATNOW);
char buf[BUFSIZ], prompt[BUFSIZ];
char **argp, **arguments;
struct stat st;
- char *attach = NMH_ATTACH_HEADER;/* attachment header field name */
char cwd[PATH_MAX + 1]; /* current working directory */
char file[PATH_MAX + 1]; /* file name buffer */
char shell[PATH_MAX + 1]; /* shell response buffer */
continue;
case ATTACHSW:
- if (!(attach = *argp++) || *attach == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ advise(NULL, "The -attach switch is deprecated");
continue;
case NOATTACHSW:
- attach = NULL;
+ advise(NULL, "The -noattach switch is deprecated");
continue;
}
}
* -n numbers listing
*/
- if (attach == (char *)0) {
- advise((char *)0, "can't list because no header field name was given.");
- break;
- }
-
l = (char *)0;
n = 0;
advise((char *)0, "usage is alist [-ln].");
else
- annolist(drft, attach, l, n);
+ annolist(drft, ATTACH_FIELD, l, n);
break;
int verbose = 0;
char **ap;
- if (attach == (char *)0) {
- advise((char *)0, "can't attach because no header field name was given.");
- break;
- }
-
for (ap = argp+1; *ap; ++ap) {
if (strcmp(*ap, "-v") == 0) {
++argp;
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
while (fgets(shell, sizeof (shell), f) != (char *)0) {
- char *build_directive;
+ char *ctype;
*(strchr(shell, '\n')) = '\0';
if (*shell == '/') {
- (void)annotate(drft, attach, shell, 1, 0, -2, 1);
- if (verbose) {
- build_directive =
- construct_build_directive (shell, NULL, 1);
- }
+ strncpy(file, shell, sizeof(file));
+ file[sizeof(file) - 1] = '\0';
} else {
- (void)sprintf(file, "%s/%s", cwd, shell);
- (void)annotate(drft, attach, file, 1, 0, -2, 1);
- if (verbose) {
- build_directive =
- construct_build_directive (file, NULL, 1);
- }
+ snprintf(file, sizeof(file), "%s/%s", cwd, shell);
+ }
+
+ annotate(drft, ATTACH_FIELD, file, 1, 0, -2, 1);
+ if (verbose) {
+ ctype = mime_type(file);
}
if (verbose) {
- printf ("%s", build_directive);
- free (build_directive);
+ printf ("Attaching %s as a %s", file, ctype);
+ free (ctype);
}
}
* Detach files from current draft.
*/
- if (attach == (char *)0) {
- advise((char *)0, "can't detach because no header field name was given.");
- break;
- }
-
/*
* Scan the arguments for a -n. Mixed file names and numbers aren't allowed,
* so this catches a -n anywhere in the argument list.
if (**arguments != '\0') {
n = atoi(*arguments);
- (void)annotate(drft, attach, (char *)0, 1, 0, n, 1);
+ annotate(drft, ATTACH_FIELD, (char *)0, 1, 0, n, 1);
for (argp = arguments + 1; *argp != (char *)0; argp++) {
if (atoi(*argp) > n) {
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
while (fgets(shell, sizeof (shell), f) != (char *)0) {
*(strchr(shell, '\n')) = '\0';
- (void)annotate(drft, attach, shell, 1, 0, 0, 1);
+ annotate(drft, ATTACH_FIELD, shell, 1, 0, 0, 1);
}
pclose(f);
} else {