]> diplodocus.org Git - nmh/commitdiff
Convert whatnow over to using the new Attach header.
authorKen Hornstein <kenh@pobox.com>
Wed, 22 Jan 2014 20:22:07 +0000 (15:22 -0500)
committerKen Hornstein <kenh@pobox.com>
Wed, 22 Jan 2014 20:22:07 +0000 (15:22 -0500)
Mark the old -attach switches as deprecated (and make them not show
up in help).  Still more documentation cleanup to do.

h/mh.h
man/send.man
man/whatnow.man
test/whatnow/test-attach-detach
uip/attach.c
uip/send.c
uip/whatnowsbr.c

diff --git a/h/mh.h b/h/mh.h
index a47b7c20885c197bb71af05d902f0880f0f18998..999d600ab1e0d691dd3fb9b3a9588a5e8d812d05 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -122,8 +122,6 @@ struct swit {
 
 extern struct swit anoyes[];   /* standard yes/no switches */
 
 
 extern struct swit anoyes[];   /* standard yes/no switches */
 
-#define ATTACHFORMATS 3                /* Number of send attach formats. */
-
 /*
  * general folder attributes
  */
 /*
  * general folder attributes
  */
@@ -359,8 +357,6 @@ typedef struct m_getfld_state *m_getfld_state_t;
 #define LINK   "@"             /* Name of link to file to which you are */
                                /* replying. */
 
 #define LINK   "@"             /* Name of link to file to which you are */
                                /* replying. */
 
-#define NMH_ATTACH_HEADER "Nmh-Attachment"  /* Default header for -attach */
-
 /*
  * credentials management
  */
 /*
  * credentials management
  */
index 83cf19ae7f9d9ed3e7667493bff28ccd59987f87..b7016a41f9cac6f2d1750dc1c59103cc75239e52 100644 (file)
@@ -54,11 +54,6 @@ send \- send a message
 \&...]
 .RB [ \-version ]
 .RB [ \-help ]
 \&...]
 .RB [ \-version ]
 .RB [ \-help ]
-.RB [ \-attach
-.IR header-field-name ]
-.RB [ \-noattach ]
-.RB [ \-attachformat
-.IR 0 " | " 1 " | " 2 ]
 .ad
 .SH DESCRIPTION
 .B Send
 .ad
 .SH DESCRIPTION
 .B Send
index 367a32678d08e769601bfb29d05cb77f08f6c830..3d5806bf1916e5c1b2a096cf2faa048d5f950468 100644 (file)
@@ -21,9 +21,6 @@ whatnow \- prompting front-end for sending messages
 .RI [ file ]
 .RB [ \-version ]
 .RB [ \-help ]
 .RI [ file ]
 .RB [ \-version ]
 .RB [ \-help ]
-.RB [ \-attach
-.IR header-field-name ]
-.RB [ \-noattach ]
 .ad
 .SH DESCRIPTION
 .B Whatnow
 .ad
 .SH DESCRIPTION
 .B Whatnow
@@ -243,7 +240,6 @@ commands for managing MIME attachments.
 .SH DEFAULTS
 .nf
 .RB ` \-prompt "' defaults to \*(lqWhat\ Now?\ \*(rq"
 .SH DEFAULTS
 .nf
 .RB ` \-prompt "' defaults to \*(lqWhat\ Now?\ \*(rq"
-.RB ` \-attach "' defaults to \*(lqNmh-Attachment\*(rq"
 .fi
 .SH BUGS
 If the initial edit fails,
 .fi
 .SH BUGS
 If the initial edit fails,
index 3181f21b53deab3d60d22e77262e77b6346468b7..ba22a19c54235f10139e046608592422f9219687 100755 (executable)
@@ -68,13 +68,13 @@ esac
 # whatnow's exit status is always 1 so that is not a failure
 set +e
 echo "attach $testname_quoted" | \
 # whatnow's exit status is always 1 so that is not a failure
 set +e
 echo "attach $testname_quoted" | \
-  run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
+  run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
 echo "alist" | \
 echo "alist" | \
-  run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
+  run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
 echo "detach $testname_quoted" | \
 echo "detach $testname_quoted" | \
-  run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
+  run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
 echo "alist" | \
 echo "alist" | \
-  run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
+  run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
 set -e
 
 check "$expectederr" "$actualerr"
 set -e
 
 check "$expectederr" "$actualerr"
@@ -84,7 +84,7 @@ if [ "$readline" = 0 ]; then
 cat >"$expected" <<EOF
 whatnow: attach command requires file argument(s).
 whatnow: attach command requires file argument(s).
 cat >"$expected" <<EOF
 whatnow: attach command requires file argument(s).
 whatnow: attach command requires file argument(s).
-#text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+Attaching ${MH_TEST_DIR}/Mail/context as a text/plain
 EOF
 else
 cat >"$expected" <<EOF
 EOF
 else
 cat >"$expected" <<EOF
@@ -93,7 +93,7 @@ whatnow: attach command requires file argument(s).
 at -v
 whatnow: attach command requires file argument(s).
 at -v Mail/context
 at -v
 whatnow: attach command requires file argument(s).
 at -v Mail/context
-#text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
+Attaching ${MH_TEST_DIR}/Mail/context as a text/plain
 quit -delete
 EOF
 fi
 quit -delete
 EOF
 fi
index 2902499706ab536aac55a3b8f76daa808c6ea9bb..e7046fe50cfcb574c75cf81f0eb8e8f9055b6a0c 100644 (file)
@@ -15,6 +15,7 @@ static int get_line(FILE *, char *, size_t);
 static char *get_file_info(const char *, const char *);
 #endif /* MIMETYPEPROC */
 
 static char *get_file_info(const char *, const char *);
 #endif /* MIMETYPEPROC */
 
+#if 0
 int
 attach(char *attachment_header_field_name, char *draft_file_name,
        char *body_file_name, size_t body_file_name_len,
 int
 attach(char *attachment_header_field_name, char *draft_file_name,
        char *body_file_name, size_t body_file_name_len,
@@ -277,6 +278,8 @@ get_line(FILE *draft_file, char *field, size_t field_size)
     return (c);
 }
 
     return (c);
 }
 
+#endif
+
 /*
  * Try to use external command to determine mime type, and possibly
  * encoding.  Caller is responsible for free'ing returned memory.
 /*
  * Try to use external command to determine mime type, and possibly
  * encoding.  Caller is responsible for free'ing returned memory.
@@ -383,6 +386,7 @@ get_file_info(const char *proc, const char *file_name) {
 #endif /* MIMETYPEPROC */
 
 
 #endif /* MIMETYPEPROC */
 
 
+#if 0
 /*
  * Construct an mhbuild directive for the draft file.  This starts
  * with the content type.  Append a file name attribute, and depending
 /*
  * Construct an mhbuild directive for the draft file.  This starts
  * with the content type.  Append a file name attribute, and depending
@@ -590,3 +594,4 @@ construct_build_directive (char *file_name, const char *default_content_type,
 
     return build_directive;
 }
 
     return build_directive;
 }
+#endif
index 31718392d5c002f65b5b08ec2cdca91bb7768f28..3ba82fb55b6af676325b18952fe4743888b0b3ed 100644 (file)
@@ -62,8 +62,8 @@
     X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
     X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
     X("user username", SASLminc(-4), USERSW) \
     X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
     X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
     X("user username", SASLminc(-4), USERSW) \
-    X("attach", 6, ATTACHSW) \
-    X("noattach", 0, NOATTACHSW) \
+    X("attach", -6, ATTACHSW) \
+    X("noattach", -8, NOATTACHSW) \
     X("attachformat", 7, ATTACHFORMATSW) \
     X("port server-port-name/number", 4, PORTSW) \
     X("tls", TLSminc(-3), TLSSW) \
     X("attachformat", 7, ATTACHFORMATSW) \
     X("port server-port-name/number", 4, PORTSW) \
     X("tls", TLSminc(-3), TLSSW) \
index 3010bff08d2ebc5bd5efc31ef4a4557c956341cd..e67ad53a97abe8fcfc91e1b5fd136a6d96b21be8 100644 (file)
@@ -53,8 +53,9 @@
     X("prompt string", 4, PRMPTSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
     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);
 
 #define X(sw, minchars, id) id,
 DEFINE_SWITCH_ENUM(WHATNOW);
@@ -122,7 +123,6 @@ WhatNow (int argc, char **argv)
     char buf[BUFSIZ], prompt[BUFSIZ];
     char **argp, **arguments;
     struct stat st;
     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 */
     char       cwd[PATH_MAX + 1];      /* current working directory */
     char       file[PATH_MAX + 1];     /* file name buffer */
     char       shell[PATH_MAX + 1];    /* shell response buffer */
@@ -197,12 +197,11 @@ WhatNow (int argc, char **argv)
                continue;
 
            case ATTACHSW:
                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:
                continue;
 
            case NOATTACHSW:
-               attach = NULL;
+               advise(NULL, "The -noattach switch is deprecated");
                continue;
            }
        }
                continue;
            }
        }
@@ -360,11 +359,6 @@ WhatNow (int argc, char **argv)
             *   -n     numbers listing
             */
 
             *   -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;
 
            l = (char *)0;
            n = 0;
 
@@ -390,7 +384,7 @@ WhatNow (int argc, char **argv)
                advise((char *)0, "usage is alist [-ln].");
 
            else
                advise((char *)0, "usage is alist [-ln].");
 
            else
-               annolist(drft, attach, l, n);
+               annolist(drft, ATTACH_FIELD, l, n);
 
            break;
 
 
            break;
 
@@ -402,11 +396,6 @@ WhatNow (int argc, char **argv)
             int verbose = 0;
             char **ap;
 
             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;
            for (ap = argp+1; *ap; ++ap) {
                if (strcmp(*ap, "-v") == 0) {
                    ++argp;
@@ -437,28 +426,25 @@ WhatNow (int argc, char **argv)
 
            if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
                while (fgets(shell, sizeof (shell), f) != (char *)0) {
 
            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 == '/') {
 
                    *(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 {
                    } 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) {
                    }
 
                    if (verbose) {
-                       printf ("%s", build_directive);
-                       free (build_directive);
+                       printf ("Attaching %s as a %s", file, ctype);
+                       free (ctype);
                    }
                }
 
                    }
                }
 
@@ -475,11 +461,6 @@ WhatNow (int argc, char **argv)
             *  Detach files from current draft.
             */
 
             *  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.
            /*
             *  Scan the arguments for a -n.  Mixed file names and numbers aren't allowed,
             *  so this catches a -n anywhere in the argument list.
@@ -506,7 +487,7 @@ WhatNow (int argc, char **argv)
 
                    if (**arguments != '\0') {
                        n = atoi(*arguments);
 
                    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) {
 
                        for (argp = arguments + 1; *argp != (char *)0; argp++) {
                            if (atoi(*argp) > n) {
@@ -533,7 +514,7 @@ WhatNow (int argc, char **argv)
            if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
                while (fgets(shell, sizeof (shell), f) != (char *)0) {
                    *(strchr(shell, '\n')) = '\0';
            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 {
                }
                pclose(f);
            } else {