2 * whatnowsbr.c -- the WhatNow shell
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
8 * Several options have been added to ease the inclusion of attachments
9 * using the header field name mechanism added to anno and send. The
10 * -attach option is used to specify the header field name for attachments.
12 * Several commands have been added at the whatnow prompt:
14 * cd [ directory ] This option works just like the shell's
15 * cd command and lets the user change the
16 * directory from which attachments are
17 * taken so that long path names are not
18 * needed with every file.
20 * ls [ ls-options ] This option works just like the normal
21 * ls command and exists to allow the user
22 * to verify file names in the directory.
24 * pwd This option works just like the normal
25 * pwd command and exists to allow the user
26 * to verify the directory.
28 * attach files This option attaches the named files to
31 * alist [-ln] This option lists the attachments on the
32 * draft. -l gets long listings, -n gets
35 * detach files This option removes attachments from the
36 * detach -n numbers draft. This can be done by file name or
37 * by attachment number.
46 static struct swit whatnowswitches[] = {
48 { "draftfolder +folder", 0 },
50 { "draftmessage msg", 0 },
52 { "nodraftfolder", 0 },
54 { "editor editor", 0 },
58 { "prompt string", 4 },
64 { "attach header-field-name", 0 },
69 * Options at the "whatnow" prompt
71 static struct swit aleqs[] = {
73 { "edit [<editor> <switches>]", 0 },
75 { "refile [<switches>] +folder", 0 },
77 { "mime [<switches>]", 0 },
79 { "display [<switches>]", 0 },
81 { "list [<switches>]", 0 },
83 { "send [<switches>]", 0 },
85 { "push [<switches>]", 0 },
87 { "quit [-delete]", 0 },
91 { "cd [directory]", 0 },
96 #define ATTACHCMDSW 13
98 #define DETACHCMDSW 14
100 #define ALISTCMDSW 15
101 { "alist [-ln] ", 2 },
105 static char *myprompt = "\nWhat now? ";
110 static int editfile (char **, char **, char *, int, struct msgs *,
111 char *, char *, int);
112 static int sendfile (char **, char *, int);
113 static void sendit (char *, char **, char *, int);
114 static int buildfile (char **, char *);
115 static int check_draft (char *);
116 static int removefile (char *);
117 static void writelscmd(char *, int, char **);
118 static void writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp);
119 static FILE* popen_in_dir(const char *dir, const char *cmd, const char *type);
120 static int system_in_dir(const char *dir, const char *cmd);
124 static int copyf (char *, char *);
129 WhatNow (int argc, char **argv)
131 int isdf = 0, nedit = 0, use = 0;
132 char *cp, *dfolder = NULL, *dmsg = NULL;
133 char *ed = NULL, *drft = NULL, *msgnam = NULL;
134 char buf[BUFSIZ], prompt[BUFSIZ];
135 char **argp, **arguments;
137 char *attach = (char *)0; /* attachment header field name */
138 char cwd[MAXPATHLEN + 1]; /* current working directory */
139 char file[MAXPATHLEN + 1]; /* file name buffer */
140 char shell[MAXPATHLEN + 1]; /* shell response buffer */
141 FILE *f; /* read pointer for bgnd proc */
142 char *l; /* set on -l to alist command */
143 int n; /* set on -n to alist command */
145 invo_name = r1bindex (argv[0], '/');
147 /* read user profile/context */
150 arguments = getarguments (invo_name, argc, argv, 1);
154 * Get the initial current working directory.
157 if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
158 adios("getcwd", "could not get working directory");
161 while ((cp = *argp++)) {
163 switch (smatch (++cp, whatnowswitches)) {
165 ambigsw (cp, whatnowswitches);
168 adios (NULL, "-%s unknown", cp);
171 snprintf (buf, sizeof(buf), "%s [switches] [file]", invo_name);
172 print_help (buf, whatnowswitches, 1);
175 print_version(invo_name);
180 adios (NULL, "only one draft folder at a time!");
181 if (!(cp = *argp++) || *cp == '-')
182 adios (NULL, "missing argument to %s", argp[-2]);
183 dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
184 *cp != '@' ? TFOLDER : TSUBCWF);
188 adios (NULL, "only one draft message at a time!");
189 if (!(dmsg = *argp++) || *dmsg == '-')
190 adios (NULL, "missing argument to %s", argp[-2]);
198 if (!(ed = *argp++) || *ed == '-')
199 adios (NULL, "missing argument to %s", argp[-2]);
207 if (!(myprompt = *argp++) || *myprompt == '-')
208 adios (NULL, "missing argument to %s", argp[-2]);
212 if (attach != (char *)0)
213 adios(NULL, "only one attachment header field name at a time!");
214 if (!(attach = *argp++) || *attach == '-')
215 adios (NULL, "missing argument to %s", argp[-2]);
220 adios (NULL, "only one draft at a time!");
225 if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
226 drft = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
228 msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
230 if ((cp = getenv ("mhuse")) && *cp)
233 if (ed == NULL && ((ed = getenv ("mheditor")) == NULL || *ed == 0)) {
238 /* start editing the draft, unless -noedit was given */
239 if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0)
242 snprintf (prompt, sizeof(prompt), myprompt, invo_name);
244 if (!(argp = getans (prompt, aleqs))) {
248 switch (smatch (*argp, aleqs)) {
250 /* display the message being replied to, or distributed */
252 showfile (++argp, msgnam);
254 advise (NULL, "no alternate message to display");
258 /* Translate MIME composition file */
259 buildfile (++argp, drft);
263 /* Call an editor on the draft file */
266 if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK)
271 /* display the draft file */
272 showfile (++argp, drft);
276 /* Quit, and possibly delete the draft */
277 if (*++argp && (*argp[0] == 'd' ||
278 ((*argp)[0] == '-' && (*argp)[1] == 'd'))) {
281 if (stat (drft, &st) != NOTOK)
282 advise (NULL, "draft left on %s", drft);
287 /* Delete draft and exit */
292 /* Send draft in background */
293 if (sendfile (++argp, drft, 1))
299 sendfile (++argp, drft, 0);
303 /* Refile the draft */
304 if (refile (++argp, drft) == 0)
310 * Change the working directory for attachments
312 * Run the directory through the user's shell
313 * so that we can take advantage of any syntax
314 * that the user is accustomed to. Read back
318 if (*(argp+1) == (char *)0) {
319 (void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
321 writesomecmd(buf, BUFSIZ, "cd", "pwd", argp);
323 if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
324 fgets(cwd, sizeof (cwd), f);
326 if (strchr(cwd, '\n') != (char *)0)
327 *strchr(cwd, '\n') = '\0';
331 advise("popen", "could not get directory");
337 /* Print the working directory for attachments */
343 * List files in the current attachment working
346 * Use the user's shell so that we can take
347 * advantage of any syntax that the user is
350 writelscmd(buf, sizeof(buf), argp);
351 (void)system_in_dir(cwd, buf);
356 * List attachments on current draft. Options are:
358 * -l long listing (full path names)
362 if (attach == (char *)0) {
363 advise((char *)0, "can't list because no header field name was given.");
370 while (*++argp != (char *)0) {
371 if (strcmp(*argp, "-l") == 0)
374 else if (strcmp(*argp, "-n") == 0)
377 else if (strcmp(*argp, "-ln") == 0 || strcmp(*argp, "-nl") == 0) {
387 advise((char *)0, "usage is alist [-ln].");
390 annolist(drft, attach, l, n);
396 * Attach files to current draft.
399 if (attach == (char *)0) {
400 advise((char *)0, "can't attach because no header field name was given.");
404 if (*(argp+1) == (char *)0) {
405 advise((char *)0, "attach command requires file argument(s).");
410 * Build a command line that causes the user's
411 * shell to list the file name arguments.
412 * This handles and wildcard expansion, tilde
415 writelscmd(buf, sizeof(buf), argp);
418 * Read back the response from the shell,
419 * which contains a number of lines with one
420 * file name per line. Remove off the newline.
421 * Determine whether we have an absolute or
422 * relative path name. Prepend the current
423 * working directory to relative path names.
424 * Add the attachment annotation to the draft.
427 if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
428 while (fgets(shell, sizeof (shell), f) != (char *)0) {
429 *(strchr(shell, '\n')) = '\0';
432 (void)annotate(drft, attach, shell, 1, 0, -2, 1);
434 (void)sprintf(file, "%s/%s", cwd, shell);
435 (void)annotate(drft, attach, file, 1, 0, -2, 1);
441 advise("popen", "could not get file from shell");
448 * Detach files from current draft.
451 if (attach == (char *)0) {
452 advise((char *)0, "can't detach because no header field name was given.");
457 * Scan the arguments for a -n. Mixed file
458 * names and numbers aren't allowed, so this
459 * catches a -n anywhere in the argument list.
462 for (n = 0, arguments = argp + 1; *arguments != (char *)0; arguments++) {
463 if (strcmp(*arguments, "-n") == 0) {
470 * A -n was found so interpret the arguments as
471 * attachment numbers. Decrement any remaining
472 * argument number that is greater than the one
473 * just processed after processing each one so
474 * that the numbering stays correct.
478 for (arguments = argp + 1; *arguments != (char *)0; arguments++) {
479 if (strcmp(*arguments, "-n") == 0)
482 if (**arguments != '\0') {
483 n = atoi(*arguments);
484 (void)annotate(drft, attach, (char *)0, 1, 0, n, 1);
486 for (argp = arguments + 1; *argp != (char *)0; argp++) {
487 if (atoi(*argp) > n) {
488 if (atoi(*argp) == 1)
491 (void)sprintf(*argp, "%d", atoi(*argp) - 1);
499 * The arguments are interpreted as file names.
500 * Run them through the user's shell for wildcard
501 * expansion and other goodies. Do this from
502 * the current working directory if the argument
503 * is not an absolute path name (does not begin
506 * We feed all the file names to the shell at
507 * once, otherwise you can't provide a file name
508 * with a space in it.
510 writelscmd(buf, sizeof(buf), argp);
511 if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
512 while (fgets(shell, sizeof (shell), f) != (char *)0) {
513 *(strchr(shell, '\n')) = '\0';
514 (void)annotate(drft, attach, shell, 1, 0, 0, 1);
518 advise("popen", "could not get file from shell");
524 /* Unknown command */
525 advise (NULL, "say what?");
535 * Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ;
539 writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
542 /* Note that we do not quote -- the argp from the user
543 * is assumed to be quoted as they desire. (We can't treat
544 * it as pure literal as that would prevent them using ~,
545 * wildcards, etc.) The buffer produced by this function
546 * should be given to popen_in_dir() or system_in_dir() so
547 * that the current working directory is set correctly.
549 int ln = snprintf(buf, bufsz, "$SHELL -c \"%s", cmd);
550 /* NB that some snprintf() return -1 on overflow rather than the
551 * new C99 mandated 'number of chars that would have been written'
553 /* length checks here and inside the loop allow for the
554 * trailing ';', trailcmd, '"' and NUL
556 int trailln = strlen(trailcmd) + 3;
557 if (ln < 0 || ln + trailln > bufsz)
558 adios((char *)0, "arguments too long");
562 while (*++argp != (char *)0) {
564 /* +1 for leading space */
565 if (ln + trailln + 1 > bufsz - (cp-buf))
566 adios((char *)0, "arguments too long");
568 memcpy(cp, *argp, ln+1);
573 strcpy(cp, trailcmd);
581 * Build a command line that causes the user's shell to list the file name
582 * arguments. This handles and wildcard expansion, tilde expansion, etc.
585 writelscmd(char *buf, int bufsz, char **argp)
587 writesomecmd(buf, bufsz, "ls", "", argp);
590 /* Like system(), but run the command in directory dir.
591 * This assumes the program is single-threaded!
594 system_in_dir(const char *dir, const char *cmd)
598 if (getcwd(olddir, sizeof(olddir)) == 0)
599 adios("getcwd", "could not get working directory");
601 adios("chdir", "could not change working directory");
603 if (chdir(olddir) != 0)
604 adios("chdir", "could not change working directory");
608 /* ditto for popen() */
610 popen_in_dir(const char *dir, const char *cmd, const char *type)
614 if (getcwd(olddir, sizeof(olddir)) == 0)
615 adios("getcwd", "could not get working directory");
617 adios("chdir", "could not change working directory");
618 f = popen(cmd, type);
619 if (chdir(olddir) != 0)
620 adios("chdir", "could not change working directory");
629 static int reedit = 0; /* have we been here before? */
630 static char *edsave = NULL; /* the editor we used previously */
634 editfile (char **ed, char **arg, char *file, int use, struct msgs *mp,
635 char *altmsg, char *cwd, int save_editor)
637 int pid, status, vecp;
638 char altpath[BUFSIZ], linkpath[BUFSIZ];
639 char *cp, *vec[MAXARGS];
645 int oumask; /* PJS: for setting permissions on symlinks. */
647 #endif /* HAVE_LSTAT */
649 /* Was there a previous edit session? */
651 if (!*ed) { /* no explicit editor */
652 *ed = edsave; /* so use the previous one */
653 if ((cp = r1bindex (*ed, '/')) == NULL)
656 /* unless we've specified it via "editor-next" */
657 cp = concat (cp, "-next", NULL);
658 if ((cp = context_find (cp)) != NULL)
662 /* set initial editor */
663 if (*ed == NULL && (*ed = context_find ("editor")) == NULL)
668 if (mp == NULL || *altmsg == '/' || cwd == NULL)
669 strncpy (altpath, altmsg, sizeof(altpath));
671 snprintf (altpath, sizeof(altpath), "%s/%s", mp->foldpath, altmsg);
673 strncpy (linkpath, altmsglink, sizeof(linkpath));
675 snprintf (linkpath, sizeof(linkpath), "%s/%s", cwd, altmsglink);
681 if (link (altpath, linkpath) == NOTOK) {
683 /* I don't think permission on symlinks matters /JLR */
684 oumask = umask(0044); /* PJS: else symlinks are world 'r' */
686 symlink (altpath, linkpath);
688 umask(oumask); /* PJS: else symlinks are world 'r' */
694 #else /* not HAVE_LSTAT */
695 link (altpath, linkpath);
696 #endif /* not HAVE_LSTAT */
699 context_save (); /* save the context file */
702 switch (pid = vfork ()) {
704 advise ("fork", "unable to");
713 m_putenv ("mhfolder", mp->foldpath);
714 m_putenv ("editalt", altpath);
718 vec[vecp++] = r1bindex (*ed, '/');
721 vec[vecp++] = *arg++;
726 fprintf (stderr, "unable to exec ");
731 if ((status = pidwait (pid, NOTOK))) {
733 if ((cp = r1bindex (*ed, '/'))
734 && strcmp (cp, "vi") == 0
735 && (status & 0x00ff) == 0)
739 if (((status & 0xff00) != 0xff00)
740 && (!reedit || (status & 0x00ff))) {
741 if (!use && (status & 0xff00) &&
742 (rename (file, cp = m_backup (file)) != NOTOK)) {
743 advise (NULL, "problems with edit--draft left in %s", cp);
745 advise (NULL, "problems with edit--%s preserved", file);
748 status = -2; /* maybe "reedit ? -2 : -1"? */
761 ? lstat (linkpath, &st) != NOTOK
762 && S_ISREG(st.st_mode)
763 && copyf (linkpath, altpath) == NOTOK
764 : stat (linkpath, &st) != NOTOK
766 && (unlink (altpath) == NOTOK
767 || link (linkpath, altpath) == NOTOK)))
768 advise (linkpath, "unable to update %s from", altmsg);
769 #else /* HAVE_LSTAT */
773 && stat (linkpath, &st) != NOTOK
775 && (unlink (altpath) == NOTOK
776 || link (linkpath, altpath) == NOTOK))
777 advise (linkpath, "unable to update %s from", altmsg);
778 #endif /* HAVE_LSTAT */
781 /* normally, we remember which editor we used */
783 edsave = getcpy (*ed);
795 copyf (char *ifile, char *ofile)
800 if ((in = open (ifile, O_RDONLY)) == NOTOK)
802 if ((out = open (ofile, O_WRONLY | O_TRUNC)) == NOTOK) {
803 admonish (ofile, "unable to open and truncate");
808 while ((i = read (in, buffer, sizeof(buffer))) > OK)
809 if (write (out, buffer, i) != i) {
810 advise (ofile, "may have damaged");
819 #endif /* HAVE_LSTAT */
827 sendfile (char **arg, char *file, int pushsw)
831 char *cp, *sp, *vec[MAXARGS];
833 /* Translate MIME composition file, if necessary */
834 if ((cp = context_find ("automimeproc"))
835 && (!strcmp (cp, "1"))
836 && !getenv ("NOMHNPROC")
837 && check_draft (file)
838 && (buildfile (NULL, file) == NOTOK))
841 /* For backwards compatibility */
842 if ((cp = context_find ("automhnproc"))
843 && !getenv ("NOMHNPROC")
844 && check_draft (file)
845 && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0)))
849 * If the sendproc is the nmh command `send', then we call
850 * those routines directly rather than exec'ing the command.
852 if (strcmp (sp = r1bindex (sendproc, '/'), "send") == 0) {
854 sendit (invo_name = sp, arg, file, pushsw);
859 context_save (); /* save the context file */
862 for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
866 advise (NULL, "unable to fork, so sending directly...");
869 vec[vecp++] = invo_name;
871 vec[vecp++] = "-push";
874 vec[vecp++] = *arg++;
878 execvp (sendproc, vec);
879 fprintf (stderr, "unable to exec ");
884 if (pidwait(child_id, OK) == 0)
892 * Translate MIME composition file (call buildmimeproc)
896 buildfile (char **argp, char *file)
903 /* allocate space for arguments */
909 args = (char **) mh_xmalloc((i + 2) * sizeof(char *));
912 * For backward compatibility, we need to add -build
913 * if we are using mhn as buildmimeproc
916 if (strcmp (r1bindex (ed, '/'), "mhn") == 0)
917 args[i++] = "-build";
919 /* copy any other arguments */
920 while (argp && *argp)
924 i = editfile (&ed, args, file, NOUSE, NULL, NULL, NULL, 0);
927 return (i ? NOTOK : OK);
932 * Check if draft is a mhbuild composition file
936 check_draft (char *msgnam)
939 char buf[BUFSIZ], name[NAMESZ];
942 if ((fp = fopen (msgnam, "r")) == NULL)
945 switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
950 * If draft already contains any of the
951 * Content-XXX fields, then assume it already
954 if (uprf (name, XXX_FIELD_PRF)) {
958 while (state == FLDPLUS)
959 state = m_getfld (state, name, buf, sizeof(buf), fp);
966 for (bp = buf; *bp; bp++)
967 if (*bp != ' ' && *bp != '\t' && *bp != '\n') {
972 state = m_getfld (state, name, buf, sizeof(buf), fp);
973 } while (state == BODY);
983 static struct swit sendswitches[] = {
985 { "alias aliasfile", 0 },
989 { "filter filterfile", 0 },
1025 { "width columns", 0 },
1026 #define SVERSIONSW 22
1030 #define BITSTUFFSW 24
1031 { "dashstuffing", -12 },
1032 #define NBITSTUFFSW 25
1033 { "nodashstuffing", -14 },
1043 { "client host", -6 },
1045 { "server host", 6 },
1049 { "draftfolder +folder", -6 },
1051 { "draftmessage msg", -6 },
1053 { "nodraftfolder", -3 },
1054 #define SNDATTACHSW 39
1055 { "attach file", 6 },
1056 #define SNDATTACHFORMAT 40
1057 { "attachformat", 7 },
1059 { "port server-port-name/number", 4 },
1064 extern int debugsw; /* from sendsbr.c */
1071 extern char *altmsg; /* .. */
1072 extern char *annotext;
1073 extern char *distfile;
1077 sendit (char *sp, char **arg, char *file, int pushed)
1080 char *cp, buf[BUFSIZ], **argp;
1081 char **arguments, *vec[MAXARGS];
1083 char *attach = (char *)0; /* attachment header field name */
1084 int attachformat = 0; /* mhbuild format specifier for
1095 * Make sure these are defined. In particular, we need
1096 * vec[1] to be NULL, in case "arg" is NULL below. It
1097 * doesn't matter what is the value of vec[0], but we
1098 * set it to NULL, to help catch "off-by-one" errors.
1104 * Temporarily copy arg to vec, since the brkstring() call in
1105 * getarguments() will wipe it out before it is merged in.
1106 * Also, we skip the first element of vec, since getarguments()
1107 * skips it. Then we count the number of arguments
1108 * copied. The value of "n" will be one greater than
1109 * this in order to simulate the standard argc/argv.
1114 copyip (arg, vec+1, MAXARGS-1);
1121 * Merge any arguments from command line (now in vec)
1122 * and arguments from profile.
1124 arguments = getarguments (sp, n, vec, 1);
1136 vecp = 1; /* we'll get the zero'th element later */
1137 vec[vecp++] = "-library";
1138 vec[vecp++] = getcpy (m_maildir (""));
1140 while ((cp = *argp++)) {
1142 switch (smatch (++cp, sendswitches)) {
1144 ambigsw (cp, sendswitches);
1147 advise (NULL, "-%s unknown\n", cp);
1151 snprintf (buf, sizeof(buf), "%s [switches]", sp);
1152 print_help (buf, sendswitches, 1);
1155 print_version (invo_name);
1188 debugsw++; /* fall */
1215 if (!(cp = *argp++) || *cp == '-') {
1216 advise (NULL, "missing argument to %s", argp[-2]);
1224 if (!(cp = *argp++) || *cp == '-') {
1225 advise (NULL, "missing argument to %s", argp[-2]);
1232 if (!(attach = *argp++) || *attach == '-') {
1233 advise (NULL, "missing argument to %s", argp[-2]);
1238 case SNDATTACHFORMAT:
1239 if (! *argp || **argp == '-')
1240 adios (NULL, "missing argument to %s", argp[-1]);
1242 attachformat = atoi (*argp);
1243 if (attachformat < 0 ||
1244 attachformat > ATTACHFORMATS - 1) {
1245 advise (NULL, "unsupported attachformat %d",
1254 advise (NULL, "usage: %s [switches]", sp);
1258 /* allow Aliasfile: profile entry */
1259 if ((cp = context_find ("Aliasfile"))) {
1263 for (ap = brkstring (dp, " ", "\n"); ap && *ap; ap++) {
1264 vec[vecp++] = "-alias";
1269 if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
1270 if ((cp = context_find ("signature")) && *cp)
1271 m_putenv ("SIGNATURE", cp);
1274 snprintf (buf, sizeof(buf), "%s/.signature", mypath);
1275 if ((fp = fopen (buf, "r")) != NULL
1276 && fgets (buf, sizeof(buf), fp) != NULL) {
1278 if (cp = strchr (buf, '\n'))
1280 m_putenv ("SIGNATURE", buf);
1285 if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
1287 if ((altmsg = getenv ("mhaltmsg")) == NULL || *altmsg == 0)
1289 if (annotext && ((cp = getenv ("mhinplace")) != NULL && *cp != 0))
1290 inplace = atoi (cp);
1292 if ((cp = getenv ("mhdist"))
1295 && (distsw = atoi (cp))
1296 #endif /* not lint */
1298 vec[vecp++] = "-dist";
1299 distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL));
1300 if (link (altmsg, distfile) == NOTOK)
1301 adios (distfile, "unable to link %s to", altmsg);
1306 if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
1311 if ((pushsw = pushed))
1314 vec[0] = r1bindex (postproc, '/');
1317 if (sendsbr (vec, vecp, file, &st, 1, attach, attachformat) == OK)
1323 * Remove the draft file
1327 removefile (char *drft)
1329 if (unlink (drft) == NOTOK)
1330 adios (drft, "unable to unlink");