aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index 5de1f3e..722fc9b 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -196,48 +196,50 @@ struct file_triplet
};
/* Macros to access owner UID and GID. */
/* The directive file is always present in the triplet */
#define TRIPLET_UID(t) ((t)->file[file_directive].sb.st_uid)
/* GID is filled in after the triplet is finalized and verified */
#define TRIPLET_GID(t) ((t)->file[file_directive].sb.st_gid)
struct virt_tab
{
+ const char *(*get_path) (struct spool *sp);
int (*test_url) (mu_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,
const char *wanted_src,
const char *wanted_dst);
int (*rmsymlink_file)(struct file_triplet *trp, const char *file_name);
};
/* An upload spool. This structure contains all data necessary for releasing
files from source to destination */
struct spool
{
char *tag;
struct grecs_list *aliases;
char *url; /* Download URL */
char *source_dir; /* Source directory */
mu_url_t dest_url; /* Destination URL */
const char *dest_dir; /* Directory part of the above */
struct virt_tab vtab; /* Virtual method table */
time_t file_sweep_time; /* Remove invalid/unprocessed files
after this amount of time */
struct dictionary *dictionary[dictionary_count];
+ int dict_inited;
struct archive_descr archive; /* Archivation data */
struct notification *notification;
char *check_script;
};
#define ASGN_SPOOL(spool, trp, faction) \
do \
{ \
spool = (trp)->spool; \
if (!spool) \
{ \
logmsg (LOG_CRIT, \
@@ -363,24 +365,27 @@ extern int foreground;
extern int single_process;
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;
extern unsigned min_directive_version;
extern unsigned max_directive_version;
+extern struct spool fake_spool;
+extern struct spool inotify_spool;
+
#define UPDATE_STATS(what) \
do \
{ \
if (what >= MAX_STAT) abort(); \
wydawca_stat[what]++; \
} \
while (0)
int stat_mask_p (unsigned long mask);
struct metadef *make_stat_expansion (size_t count);
void initstats (void);
void logstats (void);
@@ -400,58 +405,70 @@ void log_output (int prio, const char *prog, FILE *fp);
enum exec_result
{
exec_success, /* Command executed and returned 0 */
exec_fail, /* Command executed and returned not 0 */
exec_error /* Command failed to execute */
};
enum exec_result wydawca_exec (int argc, const char **argv, int *retcode);
/* Directory scanning and registering */
-int scan_spool (const struct spool *spool, int uc, uid_t *uv);
+int scan_spool (struct spool *spool, int uc, uid_t *uv);
int scan_all_spools (int, uid_t *);
void spool_create_timers (void);
+int spool_add_new_file (const struct spool *spool, const char *name,
+ int uc, uid_t *uv);
+int spool_cwd_add_new_file (const struct spool *spool, const char *name,
+ int uc, uid_t *uv);
+int spool_open_dictionaries (struct spool *spool);
+void spool_close_dictionaries (struct spool *spool);
+
+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 enumerate_triplets (const struct spool *);
+void spool_commit_triplets (struct spool *);
size_t count_collected_triplets (void);
+size_t count_processable_triplets (void);
+
char *triplet_expand_param (const char *tmpl, struct file_triplet *trp);
char *triplet_expand_dictionary_query (struct dictionary *dict, void *handle,
struct file_triplet *trp);
+void triplet_remove_file (struct spool *spool, const char *name);
+
/* General-purpose dictionary support */
struct dictionary *dictionary_new (enum dictionary_id id,
enum dictionary_type type);
int dictionary_init (struct dictionary *dict);
int dictionary_done (struct dictionary *dict);
void *dictionary_open (struct dictionary *dict);
int dictionary_close (struct dictionary *dict, void *handle);
int dictionary_lookup (struct dictionary *dict, void *handle, const char *cmd);
void dictionary_copy_result (struct dictionary *dict, const char *res,
size_t size);
const char *dictionary_result (struct dictionary *dict, void *handle,
unsigned nrow,
unsigned ncol);
int dictionary_quote_string (struct dictionary *dict, void *handle,
const char *input, char **poutput, size_t *psize);
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 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);
struct uploader_info *uploader_find_frp (struct uploader_info *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,
const char **pval);
int directive_pack_version (const char *val, unsigned *pversion);
int directive_unpack_version (unsigned version, char **pbuf, size_t *psize);
@@ -476,39 +493,37 @@ int parse_time_interval (const char *str, time_t *pint, const char **endp);
/* config.c */
void config_init (void);
void config_finish (struct grecs_node *);
void config_help (void);
int assert_string_arg (grecs_locus_t *, enum grecs_callback_command,
const grecs_value_t *);
/* vtab.c */
int url_to_vtab (mu_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,
- const char *wanted_src, const char *wanted_dst);
-int
-rmsymlink_file (struct file_triplet *trp, const char *file_name);
+const char *get_path (struct spool *sp);
+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,
+ const char *wanted_src, const char *wanted_dst);
+int rmsymlink_file (struct file_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);
+const char *dir_get_path (struct spool *sp);
int dir_test_url (mu_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,
const char *wanted_src, const char *wanted_dst);
int dir_rmsymlink_file (struct file_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,
const char *wanted_src, const char *wanted_dst);
@@ -529,25 +544,25 @@ 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 report_init (void);
void report_add (const char *fmt, ...);
void report_finish (void);
extern char *report_string;
/* job.c */
-void schedule_job (const struct spool *spool, uid_t uid);
+void schedule_job (struct spool *spool, uid_t uid);
void job_init (void);
void job_queue_runner (void);
/* profile.c */
void check_pidfile (void);
void remove_pidfile (void);
/* net.c */
void wydawca_listener (void);
void trim_crlf (char *s);
@@ -579,12 +594,20 @@ char *getcwd_alloc (void);
struct txtacc *txtacc_create (void);
void txtacc_free (struct txtacc *acc);
void txtacc_free_string (struct txtacc *acc, char *str);
void txtacc_grow (struct txtacc *acc, const char *buf, size_t size);
#define txtacc_1grow(acc, c) \
do \
{ \
char __ch = c; \
txtacc_grow (acc, &__ch, 1); \
} \
while (0)
char *txtacc_finish (struct txtacc *acc, int steal);
+
+#ifdef WITH_INOTIFY
+int watcher_init (void);
+int watcher_run (int);
+#else
+# define watcher_init() -1
+# define watcher_run(c)
+#endif

Return to:

Send suggestions and report system problems to the System administrator.