From 67a64a6a7809c183516740696e15ab88f82d7ef0 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 22 Dec 2012 21:39:23 +0200 Subject: Implement inotify support. * configure.ac: New option --with-inotify. Bye default, use inotify if it is present. * src/watcher.c: New file. Implements inotify watcher. * src/Makefile.am [COND_INOTIFY] (wydawca_SOURCES): Add watcher.c * src/diskio.c (dir_get_path): New function. * src/job.c (job) : Remove const qualifier. All uses changed. (inotify_spool): New pseudo-spool. (fake_spool): Remove static qualifier. (wydawca_scanner): Support for inotify spools. * src/net.c (open_listener): Don't exit if the listener address is not set. (wydawca_listener): Listen on the listener socket and on the inotify descriptor. If none is set, bail out. * src/process.c (for_each_spool) (file_info_cleanup) (spool_cwd_add_new_file,spool_add_new_file): New functions. (scan_spool_unlocked): Use spool_cwd_add_new_file. Don't initialize dictionaries here: it will be done in spool_commit_triplets. (spool_open_dictionaries): New function. (close_dictionaries): Rename to spool_close_dictionaries. Clear dict_inited. * src/triplet.c (hash_triplet_compare): Compare spools as well. (register_file): Likewise. (triplet_lookup): New function. (check_triplet_state): New argument: noauth. All uses updated. (enumerate_triplets): Rename to spool_commit_triplets. Call spool_open_dictionaries. (count_processable_triplets,triplet_remove_file): New functions. * src/verify.c (verify_directive_file): New argument: noauth. All uses updated. * src/vtab.c (reg): Initialize get_path member. (get_path): New function. * src/wydawca.c (main): Set print_version_hook. * src/wydawca.h (virt_tab) : New method. (spool) : New member. (fake_spool, inotify_spool): New externs. (spool_add_new_file, spool_cwd_add_new_file) (spool_open_dictionaries, spool_close_dictionaries) (for_each_spool, count_processable_triplets) (triplet_remove_file, get_path): New protos. (enumerate_triplets): Rename to spool_commit_triplets. (verify_directive_file): Take two arguments. --- src/vtab.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/vtab.c') diff --git a/src/vtab.c b/src/vtab.c index 2f8a85e..cec6fc0 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -24,13 +24,13 @@ struct virt_tab_reg static struct virt_tab_reg reg[] = { { "file", - { dir_test_url, dir_move_file, dir_archive_file, dir_symlink_file, - dir_rmsymlink_file } }, + { dir_get_path, dir_test_url, dir_move_file, dir_archive_file, + dir_symlink_file, dir_rmsymlink_file } }, { "dir", - { dir_test_url, dir_move_file, dir_archive_file, dir_symlink_file, - dir_rmsymlink_file } }, + { dir_get_path, dir_test_url, dir_move_file, dir_archive_file, + dir_symlink_file, dir_rmsymlink_file } }, { "null", - { NULL, null_move_file, null_archive_file, null_symlink_file, + { NULL, NULL, null_move_file, null_archive_file, null_symlink_file, null_rmsymlink_file } }, { NULL } }; @@ -53,6 +53,14 @@ url_to_vtab (mu_url_t url, struct virt_tab *vtab) } +const char * +get_path (struct spool *sp) +{ + if (!sp->vtab.get_path) + return NULL; + return sp->vtab.get_path (sp); +} + int move_file (struct file_triplet *trp, enum file_type file_id) { -- cgit v1.2.1