diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-11 23:52:43 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-11 23:52:43 +0200 |
commit | 7c10eca883faa5dd5b01bf1e50b04abb792a6639 (patch) | |
tree | 51fc8746681d42bca8034f88510ff7f144215e70 | |
parent | 10a5f20232d2a57beb0a50b38b1d7196a7f5236e (diff) | |
download | wydawca-7c10eca883faa5dd5b01bf1e50b04abb792a6639.tar.gz wydawca-7c10eca883faa5dd5b01bf1e50b04abb792a6639.tar.bz2 |
Follow up to 87602f54.
Fix minor bugs. Update the testsuite. All tests pass now.
* modules/mailutils/mod_mailutils.c (cb_statistics): Remove. Use
wy_cb_statistics.
(expand_email_admin, expand_email_owner): Add missing functions.
* src/config.c (wy_cb_statistics): New function.
(wydawca_kw): Restore "statistics" statement.
* src/dictionary.c (dictionary_lookup): Fix debug levels.
* src/wydawca.h (wy_cb_statistics): New proto.
* tests/atlocal.in (wydawca_expandmeta): Expand @WD_MODDIR@
* tests/check-notify.at: Create notify.rc from notify.rcin
* tests/notify-upl.at: Likewise.
* tests/mailstats.at: Likewise.
* tests/upload-dry.at: Fix the expected output.
* tests/etc/mailstats.rc: Rename to tests/etc/mailstats.rcin.
* tests/etc/notify.rc: Rename to tests/etc/notify.rcin.
* tests/etc/Makefile.am: Update.
* tests/etc/wydawca.rcin: Update to the new syntax.
-rw-r--r-- | modules/mailutils/mod_mailutils.c | 142 | ||||
-rw-r--r-- | src/config.c | 10 | ||||
-rw-r--r-- | src/dictionary.c | 4 | ||||
-rw-r--r-- | src/wydawca.h | 3 | ||||
-rw-r--r-- | tests/atlocal.in | 6 | ||||
-rw-r--r-- | tests/check-notify.at | 3 | ||||
-rw-r--r-- | tests/etc/Makefile.am | 4 | ||||
-rw-r--r-- | tests/etc/mailstats.rcin (renamed from tests/etc/mailstats.rc) | 20 | ||||
-rw-r--r-- | tests/etc/notify.rcin (renamed from tests/etc/notify.rc) | 81 | ||||
-rw-r--r-- | tests/etc/wydawca.rcin | 6 | ||||
-rw-r--r-- | tests/mailstats.at | 3 | ||||
-rw-r--r-- | tests/notify-upl.at | 3 | ||||
-rw-r--r-- | tests/upload-dry.at | 2 |
13 files changed, 140 insertions, 147 deletions
diff --git a/modules/mailutils/mod_mailutils.c b/modules/mailutils/mod_mailutils.c index 8698537..2265a76 100644 --- a/modules/mailutils/mod_mailutils.c +++ b/modules/mailutils/mod_mailutils.c | |||
@@ -455,117 +455,14 @@ cb_email_address(enum grecs_callback_command cmd, grecs_node_t *node, | |||
455 | return rc; | 455 | return rc; |
456 | } | 456 | } |
457 | 457 | ||
458 | static struct mu_kwd stat_tab[] = { | ||
459 | { "errors", STAT_ERRORS }, | ||
460 | { "warnings", STAT_WARNINGS }, | ||
461 | { "bad-signatures", STAT_BAD_SIGNATURE }, | ||
462 | { "access-violations", STAT_ACCESS_VIOLATIONS }, | ||
463 | { "complete-triplets", STAT_COMPLETE_TRIPLETS }, | ||
464 | { "incomplete-triplets", STAT_INCOMPLETE_TRIPLETS }, | ||
465 | { "bad-triplets", STAT_BAD_TRIPLETS }, | ||
466 | { "expired-triplets", STAT_EXPIRED_TRIPLETS }, | ||
467 | { "triplet-success", STAT_TRIPLET_SUCCESS }, | ||
468 | { "uploads", STAT_UPLOADS }, | ||
469 | { "archives", STAT_ARCHIVES }, | ||
470 | { "symlinks", STAT_SYMLINKS }, | ||
471 | { "rmsymlinks", STAT_RMSYMLINKS }, | ||
472 | { NULL }, | ||
473 | }; | ||
474 | |||
475 | static int | ||
476 | parse_single_statmask(grecs_locus_t *locus, const grecs_value_t *val, | ||
477 | unsigned long *pmask, int *invert) | ||
478 | { | ||
479 | const char *arg; | ||
480 | int x; | ||
481 | |||
482 | if (val->type != GRECS_TYPE_STRING) { | ||
483 | grecs_error(&val->locus, 0, | ||
484 | _("expected scalar value but found list")); | ||
485 | return 1; | ||
486 | } | ||
487 | |||
488 | arg = val->v.string; | ||
489 | |||
490 | if (strcmp(arg, "all") == 0) { | ||
491 | *pmask = STAT_MASK_ALL; | ||
492 | *invert = 1; | ||
493 | return 0; | ||
494 | } else if (strcmp(arg, "none") == 0) { | ||
495 | *pmask = STAT_MASK_NONE; | ||
496 | *invert = 0; | ||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | if (mu_kwd_xlat_name(stat_tab, arg, &x)) { | ||
501 | grecs_error(&val->locus, 0, _("unknown statistics type: %s"), | ||
502 | arg); | ||
503 | return 1; | ||
504 | } | ||
505 | *pmask = STAT_MASK(x); | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int | ||
510 | parse_statmask(grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask) | ||
511 | { | ||
512 | int err = 0; | ||
513 | int invert = 0; | ||
514 | unsigned long mask = 0; | ||
515 | int i; | ||
516 | struct grecs_list_entry *ep; | ||
517 | |||
518 | switch (val->type) { | ||
519 | case GRECS_TYPE_STRING: | ||
520 | err = parse_single_statmask(loc, val, &mask, &invert); | ||
521 | break; | ||
522 | |||
523 | case GRECS_TYPE_ARRAY: | ||
524 | for (i = 0; i < val->v.arg.c; i++) { | ||
525 | unsigned long x; | ||
526 | if (parse_single_statmask(loc, val->v.arg.v[i], | ||
527 | &x, &invert)) | ||
528 | err = 1; | ||
529 | else if (invert) | ||
530 | mask &= ~x; | ||
531 | else | ||
532 | mask |= x; | ||
533 | } | ||
534 | break; | ||
535 | |||
536 | case GRECS_TYPE_LIST: | ||
537 | for (ep = val->v.list->head; ep; ep = ep->next) { | ||
538 | const grecs_value_t *vp = ep->data; | ||
539 | unsigned long x; | ||
540 | |||
541 | if (parse_single_statmask(loc, vp, &x, &invert)) | ||
542 | err = 1; | ||
543 | else if (invert) | ||
544 | mask &= ~x; | ||
545 | else | ||
546 | mask |= x; | ||
547 | } | ||
548 | break; | ||
549 | } | ||
550 | if (!err) | ||
551 | *pmask = mask; | ||
552 | return err; | ||
553 | } | ||
554 | |||
555 | static int | ||
556 | cb_statistics(enum grecs_callback_command cmd, grecs_node_t *node, | ||
557 | void *varptr, void *cb_data) | ||
558 | { | ||
559 | return parse_statmask(&node->locus, node->v.value, varptr); | ||
560 | } | ||
561 | |||
562 | static struct grecs_keyword mail_statistics_kw[] = { | 458 | static struct grecs_keyword mail_statistics_kw[] = { |
563 | { "message", N_("text"), | 459 | { "message", N_("text"), |
564 | N_("Message text"), | 460 | N_("Message text"), |
565 | grecs_type_string, GRECS_DFLT, &admin_stat_message }, | 461 | grecs_type_string, GRECS_DFLT, &admin_stat_message }, |
566 | { "statistics", N_("items"), | 462 | { "statistics", N_("items"), |
567 | N_("Send mail if one or more of these items are set"), | 463 | N_("Send mail if one or more of these items are set"), |
568 | grecs_type_string, GRECS_DFLT, &mail_admin_mask, 0, cb_statistics }, | 464 | grecs_type_string, GRECS_DFLT, &mail_admin_mask, 0, |
465 | wy_cb_statistics }, | ||
569 | { "gpg-sign", | 466 | { "gpg-sign", |
570 | N_("key"), N_("Sign message with this key"), | 467 | N_("key"), N_("Sign message with this key"), |
571 | grecs_type_string, GRECS_DFLT, &admin_stat_sign_key }, | 468 | grecs_type_string, GRECS_DFLT, &admin_stat_sign_key }, |
@@ -812,6 +709,39 @@ get_recipient(struct dictionary *dict, struct file_triplet const *trp, | |||
812 | return rcpt; | 709 | return rcpt; |
813 | } | 710 | } |
814 | 711 | ||
712 | const char * | ||
713 | expand_email_admin(struct metadef *def, void *data) | ||
714 | { | ||
715 | if (mu_address_aget_printable(admin_address, &def->storage) == 0) | ||
716 | def->value = def->storage; | ||
717 | else | ||
718 | def->value = ""; | ||
719 | return def->value; | ||
720 | } | ||
721 | |||
722 | const char * | ||
723 | expand_email_owner(struct metadef *def, void *data) | ||
724 | { | ||
725 | struct file_triplet *trp = data; | ||
726 | mu_address_t addr; | ||
727 | const char *errp; | ||
728 | |||
729 | addr = get_recipient(trp->spool->dictionary[project_owner_dict], | ||
730 | trp, &errp); | ||
731 | if (!addr) { | ||
732 | wy_log(LOG_ERR, _("cannot get email of the %s's owner: %s"), | ||
733 | trp->project, gettext(errp)); | ||
734 | def->value = ""; | ||
735 | } else { | ||
736 | if (mu_address_aget_printable(addr, &def->storage) == 0) | ||
737 | def->value = def->storage; | ||
738 | else | ||
739 | def->value = ""; | ||
740 | mu_address_destroy(&addr); | ||
741 | } | ||
742 | return def->value; | ||
743 | } | ||
744 | |||
815 | static void | 745 | static void |
816 | t_notify(struct mailevt *evt, int ev, struct file_triplet const *trp) | 746 | t_notify(struct mailevt *evt, int ev, struct file_triplet const *trp) |
817 | { | 747 | { |
@@ -935,8 +865,10 @@ void | |||
935 | mod_mailutils_LTX_notify(void *data, int ev, struct file_triplet const *trp) | 865 | mod_mailutils_LTX_notify(void *data, int ev, struct file_triplet const *trp) |
936 | { | 866 | { |
937 | struct mailevt *evt = data; | 867 | struct mailevt *evt = data; |
868 | |||
938 | if (trp) | 869 | if (trp) |
939 | t_notify(evt, ev, trp); | 870 | t_notify(evt, ev, trp); |
940 | else if (ev == ev_statistics) | 871 | else if (ev == ev_statistics) |
941 | mail_stats(evt); | 872 | mail_stats(evt); |
942 | } | 873 | } |
874 | |||
diff --git a/src/config.c b/src/config.c index 8dbc788..b89beff 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -440,6 +440,13 @@ parse_statmask(grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask) | |||
440 | return err; | 440 | return err; |
441 | } | 441 | } |
442 | 442 | ||
443 | int | ||
444 | wy_cb_statistics(enum grecs_callback_command cmd, grecs_node_t *node, | ||
445 | void *varptr, void *cb_data) | ||
446 | { | ||
447 | return parse_statmask(&node->locus, node->v.value, varptr); | ||
448 | } | ||
449 | |||
443 | 450 | ||
444 | static int | 451 | static int |
445 | cb_sql_host(enum grecs_callback_command cmd, grecs_node_t *node, |