/*
- * whatnowsbr.c -- the WhatNow shell
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- *
- * Several options have been added to ease the inclusion of attachments
- * using the header field name mechanism added to anno and send. The
- * -attach option is used to specify the header field name for attachments.
- *
- * Several commands have been added at the whatnow prompt:
- *
- * cd [ directory ] This option works just like the shell's
- * cd command and lets the user change the
- * directory from which attachments are
- * taken so that long path names are not
- * needed with every file.
- *
- * ls [ ls-options ] This option works just like the normal
- * ls command and exists to allow the user
- * to verify file names in the directory.
- *
- * pwd This option works just like the normal
- * pwd command and exists to allow the user
- * to verify the directory.
- *
- * attach files This option attaches the named files to
- * the draft.
- *
- * alist [-ln] This option lists the attachments on the
- * draft. -l gets long listings, -n gets
- * numbered listings.
- *
- * detach files This option removes attachments from the
- * detach -n numbers draft. This can be done by file name or
- * by attachment number.
- */
+** whatnowsbr.c -- the WhatNow shell
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+**
+** Several options have been added to ease the inclusion of attachments
+** using the header field name mechanism added to anno and send. The
+** -attach option is used to specify the header field name for attachments.
+**
+** Several commands have been added at the whatnow prompt:
+**
+** cd [ directory ] This option works just like the shell's
+** cd command and lets the user change the
+** directory from which attachments are
+** taken so that long path names are not
+** needed with every file.
+**
+** ls [ ls-options ] This option works just like the normal
+** ls command and exists to allow the user
+** to verify file names in the directory.
+**
+** pwd This option works just like the normal
+** pwd command and exists to allow the user
+** to verify the directory.
+**
+** attach files This option attaches the named files to
+** the draft.
+**
+** alist [-ln] This option lists the attachments on the
+** draft. -l gets long listings, -n gets
+** numbered listings.
+**
+** detach files This option removes attachments from the
+** detach -n numbers draft. This can be done by file name or
+** by attachment number.
+*/
#include <h/mh.h>
#include <fcntl.h>
#include <h/utils.h>
static struct swit whatnowswitches[] = {
-#define DFOLDSW 0
- { "draftfolder +folder", 0 },
-#define DMSGSW 1
- { "draftmessage msg", 0 },
-#define NDFLDSW 2
- { "nodraftfolder", 0 },
-#define EDITRSW 3
+#define EDITRSW 0
{ "editor editor", 0 },
-#define NEDITSW 4
+#define NEDITSW 1
{ "noedit", 0 },
-#define PRMPTSW 5
+#define PRMPTSW 2
{ "prompt string", 4 },
-#define VERSIONSW 6
+#define VERSIONSW 3
{ "version", 0 },
-#define HELPSW 7
+#define HELPSW 4
{ "help", 0 },
-#define ATTACHSW 8
+#define ATTACHSW 5
{ "attach header-field-name", 0 },
{ NULL, 0 }
};
/*
- * Options at the "whatnow" prompt
- */
+** Options at the "whatnow" prompt
+*/
static struct swit aleqs[] = {
#define EDITSW 0
{ "edit [<editor> <switches>]", 0 },
{ "send [<switches>]", 0 },
#define PUSHSW 6
{ "push [<switches>]", 0 },
-#define QUITSW 8
+#define QUITSW 7
{ "quit [-delete]", 0 },
-#define DELETESW 9
+#define DELETESW 8
{ "delete", 0 },
-#define CDCMDSW 10
+#define CDCMDSW 9
{ "cd [directory]", 0 },
-#define PWDCMDSW 11
+#define PWDCMDSW 10
{ "pwd", 0 },
-#define LSCMDSW 12
+#define LSCMDSW 11
{ "ls", 0 },
-#define ATTACHCMDSW 13
+#define ATTACHCMDSW 12
{ "attach", 0 },
-#define DETACHCMDSW 14
+#define DETACHCMDSW 13
{ "detach [-n]", 2 },
-#define ALISTCMDSW 15
+#define ALISTCMDSW 14
{ "alist [-ln] ", 2 },
{ NULL, 0 }
};
static char *myprompt = "\nWhat now? ";
/*
- * static prototypes
- */
+** static prototypes
+*/
static int editfile (char **, char **, char *, int, struct msgs *,
char *, char *, int);
static int sendfile (char **, char *, int);
int
WhatNow (int argc, char **argv)
{
- int isdf = 0, nedit = 0, use = 0;
- char *cp, *dfolder = NULL, *dmsg = NULL;
+ int nedit = 0, use = 0;
+ char *cp;
char *ed = NULL, *drft = NULL, *msgnam = NULL;
char buf[BUFSIZ], prompt[BUFSIZ];
char **argp, **arguments;
argp = arguments;
/*
- * Get the initial current working directory.
- */
+ ** Get the initial current working directory.
+ */
if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
adios("getcwd", "could not get working directory");
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [file]", invo_name);
+ snprintf (buf, sizeof(buf),
+ "%s [switches] [file]",
+ invo_name);
print_help (buf, whatnowswitches, 1);
done (1);
case VERSIONSW:
print_version(invo_name);
done (1);
- case DFOLDSW:
- if (dfolder)
- adios (NULL, "only one draft folder at a time!");
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
- *cp != '@' ? TFOLDER : TSUBCWF);
- continue;
- case DMSGSW:
- if (dmsg)
- adios (NULL, "only one draft message at a time!");
- if (!(dmsg = *argp++) || *dmsg == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case NDFLDSW:
- dfolder = NULL;
- isdf = NOTOK;
- continue;
-
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
nedit = 0;
continue;
case NEDITSW:
case PRMPTSW:
if (!(myprompt = *argp++) || *myprompt == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case ATTACHSW:
if (attach != (char *)0)
adios(NULL, "only one attachment header field name at a time!");
if (!(attach = *argp++) || *attach == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
}
}
drft = cp;
}
- if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
- drft = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
+ if ((drft == NULL && (drft = getenv("mhdraft")) == NULL) || *drft == 0)
+ drft = getcpy (m_draft("cur"));
msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
}
/* start editing the draft, unless -noedit was given */
- if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0)
+ if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1)
+ < 0)
done (1);
snprintf (prompt, sizeof(prompt), myprompt, invo_name);
}
switch (smatch (*argp, aleqs)) {
case DISPSW:
- /* display the message being replied to, or distributed */
+ /*
+ ** display the message being replied to,
+ ** or distributed
+ */
if (msgnam)
showfile (++argp, msgnam);
else
/* Call an editor on the draft file */
if (*++argp)
ed = *argp++;
- if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK)
+ if (editfile (&ed, argp, drft, NOUSE, NULL,
+ msgnam, NULL, 1) == NOTOK)
done (1);
break;
removefile (drft);
} else {
if (stat (drft, &st) != NOTOK)
- advise (NULL, "draft left on %s", drft);
+ advise(NULL, "draft left on %s", drft);
}
done (1);
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.
- */
+ ** 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+1) == (char *)0) {
(void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
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.
- */
+ ** 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.
+ */
writelscmd(buf, sizeof(buf), argp);
(void)system_in_dir(cwd, buf);
break;
case ALISTCMDSW:
/*
- * List attachments on current draft. Options are:
- *
- * -l long listing (full path names)
- * -n numbers listing
- */
+ ** 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.");
else if (strcmp(*argp, "-n") == 0)
n = 1;
- else if (strcmp(*argp, "-ln") == 0 || strcmp(*argp, "-nl") == 0) {
+ else if (strcmp(*argp, "-ln") == 0 ||
+ strcmp(*argp, "-nl") == 0) {
l = "/";
n = 1;
} else {
case ATTACHCMDSW:
/*
- * Attach files to current draft.
- */
+ ** Attach files to current draft.
+ */
if (attach == (char *)0) {
advise((char *)0, "can't attach because no header field name was given.");
}
/*
- * Build a command line that causes the user's
- * shell to list the file name arguments.
- * This handles and wildcard expansion, tilde
- * expansion, etc.
- */
+ ** Build a command line that causes the user's
+ ** shell to list the file name arguments.
+ ** This handles and wildcard expansion, tilde
+ ** expansion, etc.
+ */
writelscmd(buf, sizeof(buf), argp);
/*
- * Read back the response from the shell,
- * which contains a number of lines with one
- * file name per line. Remove off the newline.
- * Determine whether we have an absolute or
- * relative path name. Prepend the current
- * working directory to relative path names.
- * Add the attachment annotation to the draft.
- */
+ ** Read back the response from the shell,
+ ** which contains a number of lines with one
+ ** file name per line. Remove off the newline.
+ ** Determine whether we have an absolute or
+ ** relative path name. Prepend the current
+ ** working directory to relative path names.
+ ** Add the attachment annotation to the draft.
+ */
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
- while (fgets(shell, sizeof (shell), f) != (char *)0) {
+ while (fgets(shell, sizeof (shell), f)
+ != (char *)0) {
*(strchr(shell, '\n')) = '\0';
if (*shell == '/')
- (void)annotate(drft, attach, shell, 1, 0, -2, 1);
+ annotate(drft, attach, shell,
+ 1, 0, -2, 1);
else {
- (void)sprintf(file, "%s/%s", cwd, shell);
- (void)annotate(drft, attach, file, 1, 0, -2, 1);
+ sprintf(file, "%s/%s", cwd,
+ shell);
+ annotate(drft, attach, file,
+ 1, 0, -2, 1);
}
}
case DETACHCMDSW:
/*
- * 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.");
}
/*
- * Scan the arguments for a -n. Mixed file
- * names and numbers aren't allowed, so this
- * catches a -n anywhere in the argument list.
- */
-
- for (n = 0, arguments = argp + 1; *arguments != (char *)0; arguments++) {
+ ** Scan the arguments for a -n. Mixed file
+ ** names and numbers aren't allowed, so this
+ ** catches a -n anywhere in the argument list.
+ */
+
+ for (n = 0, arguments = argp + 1;
+ *arguments != (char *)0;
+ arguments++) {
if (strcmp(*arguments, "-n") == 0) {
n = 1;
break;
}
/*
- * A -n was found so interpret the arguments as
- * attachment numbers. Decrement any remaining
- * argument number that is greater than the one
- * just processed after processing each one so
- * that the numbering stays correct.
- */
+ ** A -n was found so interpret the arguments as
+ ** attachment numbers. Decrement any remaining
+ ** argument number that is greater than the one
+ ** just processed after processing each one so
+ ** that the numbering stays correct.
+ */
if (n == 1) {
- for (arguments = argp + 1; *arguments != (char *)0; arguments++) {
+ for (arguments = argp + 1;
+ *arguments != (char *)0;
+ arguments++) {
if (strcmp(*arguments, "-n") == 0)
continue;
if (**arguments != '\0') {
n = atoi(*arguments);
- (void)annotate(drft, attach, (char *)0, 1, 0, n, 1);
+ annotate(drft, attach, NULL,
+ 1, 0, n, 1);
for (argp = arguments + 1; *argp != (char *)0; argp++) {
if (atoi(*argp) > n) {
}
/*
- * The arguments are interpreted as file names.
- * Run them through the user's shell for wildcard
- * expansion and other goodies. Do this from
- * the current working directory if the argument
- * is not an absolute path name (does not begin
- * with a /).
- *
- * We feed all the file names to the shell at
- * once, otherwise you can't provide a file name
- * with a space in it.
- */
+ ** The arguments are interpreted as file names.
+ ** Run them through the user's shell for wildcard
+ ** expansion and other goodies. Do this from
+ ** the current working directory if the argument
+ ** is not an absolute path name (does not begin
+ ** with a /).
+ **
+ ** We feed all the file names to the shell at
+ ** once, otherwise you can't provide a file name
+ ** with a space in it.
+ */
writelscmd(buf, sizeof(buf), argp);
if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
- while (fgets(shell, sizeof (shell), f) != (char *)0) {
+ while (fgets(shell, sizeof (shell), f)
+ != NULL) {
*(strchr(shell, '\n')) = '\0';
- (void)annotate(drft, attach, shell, 1, 0, 0, 1);
+ annotate(drft, attach, shell,
+ 1, 0, 0, 1);
}
pclose(f);
} else {
/*
- * Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ;
- * trailcmd".
- */
+** Build a command line of the form $SHELL -c "cd 'cwd'; cmd argp ... ;
+** trailcmd".
+*/
static void
writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
{
char *cp;
- /* Note that we do not quote -- the argp from the user
- * is assumed to be quoted as they desire. (We can't treat
- * it as pure literal as that would prevent them using ~,
- * wildcards, etc.) The buffer produced by this function
- * should be given to popen_in_dir() or system_in_dir() so
- * that the current working directory is set correctly.
- */
+ /*
+ ** Note that we do not quote -- the argp from the user
+ ** is assumed to be quoted as they desire. (We can't treat
+ ** it as pure literal as that would prevent them using ~,
+ ** wildcards, etc.) The buffer produced by this function
+ ** should be given to popen_in_dir() or system_in_dir() so
+ ** that the current working directory is set correctly.
+ */
int ln = snprintf(buf, bufsz, "$SHELL -c \"%s", cmd);
- /* NB that some snprintf() return -1 on overflow rather than the
- * new C99 mandated 'number of chars that would have been written'
- */
- /* length checks here and inside the loop allow for the
- * trailing ';', trailcmd, '"' and NUL
- */
+ /*
+ ** NB that some snprintf() return -1 on overflow rather than the
+ ** new C99 mandated 'number of chars that would have been written'
+ */
+ /*
+ ** length checks here and inside the loop allow for the
+ ** trailing ';', trailcmd, '"' and NUL
+ */
int trailln = strlen(trailcmd) + 3;
if (ln < 0 || ln + trailln > bufsz)
adios((char *)0, "arguments too long");
}
/*
- * Build a command line that causes the user's shell to list the file name
- * arguments. This handles and wildcard expansion, tilde expansion, etc.
- */
+** Build a command line that causes the user's shell to list the file name
+** arguments. This handles and wildcard expansion, tilde expansion, etc.
+*/
static void
writelscmd(char *buf, int bufsz, char **argp)
{
writesomecmd(buf, bufsz, "ls", "", argp);
}
-/* Like system(), but run the command in directory dir.
- * This assumes the program is single-threaded!
- */
+/*
+** Like system(), but run the command in directory dir.
+** This assumes the program is single-threaded!
+*/
static int
system_in_dir(const char *dir, const char *cmd)
{
/*
- * EDIT
- */
+** EDIT
+*/
static int reedit = 0; /* have we been here before? */
static char *edsave = NULL; /* the editor we used previously */
if (mp == NULL || *altmsg == '/' || cwd == NULL)
strncpy (altpath, altmsg, sizeof(altpath));
else
- snprintf (altpath, sizeof(altpath), "%s/%s", mp->foldpath, altmsg);
+ snprintf (altpath, sizeof(altpath), "%s/%s",
+ mp->foldpath, altmsg);
if (cwd == NULL)
strncpy (linkpath, altmsglink, sizeof(linkpath));
else
- snprintf (linkpath, sizeof(linkpath), "%s/%s", cwd, altmsglink);
+ snprintf (linkpath, sizeof(linkpath), "%s/%s",
+ cwd, altmsglink);
}
if (altmsg) {
if (link (altpath, linkpath) == NOTOK) {
#if 0
/* I don't think permission on symlinks matters /JLR */
- oumask = umask(0044); /* PJS: else symlinks are world 'r' */
+ /* PJS: else symlinks are world 'r' */
+ oumask = umask(0044);
#endif
symlink (altpath, linkpath);
#if 0
|| link (linkpath, altpath) == NOTOK)))
advise (linkpath, "unable to update %s from", altmsg);
#else /* HAVE_LSTAT */
- if (altmsg
- && mp
- && !is_readonly(mp)
+ if (altmsg && mp && !is_readonly(mp)
&& stat (linkpath, &st) != NOTOK
&& st.st_nlink == 1
&& (unlink (altpath) == NOTOK
- || link (linkpath, altpath) == NOTOK))
- advise (linkpath, "unable to update %s from", altmsg);
+ || link (linkpath, altpath) == NOTOK))
+ advise (linkpath, "unable to update %s from",
+ altmsg);
#endif /* HAVE_LSTAT */
}
/*
- * SEND
- */
+** SEND
+*/
static int
sendfile (char **arg, char *file, int pushsw)
char *cp, *sp, *vec[MAXARGS];
/* Translate MIME composition file, if necessary */
- if ((cp = context_find ("automimeproc"))
- && (!strcmp (cp, "1"))
- && !getenv ("NOMHNPROC")
- && check_draft (file)
+ if ((cp = context_find ("automimeproc")) && (!strcmp (cp, "1"))
+ && !getenv ("NOMHNPROC") && check_draft (file)
&& (buildfile (NULL, file) == NOTOK))
return 0;
/* For backwards compatibility */
- if ((cp = context_find ("automhnproc"))
- && !getenv ("NOMHNPROC")
- && check_draft (file)
- && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0)))
+ if ((cp = context_find ("automhnproc")) && !getenv ("NOMHNPROC")
+ && check_draft (file) && (i = editfile (&cp, NULL,
+ file, NOUSE, NULL, NULL, NULL, 0)))
return 0;
/*
- * If the sendproc is the nmh command `send', then we call
- * those routines directly rather than exec'ing the command.
- */
+ ** If the sendproc is the nmh command `send', then we call
+ ** those routines directly rather than exec'ing the command.
+ */
if (strcmp (sp = r1bindex (sendproc, '/'), "send") == 0) {
cp = invo_name;
sendit (invo_name = sp, arg, file, pushsw);
/*
- * Translate MIME composition file (call buildmimeproc)
- */
+** Translate MIME composition file (call buildmimeproc)
+*/
static int
buildfile (char **argp, char *file)
args = (char **) mh_xmalloc((i + 2) * sizeof(char *));
/*
- * For backward compatibility, we need to add -build
- * if we are using mhn as buildmimeproc
- */
+ ** For backward compatibility, we need to add -build
+ ** if we are using mhn as buildmimeproc
+ */
i = 0;
if (strcmp (r1bindex (ed, '/'), "mhn") == 0)
args[i++] = "-build";
/*
- * Check if draft is a mhbuild composition file
- */
+** Check if draft is a mhbuild composition file
+*/
static int
check_draft (char *msgnam)
case FLDPLUS:
case FLDEOF:
/*
- * If draft already contains any of the
- * Content-XXX fields, then assume it already
- * been converted.
- */
+ ** If draft already contains any of the
+ ** Content-XXX fields, then assume it already
+ ** been converted.
+ */
if (uprf (name, XXX_FIELD_PRF)) {
fclose (fp);
return 0;
}
while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), fp);
break;
case BODY:
return 1;
}
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ state = m_getfld (state, name, buf,
+ sizeof(buf), fp);
} while (state == BODY);
/* and fall... */
{ "push", 0 },
#define NSPSHSW 13
{ "nopush", 0 },
-#define UNIQSW 15
+#define UNIQSW 14
{ "unique", -6 },
-#define NUNIQSW 16
+#define NUNIQSW 15
{ "nounique", -8 },
-#define VERBSW 17
+#define VERBSW 16
{ "verbose", 0 },
-#define NVERBSW 18
+#define NVERBSW 17
{ "noverbose", 0 },
-#define WATCSW 19
+#define WATCSW 18
{ "watch", 0 },
-#define NWATCSW 20
+#define NWATCSW 19
{ "nowatch", 0 },
-#define WIDTHSW 21
+#define WIDTHSW 20
{ "width columns", 0 },
-#define SVERSIONSW 22
+#define SVERSIONSW 21
{ "version", 0 },
-#define SHELPSW 23
+#define SHELPSW 22
{ "help", 0 },
-#define BITSTUFFSW 24
+#define BITSTUFFSW 23
{ "dashstuffing", -12 },
-#define NBITSTUFFSW 25
+#define NBITSTUFFSW 24
{ "nodashstuffing", -14 },
-#define MAILSW 26
+#define MAILSW 25
{ "mail", -4 },
-#define SAMLSW 27
+#define SAMLSW 26
{ "saml", -4 },
-#define SSNDSW 28
+#define SSNDSW 27
{ "send", -4 },
-#define SOMLSW 29
+#define SOMLSW 28
{ "soml", -4 },
-#define CLIESW 30
+#define CLIESW 29
{ "client host", -6 },
-#define SERVSW 31
+#define SERVSW 30
{ "server host", 6 },
-#define SNOOPSW 32
+#define SNOOPSW 31
{ "snoop", -5 },
-#define SDRFSW 33
- { "draftfolder +folder", -6 },
-#define SDRMSW 34
- { "draftmessage msg", -6 },
-#define SNDRFSW 35
- { "nodraftfolder", -3 },
-#define SNDATTACHSW 39
+#define SNDATTACHSW 32
{ "attach file", 6 },
-#define SNDATTACHFORMAT 40
+#define SNDATTACHFORMAT 33
{ "attachformat", 7 },
-#define PORTSW 41
+#define PORTSW 34
{ "port server-port-name/number", 4 },
{ NULL, 0 }
};
char **arguments, *vec[MAXARGS];
struct stat st;
char *attach = (char *)0; /* attachment header field name */
- int attachformat = 0; /* mhbuild format specifier for
- attachments */
+ int attachformat = 0; /* mhbuild format specifier for attachments */
#ifndef lint
int distsw = 0;
#endif
/*
- * Make sure these are defined. In particular, we need
- * vec[1] to be NULL, in case "arg" is NULL below. It
- * doesn't matter what is the value of vec[0], but we
- * set it to NULL, to help catch "off-by-one" errors.
- */
+ ** Make sure these are defined. In particular, we need
+ ** vec[1] to be NULL, in case "arg" is NULL below. It
+ ** doesn't matter what is the value of vec[0], but we
+ ** set it to NULL, to help catch "off-by-one" errors.
+ */
vec[0] = NULL;
vec[1] = NULL;
/*
- * Temporarily copy arg to vec, since the brkstring() call in
- * getarguments() will wipe it out before it is merged in.
- * Also, we skip the first element of vec, since getarguments()
- * skips it. Then we count the number of arguments
- * copied. The value of "n" will be one greater than
- * this in order to simulate the standard argc/argv.
- */
+ ** Temporarily copy arg to vec, since the brkstring() call in
+ ** getarguments() will wipe it out before it is merged in.
+ ** Also, we skip the first element of vec, since getarguments()
+ ** skips it. Then we count the number of arguments
+ ** copied. The value of "n" will be one greater than
+ ** this in order to simulate the standard argc/argv.
+ */
if (arg) {
char **bp;
}
/*
- * Merge any arguments from command line (now in vec)
- * and arguments from profile.
- */
+ ** Merge any arguments from command line (now in vec)
+ ** and arguments from profile.
+ */
arguments = getarguments (sp, n, vec, 1);
argp = arguments;
return;
case SHELPSW:
- snprintf (buf, sizeof(buf), "%s [switches]", sp);
+ snprintf (buf, sizeof(buf),
+ "%s [switches]", sp);
print_help (buf, sendswitches, 1);
return;
case SVERSIONSW:
vec[vecp++] = cp;
continue;
- case SDRFSW:
- case SDRMSW:
- if (!(cp = *argp++) || *cp == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- case SNDRFSW:
- continue;
-
case SNDATTACHSW:
- if (!(attach = *argp++) || *attach == '-') {
+ if (!(attach = *argp++) ||
+ *attach == '-') {
advise (NULL, "missing argument to %s", argp[-2]);
return;
}
adios (NULL, "missing argument to %s", argp[-1]);
else {
attachformat = atoi (*argp);
- if (attachformat < 0 ||
- attachformat > ATTACHFORMATS - 1) {
- advise (NULL, "unsupported attachformat %d",
- attachformat);
+ if (attachformat < 0 || attachformat > ATTACHFORMATS - 1) {
+ advise (NULL, "unsupported attachformat %d", attachformat);
continue;
}
}
/*
- * Remove the draft file
- */
+** Remove the draft file
+*/
static int
removefile (char *drft)