summaryrefslogtreecommitdiffabout
path: root/sieve
authorSergey Poznyakoff <gray@gnu.org.ua>2004-01-05 13:50:11 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2004-01-05 13:50:11 (GMT)
commit74f72efa675221352c73c2dd65c5eaa12b587bc3 (patch) (side-by-side diff)
tree869420ead219d1969f50709a46bf2c5dbbda0a74 /sieve
parent0f3de3f23314be37f9eb8bc201b19f3eccce9c7f (diff)
downloadmailutils-74f72efa675221352c73c2dd65c5eaa12b587bc3.tar.gz
mailutils-74f72efa675221352c73c2dd65c5eaa12b587bc3.tar.bz2
Brought in sync with recent changes to libsieve
Diffstat (limited to 'sieve') (more/less context) (ignore whitespace changes)
-rw-r--r--sieve/sieve.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/sieve/sieve.c b/sieve/sieve.c
index 59669d2..72b6a7e 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -62,6 +62,8 @@ Debug flags:\n\
#define D_DEFAULT "TPt"
+#define ARG_LINE_INFO 257
+
static struct argp_option options[] =
{
{"no-actions", 'n', 0, 0,
@@ -87,7 +89,10 @@ static struct argp_option options[] =
{"verbose", 'v', NULL, 0,
N_("Log all actions"), 0},
-
+
+ {"line-info", ARG_LINE_INFO, N_("BOOL"), OPTION_ARG_OPTIONAL,
+ N_("Print source location along with action logs (default)") },
+
{"email", 'e', N_("ADDRESS"), 0,
N_("Override user email address"), 0},
@@ -106,6 +111,24 @@ struct options {
char *script;
};
+static int sieve_print_locus = 1; /* Should the log messages include the
+ locus */
+
+static int
+is_true_p (char *p)
+{
+ if (!p)
+ return 1;
+ /* TRANSLATORS: This is the list of characters meaning 'Yes'. Please,
+ preserve yY in your translation, e.g., for German:
+
+ msgstr "yYjJ";
+ */
+ if (strchr (_("yY"), *p))
+ return 1;
+ return 0;
+}
+
static error_t
parser (int key, char *arg, struct argp_state *state)
{
@@ -196,6 +219,10 @@ parser (int key, char *arg, struct argp_state *state)
case 'v':
opts->verbose = 1;
break;
+
+ case ARG_LINE_INFO:
+ sieve_print_locus = is_true_p (arg);
+ break;
case ARGP_KEY_ARG:
if (opts->script)
@@ -267,14 +294,20 @@ syslog_debug_print (mu_debug_t unused, size_t level, const char *fmt,
static void
stdout_action_log (void *unused,
- const char *script, size_t msgno, message_t msg,
+ const sieve_locus_t *locus, size_t msgno, message_t msg,
const char *action, const char *fmt, va_list ap)
{
size_t uid = 0;
-
+
message_get_uid (msg, &uid);
- fprintf (stdout, _("%s on msg uid %lu"), action, (unsigned long) uid);
+ if (sieve_print_locus)
+ fprintf (stdout, _("%s:%lu: %s on msg uid %lu"),
+ locus->source_file, (unsigned long) locus->source_line,
+ action, (unsigned long) uid);
+ else
+ fprintf (stdout, _("%s on msg uid %lu"), action, (unsigned long) uid);
+
if (fmt && strlen (fmt))
{
fprintf (stdout, ": ");
@@ -285,7 +318,7 @@ stdout_action_log (void *unused,
static void
syslog_action_log (void *unused,
- const char *script, size_t msgno, message_t msg,
+ const sieve_locus_t *locus, size_t msgno, message_t msg,
const char *action, const char *fmt, va_list ap)
{
size_t uid = 0;
@@ -293,7 +326,13 @@ syslog_action_log (void *unused,
message_get_uid (msg, &uid);
- asprintf (&text, _("%s on msg uid %d"), action, uid);
+ if (sieve_print_locus)
+ asprintf (&text, _("%s:%lu: %s on msg uid %lu"),
+ locus->source_file, (unsigned long) locus->source_line,
+ action, (unsigned long) uid);
+ else
+ asprintf (&text, _("%s on msg uid %lu"), action, (unsigned long) uid);
+
if (fmt && strlen (fmt))
{
char *diag = NULL;

Return to:

Send suggestions and report system problems to the System administrator.