summaryrefslogtreecommitdiffabout
path: root/src/watcher.c
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 20:39:23 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-03-10 20:39:23 (GMT)
commit87602f5492b842f734dffe22f4e2f85dbc6ce713 (patch) (side-by-side diff)
tree3e7e04bca15e8af5c981a78619e2d95f03b45c67 /src/watcher.c
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/watcher.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/watcher.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/watcher.c b/src/watcher.c
index c18beab..1ba7c71 100644
--- a/src/watcher.c
+++ b/src/watcher.c
@@ -84,14 +84,14 @@ create_watcher(struct spool *sp, void *data)
return 0;
if (!sp->inotify_enable) {
- if (debug_level > 1)
+ if (wy_debug_level > 1)
logmsg(LOG_DEBUG,
"disabling inotify support for spool %s",
sp->tag);
return 0;
}
- if (debug_level > 1)
+ if (wy_debug_level > 1)
logmsg(LOG_DEBUG, "spool %s: creating watcher %s", sp->tag,
path);
dwp = malloc(sizeof(*dwp));
@@ -123,12 +123,12 @@ watcher_init()
int ifd, rc;
if (!inotify_enable) {
- if (debug_level > 1)
+ if (wy_debug_level > 1)
logmsg(LOG_DEBUG, "disabling inotify support");
return -1;
}
- if (debug_level > 1)
+ if (wy_debug_level > 1)
logmsg(LOG_DEBUG, "setting up inotify");
ifd = inotify_init();
if (ifd == -1) {
@@ -140,11 +140,11 @@ watcher_init()
if (rc)
exit(EX_OSERR);
if (!dirwatcher_list) {
- if (debug_level > 1)
+ if (wy_debug_level > 1)
logmsg(LOG_DEBUG, "inotify: nothing to watch");
close(ifd);
ifd = -1;
- } else if (debug_level > 1)
+ } else if (wy_debug_level > 1)
logmsg(LOG_DEBUG, "inotify initialized successfully");
return ifd;
@@ -174,17 +174,17 @@ process_event(struct inotify_event *ep)
else
logmsg(LOG_NOTICE, "unrecognized event %x", ep->mask);
} else if (ep->mask & IN_CREATE) {
- if (debug_level > 0)
+ if (wy_debug_level > 0)
logmsg(LOG_DEBUG, "%s/%s created",
dwp->spool->source_dir, ep->name);
} else if (ep->mask & (IN_DELETE | IN_MOVED_FROM)) {
- if (debug_level > 0)
+ if (wy_debug_level > 0)
logmsg(LOG_DEBUG, "%s/%s %s", dwp->spool->source_dir,
ep->name,
ep->mask & IN_DELETE ? "deleted" : "moved out");
triplet_remove_file(dwp->spool, ep->name);
} else if (ep->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) {
- if (debug_level > 0)
+ if (wy_debug_level > 0)
logmsg(LOG_DEBUG, "%s/%s written",
dwp->spool->source_dir, ep->name);
if (spool_add_new_file(dwp->spool, ep->name, 0, NULL) == 0

Return to:

Send suggestions and report system problems to the System administrator.