Commit 9813be45 9813be458d631d21b05164e794a9ab335eb00c96 by Sergey Poznyakoff

Minor improvements in comsat and frm

* comsat/action.c (action_exec): Remove `line' argument.
Do not explicitly add locus to the messages.
(run_user_action): Add locus to diagnostics mu_debug_t,
so it is prepended to all diagnostic messages automatically.
* comsat/comsat.c: Improve help output
* frm/frm.c (attr_help): Remove unnecessary variable.
1 parent 2141acfb
......@@ -18,6 +18,7 @@
MA 02110-1301 USA */
#include "comsat.h"
#include <mailutils/io.h>
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
#include <obstack.h>
......@@ -287,35 +288,32 @@ action_echo (FILE *tty, const char *cr, int omit_newline,
}
static void
action_exec (FILE *tty, int line, int argc, char **argv)
action_exec (FILE *tty, int argc, char **argv)
{
pid_t pid;
struct stat stb;
if (argc == 0)
{
mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: no arguments for exec"), username, line);
mu_diag_output (MU_DIAG_ERROR, _("no arguments for exec"));
return;
}
if (argv[0][0] != '/')
{
mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: not an absolute pathname"),
username, line);
mu_diag_output (MU_DIAG_ERROR, _("not an absolute pathname: %s"), argv[0]);
return;
}
if (stat (argv[0], &stb))
{
mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: cannot stat %s: %s"),
username, line, argv[0], strerror (errno));
mu_diag_funcall (MU_DIAG_ERROR, "stat", argv[0], errno);
return;
}
if (stb.st_mode & (S_ISUID|S_ISGID))
{
mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: will not execute set[ug]id programs"),
username, line);
mu_diag_output (MU_DIAG_ERROR, _("will not execute set[ug]id programs"));
return;
}
......@@ -374,7 +372,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg)
if (fp)
{
unsigned line = 1, n;
mu_debug_t debug;
char *cwd = mu_getcwd ();
char *rcname;
mu_asprintf (&rcname, "%s/%s", cwd, BIFF_RC);
free (cwd);
mu_diag_get_debug (&debug);
while ((n = act_getline (fp, &stmt, &size)))
{
int argc;
......@@ -384,6 +390,7 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg)
&& argc
&& argv[0][0] != '#')
{
mu_debug_set_locus (debug, rcname, line);
if (strcmp (argv[0], "beep") == 0)
{
/* FIXME: excess arguments are ignored */
......@@ -412,15 +419,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg)
}
else if (strcmp (argv[0], "exec") == 0)
{
action_exec (tty, line, argc - 1, argv + 1);
action_exec (tty, argc - 1, argv + 1);
nact++;
}
else
{
fprintf (tty, _(".biffrc:%d: unknown keyword"), line);
fprintf (tty, "\r\n");
mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: unknown keyword %s"),
username, line, argv[0]);
mu_diag_output (MU_DIAG_ERROR, _("unknown keyword %s"),
argv[0]);
break;
}
}
......@@ -429,6 +436,8 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg)
line += n;
}
fclose (fp);
mu_debug_set_locus (debug, NULL, 0);
free (rcname);
}
if (nact == 0)
......
......@@ -55,6 +55,7 @@ typedef struct utmp UTMP;
const char *program_version = "comsatd (" PACKAGE_STRING ")";
static char doc[] = "GNU comsatd";
static char args_doc[] = N_("\n--test MBOX-URL MSG-QID");
#define OPT_FOREGROUND 256
......@@ -77,7 +78,7 @@ static error_t comsatd_parse_opt (int key, char *arg,
static struct argp argp = {
options,
comsatd_parse_opt,
NULL,
args_doc,
doc,
NULL,
NULL, NULL
......
......@@ -46,13 +46,6 @@ static struct attr_tab {
{ NULL }
};
static char attr_help[] =
/* TRANSLATORS: Please do *not* translate the words "new", "unread",
"old" and "read". They are keywords. */
N_("select messages with the specific attribute: \
new, unread, old (same as unread) or read (or any unambiguous \
abbreviation of these)");
/* Attribute table handling */
......@@ -127,10 +120,16 @@ static struct argp_option options[] = {
{"field", 'f', N_("NAME"), 0, N_("header field to display"), 0},
{"to", 'l', NULL, 0, N_("include the To: information"), 0},
{"number", 'n', NULL, 0, N_("display message numbers"), 0},
{"Quiet", 'Q', NULL, 0, N_("very quiet"), 0},
{"Quiet", 'Q', NULL, 0, N_("do not display headers"), 0},
{"query", 'q', NULL, 0, N_("print a message if the mailbox contains some unread mail"), 0},
{"summary",'S', NULL, 0, N_("print a summary of messages"), 0},
{"status", 's', N_("STATUS"), 0, attr_help, 0},
{"status", 's', N_("STATUS"), 0,
/* TRANSLATORS: Please do *not* translate the words "new", "unread",
"old" and "read". They are keywords. */
N_("select messages with the specific attribute:"
" new, unread, old (same as unread) or read (or any unambiguous"
" abbreviation of these)"),
0},
{"align", 't', NULL, 0, N_("tidy mode: align subject lines"), 0},
{0, 0, 0, 0}
};
......