summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 13:03:59 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-03-12 13:22:13 (GMT)
commit1ba8cf95a5f536d4aa6293f9848271a7285bc092 (patch) (side-by-side diff)
treedede8a4bccb1daad8b67530d87845e7fe05749e6 /src
parent293108d7806aa3c0c5e706237b3788b261779e66 (diff)
downloadwydawca-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
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/Makefile.am3
-rw-r--r--src/cmdline.opt2
-rw-r--r--src/config.c26
-rw-r--r--src/directive.c28
-rw-r--r--src/diskio.c46
-rw-r--r--src/event.c6
-rw-r--r--src/gpg.c14
-rw-r--r--src/job.c12
-rw-r--r--src/meta.c39
-rw-r--r--src/module.c4
-rw-r--r--src/null.c10
-rw-r--r--src/timer.c8
-rw-r--r--src/triplet.c176
-rw-r--r--src/verify.c6
-rw-r--r--src/vtab.c8
-rw-r--r--src/watcher.c2
-rw-r--r--src/wydawca.c16
-rw-r--r--src/wydawca.h150
18 files changed, 268 insertions, 288 deletions
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 && unlink(dst_file)) {
+ if (!wy_dry_run && unlink(dst_file)) {
wy_log(LOG_ERR, _("cannot unlink %s: %s"), dst_file,
strerror(errno));
return 1;
@@ -650,9 +650,9 @@ do_rmsymlink_file(const char *dst_file, int noentok)
/* Remove the symbolic link TRP->spool->dest_dir/TRP->relative_dir/FILE_NAME
- Do nothing if dry_run_mode is set. */
+ Do nothing if wy_dry_run is set. */
int
-dir_rmsymlink_file(struct file_triplet *trp, const char *file_name)
+dir_rmsymlink_file(struct wy_triplet *trp, const char *file_name)
{
char *dst_file;
int rc = 0;
diff --git a/src/event.c b/src/event.c
index 548a316..0e19d7b 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1,8 +1,8 @@
#include "wydawca.h"
void
-notify(struct notification *n, struct file_triplet *t,
- enum notification_event e)
+notify(struct notification *n, struct wy_triplet *t,
+ enum wy_event e)
{
for (; n; n = n->next)
if (n->ev == e) {
@@ -14,7 +14,7 @@ notify(struct notification *n, struct file_triplet *t,
void
notify_stats()
{
- notify(default_notification, NULL, ev_statistics);
+ notify(default_notification, NULL, wy_ev_statistics);
}
void
diff --git a/src/gpg.c b/src/gpg.c
index ca7c185..ff55619 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -134,7 +134,7 @@ create_gpg_homedir()
}
static int
-checksig(gpgme_signature_t sig, const char *uid, struct file_triplet *trp)
+checksig(gpgme_signature_t sig, const char *uid, struct wy_triplet *trp)
{
switch (gpg_err_code(sig->status)) {
case GPG_ERR_NO_ERROR:
@@ -184,7 +184,7 @@ checksig(gpgme_signature_t sig, const char *uid, struct file_triplet *trp)
static int
gpg_verify_signature(gpgme_ctx_t ctx, gpgme_signature_t sig,
- struct file_triplet *trp)
+ struct wy_triplet *trp)
{
if (!sig)
return 0;
@@ -208,7 +208,7 @@ gpg_verify_signature(gpgme_ctx_t ctx, gpgme_signature_t sig,
/* Verify the directive file from TRP using public key PUBKEY */
int
-verify_directive_signature(struct file_triplet *trp)
+verify_directive_signature(struct wy_triplet *trp)
{
gpgme_ctx_t ctx;
gpgme_data_t key_data, directive_data, plain = NULL;
@@ -219,7 +219,7 @@ verify_directive_signature(struct file_triplet *trp)
create_gpg_homedir();
fail_if_err(gpgme_new(&ctx));
- for (uptr = triplet_get_uploaders(trp); uptr; uptr = uptr->next) {
+ for (uptr = wy_triplet_get_uploaders(trp); uptr; uptr = uptr->next) {
gpgme_import_result_t res;
gpgme_import_status_t pstat;
@@ -246,7 +246,7 @@ verify_directive_signature(struct file_triplet *trp)
if (!gpg_verify_signature(ctx, result->signatures, trp)) {
UPDATE_STATS(STAT_BAD_SIGNATURE);
notify(trp->spool->notification, trp,
- ev_bad_directive_signature);
+ wy_ev_bad_directive_signature);
rc = 1;
} else
rc = 0;
@@ -269,7 +269,7 @@ verify_directive_signature(struct file_triplet *trp)
NOTE: It is assumed that the public key is already registered (by
a previous call to verify_directive_signature). */
int
-verify_detached_signature(struct file_triplet *trp)
+verify_detached_signature(struct wy_triplet *trp)
{
gpgme_engine_info_t info;
const char *argv[5];
@@ -302,7 +302,7 @@ verify_detached_signature(struct file_triplet *trp)
case exec_fail:
UPDATE_STATS(STAT_BAD_SIGNATURE);
wy_log(LOG_ERR, _("BAD detached signature for %s"), trp->name);
- notify(spool->notification, trp, ev_bad_detached_signature);
+ notify(spool->notification, trp, wy_ev_bad_detached_signature);
break;
case exec_error:
diff --git a/src/job.c b/src/job.c
index 316a6a2..680f454 100644
--- a/src/job.c
+++ b/src/job.c
@@ -26,7 +26,7 @@ struct job {
struct job *next, *prev;
int state;
struct spool *spool;
- struct file_triplet *triplet_list;
+ struct wy_triplet *triplet_list;
uid_t uid;
pid_t pid;
time_t timestamp;
@@ -57,7 +57,7 @@ set_timer(time_t interval)
}
void
-triplet_jq_unlink(struct file_triplet *tp)
+triplet_jq_unlink(struct wy_triplet *tp)
{
if (!tp || !tp->job)
return;
@@ -75,12 +75,12 @@ triplet_jq_unlink(struct file_triplet *tp)
void
jq_clear(struct job *job)
{
- struct file_triplet *tp;
+ struct wy_triplet *tp;
if (!job->triplet_list)
return;
for (tp = job->triplet_list; tp; ) {
- struct file_triplet *next = tp->jq_next;
+ struct wy_triplet *next = tp->jq_next;
remove_triplet(tp, 1);
tp = next;
}
@@ -111,7 +111,7 @@ job_active_count()
static int
procspool(struct spool *spool, void *data)
{
- struct file_triplet *trp = *(struct file_triplet **)data;
+ struct wy_triplet *trp = *(struct wy_triplet **)data;
if (!trp)
return 0;
@@ -229,7 +229,7 @@ job_insert(struct job *job, struct job *elt)
}
void
-schedule_job(struct spool *spool, uid_t uid, struct file_triplet *tp)
+schedule_job(struct spool *spool, uid_t uid, struct wy_triplet *tp)
{
struct job *job;
diff --git a/src/meta.c b/src/meta.c
index eac2d68..338d624 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -18,7 +18,7 @@
#include "sql.h"
static const char *
-meta_expand(struct metadef *def, void *data)
+meta_expand(struct wy_metadef *def, void *data)
{
if (!def->value) {
if (def->expand)
@@ -29,7 +29,7 @@ meta_expand(struct metadef *def, void *data)
}
static const char *
-find_expansion_char(int c, struct metadef *def, void *data)
+find_expansion_char(int c, struct wy_metadef *def, void *data)
{
for (; def->kw; def++)
if (def->kw[1] == 0 && def->kw[0] == c)
@@ -38,7 +38,7 @@ find_expansion_char(int c, struct metadef *def, void *data)
}
static const char *
-find_expansion_word(const char *kw, size_t len, struct metadef *def,
+find_expansion_word(const char *kw, size_t len, struct wy_metadef *def,
void *data)
{
for (; def->kw; def++)
@@ -48,7 +48,7 @@ find_expansion_word(const char *kw, size_t len, struct metadef *def,
}
char *
-meta_expand_string(const char *string, struct metadef *def, void *data,
+meta_expand_string(const char *string, struct wy_metadef *def, void *data,
struct dictionary *dict, void *handle)
{
const char *p, *s;
@@ -135,7 +135,7 @@ meta_expand_string(const char *string, struct metadef *def, void *data,
}
void
-meta_free(struct metadef *def)
+meta_free(struct wy_metadef *def)
{
for (; def->kw; def++) {
if (def->storage) {
@@ -145,10 +145,10 @@ meta_free(struct metadef *def)
}
}
-struct metadef *
-metadef_join(struct metadef *a, struct metadef *b)
+struct wy_metadef *
+metadef_join(struct wy_metadef *a, struct wy_metadef *b)
{
- struct metadef *np;
+ struct wy_metadef *np;
size_t i, j;
for (i = 0; a[i].kw; i++);
@@ -163,3 +163,26 @@ metadef_join(struct metadef *a, struct metadef *b)
np[i + j].kw = NULL;
return np;
}
+
+char *
+wy_expand_stats(const char *tmpl)
+{
+ struct wy_metadef *exp;
+ time_t t;
+ size_t tc;
+ char *text;
+
+ 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);
+ text = meta_expand_string(tmpl, exp, NULL, NULL, NULL);
+ meta_free(exp);
+ timer_free_meta(exp + 1, tc);
+ free(exp);
+
+ return text;
+}
diff --git a/src/module.c b/src/module.c
index aa41264..212b740 100644
--- a/src/module.c
+++ b/src/module.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
@@ -233,7 +233,7 @@ module_set_init(const char *name, grecs_node_t *node)
void
module_notify(const char *name, void *modcfg,
- enum notification_event ev, struct file_triplet *trp)
+ enum wy_event ev, struct wy_triplet *trp)
{
struct module *mod = modlookup(name);
diff --git a/src/null.c b/src/null.c
index 4a55b00..74a1870 100644
--- a/src/null.c
+++ b/src/null.c
@@ -17,14 +17,14 @@
#include "wydawca.h"
int
-null_move_file(struct file_triplet *trp, enum file_type file_id)
+null_move_file(struct wy_triplet *trp, enum file_type file_id)
{
const struct spool *spool = trp->spool;
const char *file_name = trp->file[file_id].name;
wy_debug(1, (_("spool %s: installing file `%s/%s'"),
spool->tag, trp->relative_dir, file_name));
UPDATE_STATS(STAT_UPLOADS);
- if (!dry_run_mode && unlink(file_name)) {
+ if (!wy_dry_run && unlink(file_name)) {
wy_log(LOG_ERR, _("cannot unlink %s: %s"),
file_name, strerror(errno));
return 1;
@@ -33,7 +33,7 @@ null_move_file(struct file_triplet *trp, enum file_type file_id)
}
int
-null_archive_file(struct file_triplet *trp, const char *file_name)
+null_archive_file(struct wy_triplet *trp, const char *file_name)
{
wy_debug(1, (_("spool %s: archiving `%s'"),
trp->spool->tag, file_name));
@@ -42,7 +42,7 @@ null_archive_file(struct file_triplet *trp, const char *file_name)
}
int
-null_symlink_file(struct file_triplet *trp,
+null_symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
wy_debug(1, (_("spool %s: symlinking `%s' to `%s'"),
@@ -52,7 +52,7 @@ null_symlink_file(struct file_triplet *trp,
}
int
-null_rmsymlink_file(struct file_triplet *trp, const char *file_name)
+null_rmsymlink_file(struct wy_triplet *trp, const char *file_name)
{
wy_debug(1, (_("spool %s: removing symlink `%s/%s'"),
trp->spool->tag, trp->relative_dir, file_name));
diff --git a/src/timer.c b/src/timer.c
index 1c8d68d..1b73cbf 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -189,7 +189,7 @@ timer_get_count()
}
struct timer_data {
- struct metadef *def;
+ struct wy_metadef *def;
size_t num;
};
@@ -207,7 +207,7 @@ _fill_meta(void *sym, void *data)
grecs_alloc_die(); \
tp->def->kw = buf; \
tp->def->storage = \
- timer_format_time(__cat2__(timer_get_,arg)(slot)); \
+ timer_format_time(wy_s_cat2(timer_get_,arg)(slot)); \
tp->def->value = tp->def->storage; \
tp->def->expand = NULL; \
tp->def++; \
@@ -222,7 +222,7 @@ _fill_meta(void *sym, void *data)
}
void
-timer_fill_meta(struct metadef *def, size_t num)
+timer_fill_meta(struct wy_metadef *def, size_t num)
{
struct timer_data td;
if (!timer_table)
@@ -233,7 +233,7 @@ timer_fill_meta(struct metadef *def, size_t num)
}
void
-timer_free_meta(struct metadef *def, size_t num)
+timer_free_meta(struct wy_metadef *def, size_t num)
{
while (num--) {
free(def->kw);
diff --git a/src/triplet.c b/src/triplet.c
index 932ab86..1b3569f 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -20,15 +20,15 @@
/* Triplets are stored in a symtab: */
static struct grecs_symtab *triplet_table;
/* ... and are organized into a doubly-linked list, using the prev and
- next members of struct file_triplet. The list is ordered so that
+ next members of struct wy_triplet. The list is ordered so that
prev points to a triplet older than this one, and next points to a
newer triplet. The triplet_list variable points to the root of the
list, i.e. the oldest triplet available. */
-static struct file_triplet *triplet_list;
+static struct wy_triplet *triplet_list;
/* Functions for building the ordered doubly-linked list of triplets */
static time_t
-triplet_timestamp(struct file_triplet *tp)
+triplet_timestamp(struct wy_triplet *tp)
{
int i;
time_t t = 0;
@@ -45,7 +45,7 @@ triplet_timestamp(struct file_triplet *tp)
}
static time_t
-triplet_ttl(struct file_triplet *tp)
+triplet_ttl(struct wy_triplet *tp)
{
time_t t;
@@ -58,7 +58,7 @@ triplet_ttl(struct file_triplet *tp)
}
void
-triplet_list_unlink(struct file_triplet *tp)
+triplet_list_unlink(struct wy_triplet *tp)
{
if (tp->prev)
tp->prev->next = tp->next;
@@ -72,8 +72,8 @@ triplet_list_unlink(struct file_triplet *tp)
}
static void
-triplet_list_insert_before(struct file_triplet *newp,
- struct file_triplet *anchor)
+triplet_list_insert_before(struct wy_triplet *newp,
+ struct wy_triplet *anchor)
{
if (!anchor) {
triplet_list = newp;
@@ -91,10 +91,10 @@ triplet_list_insert_before(struct file_triplet *newp,
}
void
-triplet_list_ordered_insert(struct file_triplet *tp)
+triplet_list_ordered_insert(struct wy_triplet *tp)
{
time_t t = triplet_timestamp(tp);
- struct file_triplet *p, *prev = NULL;
+ struct wy_triplet *p, *prev = NULL;
for (p = triplet_list; p && triplet_timestamp(p) < t;
prev = p, p = p->next) ;
@@ -138,7 +138,7 @@ wy_userlist_free(struct wy_user *wp)
static unsigned
hash_triplet_hasher(void *data, unsigned long n_buckets)
{
- struct file_triplet const *t = data;
+ struct wy_triplet const *t = data;
return grecs_hash_string(t->name, n_buckets);
}
@@ -146,8 +146,8 @@ hash_triplet_hasher(void *data, unsigned long n_buckets)
static int
hash_triplet_compare(void const *data1, void const *data2)
{
- struct file_triplet const *t1 = data1;
- struct file_triplet const *t2 = data2;
+ struct wy_triplet const *t1 = data1;
+ struct wy_triplet const *t2 = data2;
return t1->spool == t2->spool && strcmp(t1->name, t2->name);
}
@@ -156,7 +156,7 @@ void
hash_triplet_free(void *data)
{
int i;
- struct file_triplet *tp = data;
+ struct wy_triplet *tp = data;
free(tp->name);
@@ -178,7 +178,7 @@ hash_triplet_free(void *data)
}
char *
-triplet_strdup(struct file_triplet *tp, const char *str)
+triplet_strdup(struct wy_triplet *tp, const char *str)
{
size_t len = strlen(str);
txtacc_grow(tp->acc, str, len + 1);
@@ -189,12 +189,12 @@ triplet_strdup(struct file_triplet *tp, const char *str)
void
register_file(struct file_info *finfo, const struct spool *spool)
{
- struct file_triplet key, *ret;
+ struct wy_triplet key, *ret;
int install = 1;
if (!triplet_table) {
triplet_table =
- grecs_symtab_create(sizeof(struct file_triplet),
+ grecs_symtab_create(sizeof(struct wy_triplet),
hash_triplet_hasher,
hash_triplet_compare,
NULL,
@@ -222,10 +222,10 @@ register_file(struct file_info *finfo, const struct spool *spool)
triplet_list_ordered_insert(ret);
}
-struct file_triplet *
+struct wy_triplet *
triplet_lookup(struct spool *spool, const char *name)
{
- struct file_triplet key, *ret;
+ struct wy_triplet key, *ret;
struct file_info finfo;
if (!triplet_table)
@@ -248,7 +248,7 @@ triplet_lookup(struct spool *spool, const char *name)
/* Return true if any part of the triplet TRP was modified more than
TTL seconds ago */
static int
-triplet_expired_p(struct file_triplet *trp)
+triplet_expired_p(struct wy_triplet *trp)
{
int i;
time_t now = time(NULL);
@@ -279,7 +279,7 @@ enum triplet_state {
};
static enum triplet_state
-check_triplet_state(struct file_triplet *trp, int noauth)
+check_triplet_state(struct wy_triplet *trp, int noauth)
{
if (trp->file[file_directive].name) {
if (verify_directive_file(trp, noauth))
@@ -310,7 +310,7 @@ check_triplet_state(struct file_triplet *trp, int noauth)
/* Unlink all parts of the triplet TRP */
int
-remove_triplet(struct file_triplet *trp, int check)
+remove_triplet(struct wy_triplet *trp, int check)
{
int i;
@@ -326,7 +326,7 @@ remove_triplet(struct file_triplet *trp, int check)
} else {
wy_log(LOG_NOTICE, _("removing %s"),
trp->file[i].name);
- if (!dry_run_mode && unlink(trp->file[i].name))
+ if (!wy_dry_run && unlink(trp->file[i].name))
wy_log(LOG_ERR,
_("cannot remove %s: %s"),
trp->file[i].name,
@@ -353,7 +353,7 @@ triplet_sweep(void)
static int
triplet_processor(void *data, void *proc_data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
wy_debug(1, ("FILE %s, DIST=%s, SIG=%s, DIRECTIVE=%s",
trp->name,
@@ -391,7 +391,7 @@ triplet_processor(void *data, void *proc_data)
/* Process all triplets from the table according to the SPOOL */
void
-spool_commit_triplets(struct spool *spool, struct file_triplet *tplist)
+spool_commit_triplets(struct spool *spool, struct wy_triplet *tplist)
{
wy_debug(1, (_("processing spool %s (%s)"),
spool->tag, wy_url_printable(spool->dest_url)));
@@ -399,7 +399,7 @@ spool_commit_triplets(struct spool *spool, struct file_triplet *tplist)
return;
if (tplist) {
while (tplist) {
- struct file_triplet *next = tplist->jq_next;
+ struct wy_triplet *next = tplist->jq_next;
if (tplist->spool == spool)
triplet_processor(tplist, NULL);
tplist = next;
@@ -417,13 +417,13 @@ count_collected_triplets()
}
struct count_closure {
- struct file_triplet *tp;
+ struct wy_triplet *tp;
};
static int
triplet_linker(void *data, void *proc_data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
struct count_closure *cp = proc_data;
if (trp->job)
@@ -456,7 +456,7 @@ triplet_linker(void *data, void *proc_data)
return 0;
}
-struct file_triplet *
+struct wy_triplet *
link_processable_triplets()
{
struct count_closure clos;
@@ -470,7 +470,7 @@ link_processable_triplets()
void
triplet_remove_file(struct spool *spool, const char *name)
{
- struct file_triplet *tp = triplet_lookup(spool, name);
+ struct wy_triplet *tp = triplet_lookup(spool, name);
int i, n = 0;
if (!tp)
@@ -493,45 +493,45 @@ triplet_remove_file(struct spool *spool, const char *name)
}
static const char *
-expand_project_base(struct metadef *def, void *data)
+expand_project_base(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->project;
}
static const char *
-expand_tag(struct metadef *def, void *data)
+expand_tag(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->spool->tag;
}
static const char *
-expand_url(struct metadef *def, void *data)
+expand_url(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->spool->url;
}
static const char *
-expand_relative_dir(struct metadef *def, void *data)
+expand_relative_dir(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
directive_get_value(trp, "directory", (const char **)&def->value);
return def->value;
}
static const char *
-expand_dest_dir(struct metadef *def, void *data)
+expand_dest_dir(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->spool->dest_dir;
}
static const char *
-expand_source_dir(struct metadef *def, void *data)
+expand_source_dir(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->spool->source_dir;
}
@@ -561,7 +561,7 @@ decode_file_mode(mode_t mode, char *string)
static int ugswidth = 19;
static int
-format_file_data(struct file_triplet *trp, enum file_type type, char **pret)
+format_file_data(struct wy_triplet *trp, enum file_type type, char **pret)
{
char modes[11];
struct file_info *info = trp->file + type;
@@ -623,9 +623,9 @@ format_file_data(struct file_triplet *trp, enum file_type type, char **pret)
}
static const char *
-expand_triplet_ls_full(struct metadef *def, void *data)
+expand_triplet_ls_full(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
char *buf[FILE_TYPE_COUNT] = { NULL, NULL, NULL };
size_t size = 0;
@@ -657,9 +657,9 @@ expand_triplet_ls_full(struct metadef *def, void *data)
}
static const char *
-expand_triplet_ls_upload(struct metadef *def, void *data)
+expand_triplet_ls_upload(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
char *buf[2] = { NULL, NULL };
size_t size = 0;
@@ -686,57 +686,57 @@ expand_triplet_ls_upload(struct metadef *def, void *data)
}
static const char *
-expand_triplet_dist(struct metadef *def, void *data)
+expand_triplet_dist(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->file[file_dist].name;
}
static const char *
-expand_triplet_sig(struct metadef *def, void *data)
+expand_triplet_sig(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->file[file_signature].name;
}
static const char *
-expand_triplet_dir(struct metadef *def, void *data)
+expand_triplet_dir(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->file[file_directive].name;
}
static const char *
-expand_triplet_ls_dist(struct metadef *def, void *data)
+expand_triplet_ls_dist(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
format_file_data(trp, file_dist, &def->storage);
def->value = def->storage;
return def->value;
}
static const char *
-expand_triplet_ls_sig(struct metadef *def, void *data)
+expand_triplet_ls_sig(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
format_file_data(trp, file_signature, &def->storage);
def->value = def->storage;
return def->value;
}
static const char *
-expand_triplet_ls_directive(struct metadef *def, void *data)
+expand_triplet_ls_directive(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
format_file_data(trp, file_directive, &def->storage);
def->value = def->storage;
return def->value;
}
static const char *
-expand_user_name(struct metadef *def, void *data)
+expand_user_name(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
if (trp->uploader)
return trp->uploader->name;
def->value = "UNKNOWN";
@@ -744,9 +744,9 @@ expand_user_name(struct metadef *def, void *data)
}
static const char *
-expand_user_real_name(struct metadef *def, void *data)
+expand_user_real_name(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
if (trp->uploader)
return trp->uploader->realname;
def->value = "UNKNOWN";
@@ -754,9 +754,9 @@ expand_user_real_name(struct metadef *def, void *data)
}
static const char *
-expand_user_email(struct metadef *def, void *data)
+expand_user_email(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
if (trp->uploader)
return trp->uploader->email;
def->value = "UNKNOWN";
@@ -764,9 +764,9 @@ expand_user_email(struct metadef *def, void *data)
}
static const char *
-expand_email_user(struct metadef *def, void *data)
+expand_email_user(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
if (trp->uploader) {
size_t size = 0;
if (grecs_asprintf(&def->storage, &size, "\"%s\" <%s>",
@@ -779,31 +779,31 @@ expand_email_user(struct metadef *def, void *data)
}
static const char *
-expand_report(struct metadef *def, void *data)
+expand_report(struct wy_metadef *def, void *data)
{
return report_string;
}
static const char *
-expand_comment(struct metadef *def, void *data)
+expand_comment(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
if (directive_get_value(trp, "comment", (const char **)&def->value))
def->value = "";
return def->value;
}
static const char *
-expand_check_diagn(struct metadef *def, void *data)
+expand_check_diagn(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
return trp->check_diag;
}
static const char *
-expand_check_result(struct metadef *def, void *data)
+expand_check_result(struct wy_metadef *def, void *data)
{
- struct file_triplet *trp = data;
+ struct wy_triplet *trp = data;
int status = trp->check_result;
if (status == 0)
@@ -827,10 +827,10 @@ expand_check_result(struct metadef *def, void *data)
#define DECL_EXPAND_TIMER(what) \
static const char * \
-__cat2__(expand_timer_,what) (struct metadef *def, void *data) \
+wy_s_cat2(expand_timer_,what) (struct wy_metadef *def, void *data) \
{ \
wydawca_timer_t t = timer_stop ((char*)def->data); \
- def->storage = timer_format_time (__cat2__(timer_get_,what) (t)); \
+ def->storage = timer_format_time (wy_s_cat2(timer_get_,what) (t)); \
return def->value = def->storage; \
}
@@ -838,12 +838,12 @@ DECL_EXPAND_TIMER(real)
DECL_EXPAND_TIMER(user)
DECL_EXPAND_TIMER(system)
#define DECL_TIMER(name,t) \
- { "timer:" #name ":" #t, NULL, __cat2__(expand_timer_,t), NULL, #name }
+ { "timer:" #name ":" #t, NULL, wy_s_cat2(expand_timer_,t), NULL, #name }
#define DECL_FULL_TIMER(name) \
DECL_TIMER(name, real), \
DECL_TIMER(name, user), \
DECL_TIMER(name, system)
-struct metadef triplet_default_meta[] = {
+struct wy_metadef triplet_default_meta[] = {
{ "u", NULL, expand_user_name, NULL },
{ "user", NULL, expand_user_name, NULL },
{ "user:name", NULL, expand_user_name, NULL },
@@ -860,7 +860,7 @@ struct metadef triplet_default_meta[] = {
char *
triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
- struct file_triplet const *trp)
+ struct wy_triplet const *trp)
{
char *p = meta_expand_string(dict->query, triplet_default_meta,
(void*) trp,
@@ -869,7 +869,7 @@ triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
return p;
}
-struct metadef triplet_meta[] = {
+struct wy_metadef triplet_meta[] = {
{ "project", NULL, expand_project_base, NULL },
{ "url", NULL, expand_url, NULL },
{ "spool", NULL, expand_tag, NULL },
@@ -900,11 +900,11 @@ struct metadef triplet_meta[] = {
};
char *
-triplet_expand_param(const char *tmpl, struct file_triplet const *trp,
- struct metadef *xmeta)
+wy_triplet_expand_param(const char *tmpl, struct wy_triplet const *trp,
+ struct wy_metadef *xmeta)
{
char *p;
- struct metadef *mp = metadef_join(triplet_meta, xmeta);
+ struct wy_metadef *mp = metadef_join(triplet_meta, xmeta);
p = meta_expand_string(tmpl, mp, (void *)trp, NULL, NULL);
meta_free(mp);
@@ -913,7 +913,7 @@ triplet_expand_param(const char *tmpl, struct file_triplet const *trp,
}
struct wy_user *
-triplet_get_uploaders(struct file_triplet *trp)
+wy_triplet_get_uploaders(struct wy_triplet *trp)
{
const struct spool *spool;
struct dictionary *dict;
@@ -1024,14 +1024,14 @@ triplet_get_uploaders(struct file_triplet *trp)
}
struct wy_user *
-triplet_get_uploader(struct file_triplet *trp)
+wy_triplet_get_uploader(struct wy_triplet *trp)
{
return trp->uploader;
}
struct wy_user *
-triplet_get_admins(struct file_triplet *trp)
+wy_triplet_get_admins(struct wy_triplet *trp)
{
const struct spool *spool;
struct dictionary *dict;
@@ -1116,3 +1116,9 @@ triplet_get_admins(struct file_triplet *trp)
return trp->admin_list;
}
+
+const char *
+wy_triplet_project(struct wy_triplet *trp)
+{
+ return trp->project;
+}
diff --git a/src/verify.c b/src/verify.c
index 464a2b3..2fea122 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -84,7 +84,7 @@ extract_plaintext(char *blurb)
}
int
-fill_project_name(struct file_triplet *trp)
+fill_project_name(struct wy_triplet *trp)
{
char *blurb;
size_t size;
@@ -178,7 +178,7 @@ uploader_find_frp(struct wy_user *list, const char *fpr)
}
int
-verify_directive_file(struct file_triplet *trp, int noath)
+verify_directive_file(struct wy_triplet *trp, int noath)
{
if (!trp->file[file_directive].name)
return 1;
@@ -187,7 +187,7 @@ verify_directive_file(struct file_triplet *trp, int noath)
return 1;
if (!noath) {
- if (!triplet_get_uploaders(trp))
+ if (!wy_triplet_get_uploaders(trp))
return 1;
if (verify_directive_signature(trp)) {
diff --git a/src/vtab.c b/src/vtab.c
index 6a23541..3715650 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -116,7 +116,7 @@ url_to_vtab(wy_url_t url, struct virt_tab *vtab)
}
int
-move_file(struct file_triplet *trp, enum file_type file_id)
+move_file(struct wy_triplet *trp, enum file_type file_id)
{
int rc = trp->spool->vtab.move_file(trp, file_id);
report_add("Move %s to %s: %s", trp->file[file_id].name,
@@ -125,7 +125,7 @@ move_file(struct file_triplet *trp, enum file_type file_id)
}
int
-archive_file(struct file_triplet *trp, const char *file_name)
+archive_file(struct wy_triplet *trp, const char *file_name)
{
int rc = trp->spool->vtab.archive_file(trp, file_name);
report_add("Archive and remove %s/%s: %s",
@@ -135,7 +135,7 @@ archive_file(struct file_triplet *trp, const char *file_name)
}
int
-symlink_file(struct file_triplet *trp,
+symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
int rc = trp->spool->vtab.symlink_file(trp, wanted_src, wanted_dst);
@@ -145,7 +145,7 @@ symlink_file(struct file_triplet *trp,
}
int
-rmsymlink_file(struct file_triplet *trp, const char *file_name)
+rmsymlink_file(struct wy_triplet *trp, const char *file_name)
{
int rc = trp->spool->vtab.rmsymlink_file(trp, file_name);
report_add("Remove symlink %s/%s: %s", trp->relative_dir, file_name,
diff --git a/src/watcher.c b/src/watcher.c
index 0af885b..da55861 100644
--- a/src/watcher.c
+++ b/src/watcher.c
@@ -148,7 +148,7 @@ process_event(struct inotify_event *ep)
{
static struct dirwatcher *dwp;
dwp = dirwatcher_find_wd(ep->wd);
- struct file_triplet *tp;
+ struct wy_triplet *tp;
if (ep->mask & IN_IGNORED)
/* nothing */ ;
diff --git a/src/wydawca.c b/src/wydawca.c
index e88ec34..3561994 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -24,7 +24,7 @@ gid_t *wydawca_supp_groups;
char *conffile = SYSCONFDIR "/wydawca.rc";
const char *wy_version = "wydawca (" PACKAGE_STRING ")";
int wy_debug_level;
-int dry_run_mode;
+int wy_dry_run;
int wy_log_to_stderr = -1; /* -1 means autodetect */
int wy_log_facility = LOG_LOCAL1;
char *wy_syslog_tag = "wydawca";
@@ -44,7 +44,7 @@ int foreground;
int single_process;
time_t wakeup_interval;
struct grecs_list *all_spool_aliases;
-char *wydawca_gpg_homedir;
+char *wy_gpg_homedir;
char *default_check_script;
struct grecs_sockaddr listen_sockaddr;
@@ -171,7 +171,7 @@ static char *stat_kwname[MAX_STAT] = {
};
int
-stat_mask_p(unsigned long mask)
+wy_stat_mask_p(unsigned long mask)
{
int i;
@@ -182,7 +182,7 @@ stat_mask_p(unsigned long mask)
}
static const char *
-stat_expand(struct metadef *def, void *data)
+stat_expand(struct wy_metadef *def, void *data)
{
size_t size = 0;
def->storage = NULL;
@@ -193,11 +193,11 @@ stat_expand(struct metadef *def, void *data)
return def->value;
}
-struct metadef *
+struct wy_metadef *
make_stat_expansion(size_t count)
{
int i;
- struct metadef *def, *p;
+ struct wy_metadef *def, *p;
def = grecs_calloc(MAX_STAT + count + 1, sizeof(def[0]));
p = def + count;
for (i = 0; i < MAX_STAT; i++, p++) {
@@ -216,7 +216,7 @@ logstats()
{
int i;
- if (stat_mask_p(print_stats)) {
+ if (wy_stat_mask_p(print_stats)) {
for (i = 0; i < MAX_STAT; i++)
if (print_stats & STAT_MASK(i))
wy_log(LOG_INFO, "%s: %u",
@@ -373,7 +373,7 @@ main(int argc, char **argv)
if (lint_mode)
exit(0);
- if (dry_run_mode || selected_spools())
+ if (wy_dry_run || selected_spools())
cron_option = 1;
if (cron_option)
daemon_mode = 0;
diff --git a/src/wydawca.h b/src/wydawca.h
index bec8666..55929ee 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -47,6 +47,8 @@
#include <mailutils/types.h>
#include <mailutils/errno.h>
+#include <wydawca/wydawca.h>
+
#include "grecs.h"
#include "wordsplit.h"
@@ -67,8 +69,6 @@
#define SUF_DIR ".directive.asc"
#define SUF_DIR_LEN (sizeof (SUF_DIR) - 1)
-#define __cat2__(a,b) a ## b
-#define __cat3__(a,b,c) a ## b ## c
#define NITEMS(a) (sizeof(a)/sizeof((a)[0]))
enum dictionary_id {
@@ -152,17 +152,8 @@ struct file_info {
struct stat sb;
};
-struct wy_user {
- struct wy_user *next;
- char *name;
- char *realname;
- char *email;
- char *gpg_key;
- char *fpr;
-};
-
/* File triplet */
-struct file_triplet {
+struct wy_triplet {
char *name; /* Triplet base name */
struct file_info file[FILE_TYPE_COUNT]; /* Components */
unsigned version; /* Protocol version */
@@ -177,9 +168,9 @@ struct file_triplet {
/* Triplets are joined in two doubly-linked lists:
1) a cronological list, with prev pointing to a triplet older
than this one, and next pointing to a triplet newer than it: */
- struct file_triplet *prev, *next;
+ struct wy_triplet *prev, *next;
/* 2) "job queue", a list of triplets processed by the same job: */
- struct file_triplet *jq_prev, *jq_next;
+ struct wy_triplet *jq_prev, *jq_next;
/* The job queue is used only when triplets are processed by
the inotify watcher. In that case, the job member points to
the job processing this request. When the job terminates, all
@@ -215,11 +206,11 @@ const char *wy_url_printable(wy_url_t url);
struct virt_tab {
int (*test_url) (wy_url_t url, grecs_locus_t * loc);
- int (*move_file) (struct file_triplet * trp, enum file_type file_id);
- int (*archive_file) (struct file_triplet * trp, const char *file_name);
- int (*symlink_file) (struct file_triplet * trp,
+ int (*move_file) (struct wy_triplet * trp, enum file_type file_id);
+ int (*archive_file) (struct wy_triplet * trp, const char *file_name);
+ int (*symlink_file) (struct wy_triplet * trp,
const char *wanted_src, const char *wanted_dst);
- int (*rmsymlink_file) (struct file_triplet * trp,
+ int (*rmsymlink_file) (struct wy_triplet * trp,
const char *file_name);
};
@@ -280,44 +271,25 @@ enum wydawca_stat {
int wy_cb_statistics(enum grecs_callback_command cmd, grecs_node_t *node,
void *varptr, void *cb_data);
-enum notification_event {
- ev_success,
- ev_bad_ownership,
- ev_bad_directive_signature,
- ev_bad_detached_signature,
- ev_check_fail,
- ev_statistics,
- MAX_EVENT
-};
-
struct notification {
struct notification *next;
- enum notification_event ev;
+ enum wy_event ev;
int statmask;
char *modname;
void *modcfg;
grecs_node_t *modnode;
};
-void notify(struct notification *, struct file_triplet *,
- enum notification_event);
+void notify(struct notification *, struct wy_triplet *,
+ enum wy_event);
void notify_stats(void);
void notify_flush(struct spool *sp);
-const char *notification_event_str(enum notification_event evt);
-struct metadef {
- char *kw;
- char *value;
- const char *(*expand) (struct metadef *, void *);
- char *storage;
- void *data;
-};
-
-char *meta_expand_string(const char *string, struct metadef *def, void *data,
+char *meta_expand_string(const char *string, struct wy_metadef *def, void *data,
struct dictionary *dict, void *handle);
-void meta_free(struct metadef *def);
-struct metadef *metadef_join(struct metadef *a, struct metadef *b);
+void meta_free(struct wy_metadef *def);
+struct wy_metadef *metadef_join(struct wy_metadef *a, struct wy_metadef *b);
/* Modules */
@@ -331,7 +303,7 @@ struct module {
void *handle;
int (*open) (grecs_node_t *);
void *(*config) (grecs_node_t *);
- int (*notify) (void *, int, struct file_triplet *);
+ int (*notify) (void *, int, struct wy_triplet *);
void (*flush) (void *);
void (*close) (void);
};
@@ -345,7 +317,7 @@ 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);
+ enum wy_event ev, struct wy_triplet *tpl);
void module_flush(const char *name, void *modcfg);
@@ -357,12 +329,6 @@ extern gid_t wydawca_gid;
extern size_t wydawca_supp_groupc;
extern gid_t *wydawca_supp_groups;
extern char *conffile; /* Configuration file name */
-extern const char *wy_version;
-extern int wy_debug_level; /* Debugging level */
-extern int dry_run_mode; /* Dry run indicator */
-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 */
extern int syslog_include_prio; /* Syslog priority indication */
extern time_t file_sweep_time; /* Unlink stale file after this amount of time
*/
@@ -387,7 +353,6 @@ extern struct grecs_sockaddr listen_sockaddr;
extern struct grecs_list *all_spool_aliases;
-extern char *wydawca_gpg_homedir;
extern char *default_check_script;
extern char *temp_homedir;
@@ -407,7 +372,7 @@ extern struct notification *default_notification;
} while (0)
int stat_mask_p(unsigned long mask);
-struct metadef *make_stat_expansion(size_t count);
+struct wy_metadef *make_stat_expansion(size_t count);
void initstats(void);
void logstats(void);
@@ -417,14 +382,6 @@ char *safe_file_name_alloc(const char *file_name);
size_t trim_length(const char *str);
size_t trim(char *str);
-void wy_log(int prio, char *fmt, ...) GSC_PRINTFLIKE(2, 3);
-void wy_dbg(char *fmt, ...) GSC_PRINTFLIKE(1, 2);
-#define wy_debug(l,c) do { \
- if (wy_debug_level >= (l)) \
- wy_dbg c; \
- } while(0)
-
-
int test_dir(const char *name, int *ec);
char *create_directory(const char *base, const char *name);
int create_hierarchy(char *dir, size_t baselen);
@@ -457,24 +414,17 @@ int for_each_spool(int (*fun) (struct spool *, void *), void *data);
void register_spool(struct spool *spool);
struct spool *wydawca_find_spool(const char *name);
void register_file(struct file_info *finfo, const struct spool *spool);
-void spool_commit_triplets(struct spool *, struct file_triplet *);
-struct file_triplet *link_processable_triplets(void);
+void spool_commit_triplets(struct spool *, struct wy_triplet *);
+struct wy_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
-struct wy_user *triplet_get_uploaders(struct file_triplet *trp);
-struct wy_user *triplet_get_admins(struct file_triplet *trp);
-
-struct wy_user *triplet_get_uploader(struct file_triplet *trp);
-
-char *triplet_expand_param(const char *tmpl, struct file_triplet const *trp,
- struct metadef *xmeta);
char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
- struct file_triplet const *trp);
+ struct wy_triplet const *trp);
void triplet_remove_file(struct spool *spool, const char *name);
time_t triplet_sweep(void);
-int remove_triplet(struct file_triplet *trp, int check);
+int remove_triplet(struct wy_triplet *trp, int check);
/* General-purpose dictionary support */
struct dictionary *dictionary_new(enum dictionary_id id,
@@ -495,33 +445,33 @@ unsigned dictionary_num_rows(struct dictionary *dict);
unsigned dictionary_num_cols(struct dictionary *dict);
/* Verification functions */
-int verify_directive_file(struct file_triplet *trp, int noath);
-int verify_directive_signature(struct file_triplet *trp);
-int verify_detached_signature(struct file_triplet *trp);
-int fill_project_name(struct file_triplet *trp);
+int verify_directive_file(struct wy_triplet *trp, int noath);
+int verify_directive_signature(struct wy_triplet *trp);
+int verify_detached_signature(struct wy_triplet *trp);
+int fill_project_name(struct wy_triplet *trp);
struct wy_user *uploader_find_frp(struct wy_user *list,
const char *frp);
/* Directive file support */
-int directive_parse(struct file_triplet *trp);
-int directive_get_value(struct file_triplet *trp, const char *key,
+int directive_parse(struct wy_triplet *trp);
+int directive_get_value(struct wy_triplet *trp, const char *key,
const char **pval);
int directive_pack_version(const char *val, unsigned *pversion);
int directive_unpack_version(unsigned version, char **pbuf, size_t * psize);
-int directive_version_in_range_p(struct file_triplet *trp,
+int directive_version_in_range_p(struct wy_triplet *trp,
unsigned from, unsigned to);
-int verify_directive_format(struct file_triplet *trp);
-int directive_first(struct file_triplet *trp, const char **pkey,
+int verify_directive_format(struct wy_triplet *trp);
+int directive_first(struct wy_triplet *trp, const char **pkey,
const char **pval);
-int directive_next(struct file_triplet *trp, int n,
+int directive_next(struct wy_triplet *trp, int n,
const char **pkey, const char **pval);
-int process_directives(struct file_triplet *trp);
+int process_directives(struct wy_triplet *trp);
int enabled_spool_p(const struct spool *spool);
int selected_spools(void);
-char *triplet_strdup(struct file_triplet *tp, const char *str);
+char *triplet_strdup(struct wy_triplet *tp, const char *str);
int parse_time_interval(const char *str, time_t * pint, const char **endp);
@@ -542,29 +492,29 @@ const char *wy_factostr(int fac);
/* vtab.c */
int url_to_vtab(wy_url_t url, struct virt_tab *vtab);
-int move_file(struct file_triplet *trp, enum file_type file_id);
-int archive_file(struct file_triplet *trp, const char *file_name);
-int symlink_file(struct file_triplet *trp,
+int move_file(struct wy_triplet *trp, enum file_type file_id);
+int archive_file(struct wy_triplet *trp, const char *file_name);
+int symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst);
-int rmsymlink_file(struct file_triplet *trp, const char *file_name);
+int rmsymlink_file(struct wy_triplet *trp, const char *file_name);
/* diskio.c */
char *concat_dir(const char *base, const char *name, size_t * pbaselen);
int copy_file(const char *file, const char *dst_file);
int dir_test_url(wy_url_t url, grecs_locus_t * locus);
-int dir_move_file(struct file_triplet *trp, enum file_type file_id);
-int dir_archive_file(struct file_triplet *trp, const char *reldir);
-int dir_symlink_file(struct file_triplet *trp,
+int dir_move_file(struct wy_triplet *trp, enum file_type file_id);
+int dir_archive_file(struct wy_triplet *trp, const char *reldir);
+int dir_symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst);
-int dir_rmsymlink_file(struct file_triplet *trp, const char *file_name);
+int dir_rmsymlink_file(struct wy_triplet *trp, const char *file_name);
/* null.c */
-int null_move_file(struct file_triplet *trp, enum file_type file_id);
-int null_archive_file(struct file_triplet *trp, const char *file_name);
-int null_symlink_file(struct file_triplet *trp,
+int null_move_file(struct wy_triplet *trp, enum file_type file_id);
+int null_archive_file(struct wy_triplet *trp, const char *file_name);
+int null_symlink_file(struct wy_triplet *trp,
const char *wanted_src, const char *wanted_dst);
-int null_rmsymlink_file(struct file_triplet *trp, const char *file_name);
+int null_rmsymlink_file(struct wy_triplet *trp, const char *file_name);
/* timer.c */
typedef struct timer_slot *wydawca_timer_t;
@@ -578,8 +528,8 @@ double timer_get_user(wydawca_timer_t t);
double timer_get_system(wydawca_timer_t t);
char *timer_format_time(double t);
size_t timer_get_count(void);
-void timer_fill_meta(struct metadef *def, size_t num);
-void timer_free_meta(struct metadef *def, size_t num);
+void timer_fill_meta(struct wy_metadef *def, size_t num);
+void timer_free_meta(struct wy_metadef *def, size_t num);
void report_init(void);
void report_add(const char *fmt, ...);
@@ -587,10 +537,10 @@ void report_finish(void);
extern char *report_string;
/* job.c */
-void schedule_job(struct spool *spool, uid_t uid, struct file_triplet *tp);
+void schedule_job(struct spool *spool, uid_t uid, struct wy_triplet *tp);
void job_init(void);
void job_queue_runner(time_t min_timeout);
-void triplet_jq_unlink(struct file_triplet *tp);
+void triplet_jq_unlink(struct wy_triplet *tp);
/* profile.c */
void check_pidfile(void);

Return to:

Send suggestions and report system problems to the System administrator.