diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-12 15:03:59 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-12 15:22:13 +0200 |
commit | 1ba8cf95a5f536d4aa6293f9848271a7285bc092 (patch) | |
tree | dede8a4bccb1daad8b67530d87845e7fe05749e6 | |
parent | 293108d7806aa3c0c5e706237b3788b261779e66 (diff) | |
download | wydawca-1ba8cf95a5f536d4aa6293f9848271a7285bc092.tar.gz wydawca-1ba8cf95a5f536d4aa6293f9848271a7285bc092.tar.bz2 |
Namespace normalization (2). Provide installable headers.
* Makefile.am (SUBDIRS): Add include.
* configure.ac: Build include/*/Makefile
Set-up grecs as a shared convenience library. Install
its headers.
* include/Makefile.am: New file.
* include/wydawca/Makefile.am: New file.
* include/wydawca/cfg.h: New file.
* include/wydawca/wydawca.h: New file.
* modules/mailutils/Makefile.am (AM_CPPFLAGS): Add include/
* src/Makefile.am (LDADD): Use @GRECS_LDADD@
(AM_CPPFLAGS): Add include/.
* tests/Makefile.am: Likewise.
* src/wydawca.h: Include wydawca/wydawca.h.
(__cat2__, __cat3__): Move to installable header and rename.
(struct wy_user): Move to installable header.
(struct file_triplet): Rename to wy_triplet. All uses changed.
(enum notification_event): Rename to wy_event and move to
installable header.
(struct metadef): Rename to wy_metadef and move to
installable header.
(dry_run_mode): Rename to wy_dry_run and move to
installable header.
(wydawca_gpg_homedir): Rename to wy_gpg_homedir and move to
installable header.
(wy_version, wy_debug_level, wy_log_to_stderr)
(wy_log_facility, wy_syslog_tag)
(wy_log,wy_dbg): Move to installable header.
* modules/mailutils/mod_mailutils.c: Update.
* src/cmdline.opt
* src/config.c
* src/directive.c
* src/diskio.c
* src/event.c
* src/gpg.c
* src/job.c
* src/meta.c
* src/module.c
* src/null.c
* src/timer.c
* src/triplet.c
* src/verify.c
* src/vtab.c
* src/watcher.c
* src/wydawca.c
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/wydawca/Makefile.am | 3 | ||||
-rw-r--r-- | include/wydawca/cfg.h | 21 | ||||
-rw-r--r-- | include/wydawca/wydawca.h | 92 | ||||
-rw-r--r-- | modules/mailutils/Makefile.am | 6 | ||||
-rw-r--r-- | modules/mailutils/mod_mailutils.c | 84 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/cmdline.opt | 2 | ||||
-rw-r--r-- | src/config.c | 26 | ||||
-rw-r--r-- | src/directive.c | 28 | ||||
-rw-r--r-- | src/diskio.c | 46 | ||||
-rw-r--r-- | src/event.c | 6 | ||||
-rw-r--r-- | src/gpg.c | 14 | ||||
-rw-r--r-- | src/job.c | 12 | ||||
-rw-r--r-- | src/meta.c | 39 | ||||
-rw-r--r-- | src/module.c | 4 | ||||
-rw-r--r-- | src/null.c | 10 | ||||
-rw-r--r-- | src/timer.c | 8 | ||||
-rw-r--r-- | src/triplet.c | 176 | ||||
-rw-r--r-- | src/verify.c | 6 | ||||
-rw-r--r-- | src/vtab.c | 8 | ||||
-rw-r--r-- | src/watcher.c | 2 | ||||
-rw-r--r-- | src/wydawca.c | 16 | ||||
-rw-r--r-- | src/wydawca.h | 150 | ||||
-rw-r--r-- | tests/Makefile.am | 7 |
27 files changed, 435 insertions, 345 deletions
diff --git a/Makefile.am b/Makefile.am index 3ae6fc6..1e2d8ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,7 @@ ACLOCAL_AMFLAGS = -I m4 -I grecs/am -I imprimatur -SUBDIRS=grecs libltdl src modules imprimatur doc etc tests +SUBDIRS=grecs libltdl include src modules imprimatur doc etc tests # We never remove files from the configuration directory distuninstallcheck_listfiles = \ diff --git a/configure.ac b/configure.ac index 94f6daf..95e5217 100644 --- a/configure.ac +++ b/configure.ac @@ -145,16 +145,14 @@ fi AM_CONDITIONAL([COND_INOTIFY],[test $status_inotify = yes]) # Grecs subsystem -GRECS_SETUP([grecs],[tree-api git2chg getopt tests]) + +GRECS_SETUP([grecs],[tree-api git2chg getopt tests shared install-headers]) AH_BOTTOM([ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) # define __attribute__(x) #endif -#ifndef GSC_PRINTFLIKE -# define GSC_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg))) -#endif ]) # Initialize the test suite. @@ -172,6 +170,8 @@ fi AC_CONFIG_FILES([Makefile doc/Makefile + include/Makefile + include/wydawca/Makefile src/Makefile modules/Makefile modules/mailutils/Makefile diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..05c81ec --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +SUBDIRS=wydawca
\ No newline at end of file diff --git a/include/wydawca/Makefile.am b/include/wydawca/Makefile.am new file mode 100644 index 0000000..43f7f67 --- /dev/null +++ b/include/wydawca/Makefile.am @@ -0,0 +1,3 @@ +pkginclude_HEADERS = \ + cfg.h\ + wydawca.h
\ No newline at end of file diff --git a/include/wydawca/cfg.h b/include/wydawca/cfg.h new file mode 100644 index 0000000..150cb69 --- /dev/null +++ b/include/wydawca/cfg.h @@ -0,0 +1,21 @@ +/* wydawca - automatic release submission daemon + Copyright (C) 2007-2013 Sergey Poznyakoff + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int wy_assert_string_arg(grecs_locus_t *locus, + enum grecs_callback_command cmd, + const grecs_value_t *value); +int wy_cb_statistics(enum grecs_callback_command cmd, grecs_node_t *node, + void *varptr, void *cb_data); diff --git a/include/wydawca/wydawca.h b/include/wydawca/wydawca.h new file mode 100644 index 0000000..9b5c7df --- /dev/null +++ b/include/wydawca/wydawca.h @@ -0,0 +1,92 @@ +/* wydawca - automatic release submission daemon + Copyright (C) 2007-2013 Sergey Poznyakoff + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#define wy_s_cat2(a,b) a ## b +#define wy_s_cat3(a,b,c) a ## b ## c + +#define WY_EXPORT(module,name) wy_s_cat3(module,_LTX_,name) +#define wy_notify WY_EXPORT(WY_MODULE,notify) +#define wy_help WY_EXPORT(WY_MODULE,help) +#define wy_open WY_EXPORT(WY_MODULE,open) +#define wy_config WY_EXPORT(WY_MODULE,config) +#define wy_flush WY_EXPORT(WY_MODULE,flush) + +/* Global variables */ + +extern int wy_dry_run; /* Dry run indicator */ +extern int wy_debug_level; /* Debugging level */ +extern char *wy_gpg_homedir; +extern const char *wy_version; +extern int wy_log_to_stderr; /* Log to stderr instead of the syslog */ +extern int wy_log_facility; /* Syslog facility to use if !wy_log_to_stderr */ +extern char *wy_syslog_tag; /* Syslog tag */ + +/* Logging and debugging */ +#ifndef WY_PRINTFLIKE +# define WY_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg))) +#endif + +void wy_log(int prio, char *fmt, ...) WY_PRINTFLIKE(2, 3); +void wy_dbg(char *fmt, ...) WY_PRINTFLIKE(1, 2); +#define wy_debug(l,c) do { \ + if (wy_debug_level >= (l)) \ + wy_dbg c; \ + } while(0) + +/* Wydawca events */ +enum wy_event { + wy_ev_success, + wy_ev_bad_ownership, + wy_ev_bad_directive_signature, + wy_ev_bad_detached_signature, + wy_ev_check_fail, + wy_ev_statistics, + WY_N_EVENT +}; + +const char *wy_event_str(enum wy_event evt); + + +struct wy_user { + struct wy_user *next; + char *name; + char *realname; + char *email; + char *gpg_key; + char *fpr; +}; + +typedef struct wy_triplet *wy_triplet_t; + +const char *wy_triplet_project(wy_triplet_t trp); +struct wy_user *wy_triplet_get_uploaders(wy_triplet_t trp); +struct wy_user *wy_triplet_get_admins(wy_triplet_t trp); +struct wy_user *wy_triplet_get_uploader(wy_triplet_t trp); + +struct wy_metadef { + char *kw; + char *value; + const char *(*expand) (struct wy_metadef *, void *); + char *storage; + void *data; +}; + +char *wy_expand_stats(const char *tmpl); +char *wy_triplet_expand_param(const char *tmpl, struct wy_triplet const *trp, + struct wy_metadef *xmeta); + +int wy_stat_mask_p(unsigned long mask); + diff --git a/modules/mailutils/Makefile.am b/modules/mailutils/Makefile.am index 7582f81..f968f7b 100644 --- a/modules/mailutils/Makefile.am +++ b/modules/mailutils/Makefile.am @@ -5,4 +5,8 @@ mod_LTLIBRARIES=mod_mailutils.la mod_mailutils_la_SOURCES = mod_mailutils.c mod_mailutils_la_LIBADD = @MAILUTILS_LIBS@ AM_LDFLAGS = -module -avoid-version -no-undefined -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)/src @GRECS_INCLUDES@ @MAILUTILS_INCLUDES@ +AM_CPPFLAGS = \ + -I$(top_srcdir)\ + -I$(top_srcdir)/include\ + -I$(top_builddir)/src\ + @GRECS_INCLUDES@ @MAILUTILS_INCLUDES@ diff --git a/modules/mailutils/mod_mailutils.c b/modules/mailutils/mod_mailutils.c index 9a8d061..a3d903c 100644 --- a/modules/mailutils/mod_mailutils.c +++ b/modules/mailutils/mod_mailutils.c @@ -18,16 +18,13 @@ #include <stdlib.h> #include <stdio.h> #include <gpgme.h> -#if 0 -/* FIXME */ -#include <wydawca/types.h> -#include <wydawca/grecs.h> -#else #include "grecs.h" -#include "wydawca.h" -#endif +#include <wydawca/wydawca.h> +#include <wydawca/cfg.h> #include <mailutils/mailutils.h> +#define WY_MODULE mod_mailutils + static int mailer_opened; static mu_mailer_t mailer; static mu_address_t admin_address; @@ -244,10 +241,10 @@ sign_message(mu_message_t *pmsg, const char *key) wy_debug(1, (_("signing message as %s"), key)); - if (wydawca_gpg_homedir) { + if (wy_gpg_homedir) { wy_debug(2, (_("setting GNUPG home directory: %s"), - wydawca_gpg_homedir)); - setenv("GNUPGHOME", wydawca_gpg_homedir, 1); + wy_gpg_homedir)); + setenv("GNUPGHOME", wy_gpg_homedir, 1); } if ((rc = mu_message_get_body(msg, &body))) { @@ -374,7 +371,7 @@ mail_send_message(mu_address_t rcpt, const char *text, const char *signer_key) if (signer_key) sign_message(&msg, signer_key); - if (!dry_run_mode) { + if (!wy_dry_run) { rc = mu_mailer_send_message(mailer, msg, from_address, rcpt); if (rc) wy_log(LOG_CRIT, _("cannot send message: %s"), @@ -487,13 +484,13 @@ static struct grecs_keyword mail_kw[] = { }; void -mod_mailutils_LTX_help(void) +wy_help(void) { /* FIXME */ } int -mod_mailutils_LTX_open(grecs_node_t *node) +wy_open(grecs_node_t *node) { int rc = 0; @@ -602,7 +599,7 @@ static struct grecs_keyword notify_event_kw[] = { }; void * -mod_mailutils_LTX_config(grecs_node_t *node) +wy_config(grecs_node_t *node) { int i; struct mailevt *evt = grecs_malloc(sizeof(*evt)); @@ -617,7 +614,7 @@ mod_mailutils_LTX_config(grecs_node_t *node) } void -mod_mailutils_LTX_flush() +wy_flush() { if (mailer_opened) { mu_mailer_close(mailer); @@ -626,9 +623,9 @@ mod_mailutils_LTX_flush() } static mu_address_t -get_uploader_email(struct file_triplet *trp, const char **errp) +get_uploader_email(wy_triplet_t trp, const char **errp) { - struct wy_user const *info = triplet_get_uploader(trp); + struct wy_user const *info = wy_triplet_get_uploader(trp); mu_address_t addr; mu_address_t rcpt = NULL; int rc; @@ -652,12 +649,12 @@ get_uploader_email(struct file_triplet *trp, const char **errp) } static mu_address_t -get_owner_address(struct file_triplet *trp) +get_owner_address(wy_triplet_t trp) { struct wy_user *wp; mu_address_t rcpt = NULL; - for (wp = triplet_get_admins(trp); wp; wp = wp->next) { + for (wp = wy_triplet_get_admins(trp); wp; wp = wp->next) { mu_address_t addr; if (mu_address_create(&addr, wp->email)) continue; @@ -672,7 +669,7 @@ get_owner_address(struct file_triplet *trp) } static const char * -expand_email_admin(struct metadef *def, void *data) +expand_email_admin(struct wy_metadef *def, void *data) { if (mu_address_aget_printable(admin_address, &def->storage) == 0) def->value = def->storage; @@ -682,15 +679,15 @@ expand_email_admin(struct metadef *def, void *data) } static const char * -expand_email_owner(struct metadef *def, void *data) +expand_email_owner(struct wy_metadef *def, void *data) { - struct file_triplet *trp = data; + wy_triplet_t trp = data; mu_address_t addr; addr = get_owner_address(trp); if (!addr) { wy_log(LOG_ERR, _("cannot get email of the %s's owner"), - trp->project); + wy_triplet_project(trp)); def->value = ""; } else { if (mu_address_aget_printable(addr, &def->storage) == 0) @@ -703,13 +700,13 @@ expand_email_owner(struct metadef *def, void *data) } static void -t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) +t_notify(struct mailevt *evt, int ev, wy_triplet_t trp) { mu_address_t rcpt = NULL; const char *errp; char *text; const char *msg; - static struct metadef email_meta[] = { + static struct wy_metadef email_meta[] = { { "email:admin", NULL, expand_email_admin, NULL }, { "email:owner", NULL, expand_email_owner, NULL }, { NULL } @@ -730,7 +727,8 @@ t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) wy_log(LOG_ERR, _("not notifying %s (project %s) about %s: %s"), ntfrcpt_str(evt->rcpt), - trp->project, notification_event_str(ev), + wy_triplet_project(trp), + wy_event_str(ev), gettext(errp)); return; } @@ -742,7 +740,8 @@ t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) wy_log(LOG_ERR, _("not notifying %s (project %s) about %s"), ntfrcpt_str(evt->rcpt), - trp->project, notification_event_str(ev)); + wy_triplet_project(trp), + wy_event_str(ev)); return; } } @@ -754,13 +753,14 @@ t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) if (mu_address_sget_printable(rcpt, &s) == 0) wy_log(LOG_DEBUG, _("notifying %s (project %s) about %s"), - s, trp->project, - notification_event_str(ev)); + s, wy_triplet_project(trp), + wy_event_str(ev)); } else wy_log(LOG_DEBUG, _("notifying message recipients (project %s) " "about %s"), - trp->project, notification_event_str(ev)); + wy_triplet_project(trp), + wy_event_str(ev)); } msg = resolve_message_template(evt->msg); @@ -768,7 +768,7 @@ t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) wy_log(LOG_ERR, _("undefined message reference: %s"), evt->msg); else { - text = triplet_expand_param(msg, trp, email_meta); + text = wy_triplet_expand_param(msg, trp, email_meta); mail_send_message(rcpt, text, evt->sign_keys); free(text); } @@ -780,13 +780,10 @@ t_notify(struct mailevt *evt, int ev, struct file_triplet *trp) static void mail_stats(struct mailevt *evt) { - struct metadef *exp; - time_t t; const char *tmpl; char *text; - size_t tc; - if (!admin_stat_message || !stat_mask_p(mail_admin_mask) || !mailer) + if (!admin_stat_message || !wy_stat_mask_p(mail_admin_mask) || !mailer) return; if (!admin_address) { @@ -802,37 +799,26 @@ mail_stats(struct mailevt *evt) wy_log(LOG_DEBUG, _("sending stats to %s"), s); } - tc = timer_get_count() * 3; - exp = make_stat_expansion(tc + 1); - time(&t); - exp[0].kw = "date"; - exp[0].value = exp[0].storage = grecs_strdup(ctime(&t)); - exp[0].value[strlen(exp[0].value) - 1] = 0; - timer_fill_meta(exp + 1, tc); - tmpl = resolve_message_template(admin_stat_message); if (!tmpl) { wy_log(LOG_ERR, _("undefined message reference: %s"), admin_stat_message); return; } - text = meta_expand_string(tmpl, exp, NULL, NULL, NULL); + text = wy_expand_stats(tmpl); mail_send_message(admin_address, text, admin_stat_sign_key); free(text); - meta_free(exp); - timer_free_meta(exp + 1, tc); - free(exp); } void -mod_mailutils_LTX_notify(void *data, int ev, struct file_triplet *trp) +wy_notify(void *data, int ev, wy_triplet_t trp) { struct mailevt *evt = data; if (trp) t_notify(evt, ev, trp); - else if (ev == ev_statistics) + else if (ev == wy_ev_statistics) mail_stats(evt); } diff --git a/src/Makefile.am b/src/Makefile.am index 7b350e5..c4be551 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,8 +67,9 @@ SUFFIXES=.opt .c .h incdir=$(pkgdatadir)/$(VERSION)/include inc_DATA = $(PP_SETUP_FILE) -LDADD=../grecs/src/libgrecs.a @SQLLIB@ @GPGMELIB@ @LIBLTDL@ +LDADD=@GRECS_LDADD@ @SQLLIB@ @GPGMELIB@ @LIBLTDL@ AM_CPPFLAGS= \ + -I$(top_srcdir)/include\ -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@\ -DSYSCONFDIR=\"$(sysconfdir)\"\ -DLOCALSTATEDIR=\"$(localstatedir)\"\ diff --git a/src/cmdline.opt b/src/cmdline.opt index ef89222..039dc6b 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -69,7 +69,7 @@ OPTION(dry-run,n,, BEGIN wy_log_to_stderr = 1; wy_debug_level++; - dry_run_mode = 1; + wy_dry_run = 1; END OPTION(cron,,, diff --git a/src/config.c b/src/config.c index b89beff..eef4ee1 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007-2012 Sergey Poznyakoff + Copyright (C) 2007-2013 Sergey Poznyakoff Wydawca is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -205,17 +205,17 @@ safe_file_name_alloc(const char *file_name) } static struct keyword event_tab[] = { - { "success", ev_success }, - { "bad-ownership", ev_bad_ownership }, - { "bad-directive-signature", ev_bad_directive_signature }, - { "bad-detached-signature", ev_bad_detached_signature }, - { "check-failure", ev_check_fail }, - { "statistics", ev_statistics }, + { "success", wy_ev_success }, + { "bad-ownership", wy_ev_bad_ownership }, + { "bad-directive-signature", wy_ev_bad_directive_signature }, + { "bad-detached-signature", wy_ev_bad_detached_signature }, + { "check-failure", wy_ev_check_fail }, + { "statistics", wy_ev_statistics }, {NULL} }; const char * -notification_event_str(enum notification_event evt) +wy_event_str(enum wy_event evt) { const char *ret; if (tok_to_keyword(evt, event_tab, &ret)) { @@ -229,8 +229,8 @@ notification_event_str(enum notification_event evt) } int -string_to_notification_event(grecs_locus_t *locus, const char *val, - enum notification_event *pret) +string_to_wy_event(grecs_locus_t *locus, const char *val, + enum wy_event *pret) { int res; if (keyword_to_tok(val, event_tab, &res)) { @@ -717,13 +717,13 @@ static int cb_event(enum grecs_callback_command cmd, grecs_node_t *node, void *varptr, void *cb_data) { - enum notification_event *pev = varptr; + enum wy_event *pev = varptr; grecs_locus_t *locus = &node->locus; grecs_value_t *value = node->v.value; if (wy_assert_string_arg(locus, cmd, value)) return 1; - string_to_notification_event(&value->locus, value->v.string, pev); + string_to_wy_event(&value->locus, value->v.string, pev); return 0; } @@ -1334,7 +1334,7 @@ static struct grecs_keyword wydawca_kw[] = { grecs_type_string, GRECS_LIST, &all_spool_aliases }, { "gpg-homedir", NULL, N_("GPG home directory"), - grecs_type_string, GRECS_DFLT, &wydawca_gpg_homedir }, + grecs_type_string, GRECS_DFLT, &wy_gpg_homedir }, {NULL} }; diff --git a/src/directive.c b/src/directive.c index 481e267..c7e1817 100644 --- a/src/directive.c +++ b/src/directive.c @@ -20,7 +20,7 @@ /* Parse directives from TRP->blurb. Fill TRP->directive */ int -directive_parse(struct file_triplet *trp) +directive_parse(struct wy_triplet *trp) { size_t dcount, i, j; char *p; @@ -61,7 +61,7 @@ directive_parse(struct file_triplet *trp) /* If a directive KEY exists in the triplet TRP, return 0 and point PVAL (unless it is NULL) to its value. Othervise, return 1. */ int -directive_get_value(struct file_triplet *trp, const char *key, +directive_get_value(struct wy_triplet *trp, const char *key, const char **pval) { int keylen = strlen(key); @@ -94,7 +94,7 @@ directive_get_value(struct file_triplet *trp, const char *key, If N points past all the directive, the function returns 0. */ static int -_directive_seq_get(int n, struct file_triplet *trp, +_directive_seq_get(int n, struct wy_triplet *trp, const char **pkey, const char **pval) { char *p; @@ -121,7 +121,7 @@ _directive_seq_get(int n, struct file_triplet *trp, /* Get the first directive from TRP. Point *PKEY to its keyword and *PVAL to its value. Return 1 on success, 0 on failure. */ int -directive_first(struct file_triplet *trp, const char **pkey, const char **pval) +directive_first(struct wy_triplet *trp, const char **pkey, const char **pval) { int n = 0; return _directive_seq_get(n, trp, pkey, pval); @@ -131,7 +131,7 @@ directive_first(struct file_triplet *trp, const char **pkey, const char **pval) *PVAL to its value. Return 1 on success, 0 on failure. Return non-0 on success, 0 on failure */ int -directive_next(struct file_triplet *trp, int n, +directive_next(struct wy_triplet *trp, int n, const char **pkey, const char **pval) { return _directive_seq_get(n, trp, pkey, pval); @@ -166,7 +166,7 @@ directive_unpack_version(unsigned version, char **pbuf, size_t * psize) /* Return true if the directory file version of the triplet TRP is within the inclusive range FROM and TO (packed) */ int -directive_version_in_range_p(struct file_triplet *trp, +directive_version_in_range_p(struct wy_triplet *trp, unsigned from, unsigned to) { const char *val; @@ -238,7 +238,7 @@ find_directive(const char *key) /* Return 0 if the directory file format of the triplet TRP is OK. */ int -verify_directive_format(struct file_triplet *trp) +verify_directive_format(struct wy_triplet *trp) { int n, dnum; const char *key; @@ -387,7 +387,7 @@ stderr_redirector(const char *tag) } static int -run_check_script(const char *script, struct file_triplet *trp, +run_check_script(const char *script, struct wy_triplet *trp, const char *descr) { static char *script_file; @@ -527,7 +527,7 @@ run_check_script(const char *script, struct file_triplet *trp, } static int -external_check(struct file_triplet *trp) +external_check(struct wy_triplet *trp) { int rc; const struct spool *spool = trp->spool; @@ -557,14 +557,14 @@ external_check(struct file_triplet *trp) if (rc) { UPDATE_STATS(STAT_CHECK_FAIL); - notify(spool->notification, trp, ev_check_fail); + notify(spool->notification, trp, wy_ev_check_fail); } return rc; } static int -symlink_filelist(struct file_triplet *trp, const char *key, const char *val) +symlink_filelist(struct wy_triplet *trp, const char *key, const char *val) { int rc = 0; struct wordsplit ws; @@ -589,7 +589,7 @@ symlink_filelist(struct file_triplet *trp, const char *key, const char *val) /* Process the directives from TRP */ int -process_directives(struct file_triplet *trp) +process_directives(struct wy_triplet *trp) { int rc, n; const char *key, *val; @@ -663,7 +663,7 @@ process_directives(struct file_triplet *trp) } } - if (!dry_run_mode && unlink(trp->file[file_directive].name)) { + if (!wy_dry_run && unlink(trp->file[file_directive].name)) { wy_log(LOG_CRIT, _("%s: cannot unlink directive file: %s"), trp->file[file_directive].name, strerror(errno)); } @@ -671,6 +671,6 @@ process_directives(struct file_triplet *trp) UPDATE_STATS(STAT_TRIPLET_SUCCESS); report_finish(); timer_stop("triplet"); - notify(spool->notification, trp, ev_success); + notify(spool->notification, trp, wy_ev_success); return 0; } diff --git a/src/diskio.c b/src/diskio.c index 99d3b54..d083d2a 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -102,14 +102,14 @@ create_hierarchy(char *dir, size_t baselen) /* Create a directory BASE/NAME (with eventual intermediate directories in NAME). - Do nothing if dry_run_mode is set. */ + Do nothing if wy_dry_run is set. */ char * create_directory(const char *base, const char *name) { size_t baselen; char *dir = concat_dir(base, name, &baselen); - if (!dry_run_mode) { + if (!wy_dry_run) { if (create_hierarchy(dir, baselen)) { free(dir); dir = NULL; @@ -225,14 +225,14 @@ do_move_file(const char *file, const char *dst_file) } /* Append the FILE to the tar ARCHIVE. - Do nothing if dry_run_mode is set. */ + Do nothing if wy_dry_run is set. */ int tar_append_file(const char *archive, const char *file) { const char *argv[6]; wy_debug(1, (_("tarring %s to %s"), file, archive)); - if (dry_run_mode) { + if (wy_dry_run) { UPDATE_STATS(STAT_ARCHIVES); return 0; } @@ -266,7 +266,7 @@ tar_append_file(const char *archive, const char *file) ARCHIVE - Archive descriptor. RELDIR - Directory part of FILE - Do nothing if dry_run_mode is set. */ + Do nothing if wy_dry_run is set. */ int backup_file(const char *dst_file, const char *dst_dir, const char *file, const struct archive_descr *archive, const char *reldir) @@ -288,7 +288,7 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file, wy_debug(1, (_("removing previous archive " "file `%s'"), file_name)); - if (!dry_run_mode && unlink(file_name)) { + if (!wy_dry_run && unlink(file_name)) { wy_log(LOG_ERR, _("cannot unlink previous archive " "file `%s': %s"), @@ -304,7 +304,7 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file, wy_debug(1, (_("backing up previous archive " "file `%s' to `%s'"), file_name, archive_file_name)); - if (!dry_run_mode) { + if (!wy_dry_run) { rc = do_move_file(file_name, archive_file_name); if (rc) { @@ -323,7 +323,7 @@ backup_file(const char *dst_file, const char *dst_dir, const char *file, } wy_debug(1, (_("archiving `%s' to `%s'"), dst_file, file_name)); - if (!dry_run_mode) { + if (!wy_dry_run) { rc = do_move_file(dst_file, file_name); if (rc) wy_log(LOG_ERR, _("archiving `%s' as `%s' failed: %s"), @@ -357,7 +357,7 @@ do_archive_file(const char *dst_file, const char *dst_dir, const char *file, break; } - if (!dry_run_mode && unlink(dst_file) && errno != ENOENT) { + if (!wy_dry_run && unlink(dst_file) && errno != ENOENT) { wy_log(LOG_ERR, _("canot unlink file `%s': %s"), dst_file, strerror(errno)); return 1; @@ -366,7 +366,7 @@ do_archive_file(const char *dst_file, const char *dst_dir, const char *file, } static int -replace_allowed_p(struct file_triplet *trp) +replace_allowed_p(struct wy_triplet *trp) { const char *val; @@ -388,9 +388,9 @@ dir_get_path(struct spool *sp) TRP->SPOOL. TRP->RELATIVE_DIR gives relative directory (i.e. the directory part of the file name) for backup purposes. - Do nothing if dry_run_mode is set. */ + Do nothing if wy_dry_run is set. */ int -dir_move_file(struct file_triplet *trp, enum file_type file_id) +dir_move_file(struct wy_triplet *trp, enum file_type file_id) { char *dst_file; int rc = 0; @@ -421,7 +421,7 @@ dir_move_file(struct file_triplet *trp, enum file_type file_id) } } - if (!dry_run_mode && rc == 0) + if (!wy_dry_run && rc == 0) rc = do_move_file(trp->file[file_id].name, dst_file); free(dst_file); @@ -433,10 +433,10 @@ dir_move_file(struct file_triplet *trp, enum file_type file_id) /* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the file. Get user IDs from the triplet TRP. - Do nothing if dry_run_mode is set. + Do nothing if wy_dry_run is set. */ int -archive_single_file(struct file_triplet *trp, const char *file_name, +archive_single_file(struct wy_triplet *trp, const char *file_name, int noentok) { char *dst_file; @@ -495,10 +495,10 @@ make_signame(const char *file_name) /* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the file. Get user IDs from the triplet TRP. Unless FILE_NAME ends in ".sig", do the same with FILE_NAME.sig, if such a file exists. - Do nothing if dry_run_mode is set. + Do nothing if wy_dry_run is set. */ int -dir_archive_file(struct file_triplet *trp, const char *file_name) +dir_archive_file(struct wy_triplet *trp, const char *file_name) { int rc; char *signame; @@ -515,9 +515,9 @@ dir_archive_file(struct file_triplet *trp, const char *file_name) /* Create a symbolic link from WANTED_SRC to WANTED_DST in the subdirectory TRP->relative_dir of SPOOL->dest_dir. - Do nothing if dry_run_mode is set. */ + Do nothing if wy_dry_run is set. */ int -dir_symlink_file(struct file_triplet *trp, +dir_symlink_file(struct wy_triplet *trp, const char *wanted_src, const char *wanted_dst) { int rc = 0; @@ -550,7 +550,7 @@ dir_symlink_file(struct file_triplet *trp, wy_debug(1, (_("symlinking %s to %s in directory %s"), src, dst, dst_dir)); - if (!dry_run_mode) { + if (!wy_dry_run) { char *p = strrchr(dst, '/'); if (p > dst) { char *dir; @@ -639,7 +639,7 @@ do_rmsymlink_file(const char *dst_file, int noentok) return 1; } } - if (!dry_run_mode |