aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 22:39:23 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 22:39:23 +0200
commit87602f5492b842f734dffe22f4e2f85dbc6ce713 (patch)
tree3e7e04bca15e8af5c981a78619e2d95f03b45c67 /src/wydawca.h
parent826bb71c57d903f760c89406f93d19fe0c131de0 (diff)
downloadwydawca-87602f5492b842f734dffe22f4e2f85dbc6ce713.tar.gz
wydawca-87602f5492b842f734dffe22f4e2f85dbc6ce713.tar.bz2
Replace mail notification with module event notification framework.
The new framework is to be general-purpose; the mail notification is implemented as a module. Althoug the program is operational, the change is not completed yet. In particular, the docs are out of date and the tests will mostly fail. * .gitignore: Update. * Makefile.am (SUBDIRS): Add modules. * configure.ac: Mailutils is now optional (though highly recommended). (AC_CONFIG_FILES): Build modules/Makefile and modules/mailutils/Makefile. * modules/Makefile.am: New file. * modules/mailutils/Makefile.am: New file. * modules/mailutils/mod_mailutils.c: New file. * src/mail.c: Remove. * src/mail.h: Remove. * src/event.c: New file. * src/Makefile.am (wydawca_SOURCES): Update. (LDADD): Remove MAILUTILS_LIBS. * src/config.c: Remove mail-related configuration statements. Add module-related ones instead. * src/wydawca.h (notification_event) <ev_statistics>: New event. (notification_target): Remove. (notification) <tgt,sign_keys,msg>: Remove. <statmask>: New member. (register_message_template): Remove. (notify_stats,notify_flush): New protos. (notification_target_str): Remove. (format_fn): Remove. (module) <next,modinit,open> <flush,close>: New members. <notify>: Change signature. (modules_close, module_set_init) (module_flush): New protos. (debug_level): Rename to wy_debug_level. All uses changed. (wy_version): New extern. (admin_stat_message,admin_stat_sign_key): Remove. (default_notification): New global. (triplet_expand_param,triplet_expand_dictionary_query): The file_triplet argument is const pointer. (assert_string_arg): Rename to wy_assert_string_arg. * src/wydawca.c (debug_level): Rename to wy_debug_level. (wy_version): New global. (logstats): Call notify_stats. (main): Call modules_close. * src/module.c: Keep modules in a singly-linked list instead of a symtab. Provide new functions. * src/net.c: Update. * src/dictionary.c: Update. * src/directive.c: Update. * src/diskio.c: Update. * src/exec.c: Update. * src/gpg.c: Update. * src/job.c (wydawca_scanner): Call notify_flush. * src/null.c: Update. * src/process.c: Update. * src/sql.c: Update. * src/tcpwrap.c: Update. * src/triplet.c: Update. * src/verify.c: Update. * src/watcher.c: Update.
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index b79b7e9..73ff961 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -282,34 +282,25 @@ enum notification_event {
ev_bad_directive_signature,
ev_bad_detached_signature,
ev_check_fail,
+ ev_statistics,
MAX_EVENT
};
-enum notification_target {
- notify_read, /* Read recipients from the message headers */
- notify_admin, /* System administrator */
- notify_owner, /* Project admin */
- notify_user /* User (uploader) */
-};
-
struct notification {
struct notification *next;
enum notification_event ev;
- enum notification_target tgt;
- const char *sign_keys;
- const char *msg;
+ int statmask;
char *modname;
void *modcfg;
grecs_node_t *modnode;
};
-void register_message_template(const char *name, const char *text);
-
void notify(struct notification *, struct file_triplet *,
enum notification_event);
+void notify_stats(void);
+void notify_flush(struct spool *sp);
const char *notification_event_str(enum notification_event evt);
-const char *notification_target_str(enum notification_target tgt);
struct metadef {
char *kw;
@@ -327,24 +318,33 @@ const char *expand_email_admin(struct metadef *def, void *data);
const char *expand_email_owner(struct metadef *def, void *data);
/* Modules */
-typedef char *(*format_fn)(void *, const char *);
struct module {
+ struct module *next;
char *name;
char *path;
grecs_locus_t locus;
+ grecs_node_t *modinit;
void *handle;
+ int (*open) (grecs_node_t *);
void *(*config) (grecs_node_t *);
- int (*notify) (void *, int, format_fn, void *);
+ int (*notify) (void *, int, struct file_triplet *);
+ void (*flush) (void *);
+ void (*close) (void);
};
int cb_module(enum grecs_callback_command cmd, grecs_node_t *node,
void *varptr, void *cb_data);
void modules_load(void);
+void modules_close(void);
+
+int module_set_init(const char *name, grecs_node_t *node);
extern struct grecs_list *module_load_path, *module_prepend_load_path;
void module_notify(const char *name, void *modcfg,
enum notification_event ev, struct file_triplet *tpl);
+void module_flush(const char *name, void *modcfg);
+
/* Global variables */
@@ -354,7 +354,8 @@ extern gid_t wydawca_gid;
extern size_t wydawca_supp_groupc;
extern gid_t *wydawca_supp_groups;
extern char *conffile; /* Configuration file name */
-extern int debug_level; /* Debugging level */
+extern const char *wy_version;
+extern int wy_debug_level; /* Debugging level */
extern int dry_run_mode; /* Dry run indicator */
extern int log_to_stderr; /* Log to stderr instead of the syslog */
extern int log_facility; /* Syslog facility to use if !log_to_stderr */
@@ -367,9 +368,6 @@ extern unsigned wydawca_stat[MAX_STAT];
extern unsigned long print_stats;
extern int archive_signatures;
-extern char *admin_stat_message;
-extern char *admin_stat_sign_key;
-
extern char *pidfile;
extern int force_startup;
@@ -398,6 +396,8 @@ extern struct spool inotify_spool;
extern int inotify_enable;
+extern struct notification *default_notification;
+
#define UPDATE_STATS(what) do { \
if (what >= MAX_STAT) abort(); \
wydawca_stat[what]++; \
@@ -450,9 +450,9 @@ void spool_commit_triplets(struct spool *, struct file_triplet *);
struct file_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
-char *triplet_expand_param(const char *tmpl, struct file_triplet *trp);
+char *triplet_expand_param(const char *tmpl, struct file_triplet const *trp);
char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
- struct file_triplet *trp);
+ struct file_triplet const *trp);
void triplet_remove_file(struct spool *spool, const char *name);
@@ -512,8 +512,8 @@ int parse_time_interval(const char *str, time_t * pint, const char **endp);
void config_init(void);
void config_finish(struct grecs_node *);
void config_help(void);
-int assert_string_arg(grecs_locus_t *, enum grecs_callback_command,
- const grecs_value_t *);
+int wy_assert_string_arg(grecs_locus_t *, enum grecs_callback_command,
+ const grecs_value_t *);
grecs_value_t *get_arg(grecs_value_t *value, unsigned n, int type);
int wy_strtofac(const char *str);

Return to:

Send suggestions and report system problems to the System administrator.