aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 15:03:59 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 15:22:13 +0200
commit1ba8cf95a5f536d4aa6293f9848271a7285bc092 (patch)
treedede8a4bccb1daad8b67530d87845e7fe05749e6 /src/wydawca.h
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/wydawca.h')
-rw-r--r--src/wydawca.h150
1 files changed, 50 insertions, 100 deletions
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.