aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-10 21:04:21 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-10 21:07:52 +0300
commita9da878ff22f980cea3bf3102113d7f2e65f61e9 (patch)
treedd3e21c580b91f6ab3d64e228ccb23170f3ddac3 /src/wydawca.h
parentda966c314f92d17b45ede9aa77ad3d3624c36725 (diff)
downloadwydawca-a9da878ff22f980cea3bf3102113d7f2e65f61e9.tar.gz
wydawca-a9da878ff22f980cea3bf3102113d7f2e65f61e9.tar.bz2
Change indentation to improve readability.
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h299
1 files changed, 150 insertions, 149 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index c4a3f8c..c2ae2de 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -76,46 +76,46 @@
#define NITEMS(a) (sizeof(a)/sizeof((a)[0]))
enum dictionary_id {
- project_uploader_dict, /* Contains names, gpg-keys, emails and
+ project_uploader_dict, /* Contains names, gpg-keys, emails and
real names of the project uploaders */
- project_owner_dict, /* Contains names and emails of the project
+ project_owner_dict, /* Contains names and emails of the project
owners */
- dictionary_count
+ dictionary_count
};
enum dictionary_type {
- dictionary_none, /* Undefined or no dictionary */
- dictionary_sql, /* Use SQL database */
- dictionary_builtin, /* Use built-in facilities */
- dictionary_external /* Invoke an external program */
+ dictionary_none, /* Undefined or no dictionary */
+ dictionary_sql, /* Use SQL database */
+ dictionary_builtin, /* Use built-in facilities */
+ dictionary_external /* Invoke an external program */
};
struct dictionary {
- enum dictionary_id id;
- enum dictionary_type type; /* Dictionary type */
- char *query; /* Query template */
- int parmc; /* Number of entries in paramv */
- char **parmv; /* Parameters. The semantics differs
- depending on type. For SQL:
- 0 - Identifier of the SQL struct
- to use; */
-
- int init_passed; /* Initialization count */
- char *result; /* Result storage */
- size_t result_size; /* Size of result */
- unsigned ncol; /* Number of columns per row */
- unsigned nrow; /* Number of rows */
-
- void *storage;
+ enum dictionary_id id;
+ enum dictionary_type type; /* Dictionary type */
+ char *query; /* Query template */
+ int parmc; /* Number of entries in paramv */
+ char **parmv; /* Parameters. The semantics differs
+ depending on type. For SQL:
+ 0 - Identifier of the SQL struct
+ to use; */
+
+ int init_passed; /* Initialization count */
+ char *result; /* Result storage */
+ size_t result_size; /* Size of result */
+ unsigned ncol; /* Number of columns per row */
+ unsigned nrow; /* Number of rows */
+
+ void *storage;
};
enum backup_type {
- no_backups, /* Don't make backups */
- simple_backups, /* Make only simple backups */
- numbered_existing_backups, /* Make numbered backups for files that
- already have such backups and simple
- backups for the rest */
- numbered_backups, /* Make only numbered backups */
+ no_backups, /* Don't make backups */
+ simple_backups, /* Make only simple backups */
+ numbered_existing_backups, /* Make numbered backups for files that
+ already have such backups and simple
+ backups for the rest */
+ numbered_backups, /* Make only numbered backups */
};
extern char const *simple_backup_suffix;
@@ -128,83 +128,83 @@ const char *split_filename(char const *file, char **pdir);
#define METADATA_OWNER 0x2
struct directory_metadata {
- int flags;
- mode_t mode;
- uid_t uid;
- gid_t gid;
+ int flags;
+ mode_t mode;
+ uid_t uid;
+ gid_t gid;
};
/* Archive types */
enum archive_type {
- archive_none, /* No archivation requested */
- archive_directory, /* Archive by moving files to a separate
+ archive_none, /* No archivation requested */
+ archive_directory, /* Archive by moving files to a separate
directory hierarchy */
- archive_tar /* Archive by appending to a tar file
+ archive_tar /* Archive by appending to a tar file
(tar -r) */
};
struct archive_descr {
- enum archive_type type; /* Archivation type */
- char *name; /* Directory name if type==archive_directory,
+ enum archive_type type; /* Archivation type */
+ char *name; /* Directory name if type==archive_directory,
archive file name if type==archive_tar */
- enum backup_type backup_type; /* Requested backup type if
+ enum backup_type backup_type; /* Requested backup type if
type == archive_directory */
- struct directory_metadata metadata; /* Directory metadata */
+ struct directory_metadata metadata; /* Directory metadata */
};
/* Type of file in a triplet */
enum file_type {
- file_dist, /* Something to be distributed */
- file_signature, /* Detached signature (.sig) */
- file_directive, /* Directive (.directive.asc) */
+ file_dist, /* Something to be distributed */
+ file_signature, /* Detached signature (.sig) */
+ file_directive, /* Directive (.directive.asc) */
};
#define FILE_TYPE_COUNT (file_directive+1)
/* Part of a triplet */
struct file_info {
- enum file_type type; /* Part type */
- char *name; /* File name */
- unsigned root_len; /* Length of root part in name */
- struct stat sb;
+ enum file_type type; /* Part type */
+ char *name; /* File name */
+ unsigned root_len; /* Length of root part in name */
+ struct stat sb;
};
/* File triplet */
struct wy_triplet {
- char *name; /* Triplet base name */
- struct file_info file[FILE_TYPE_COUNT]; /* Components */
- unsigned version; /* Protocol version */
- const struct spool *spool; /* Owning spool */
- char *relative_dir; /* Directory relative to spool->dest_dir */
- char **directive; /* Decoded directive pairs (key: value\0) */
- char *blurb; /* Block of directives: directive[i] points
+ char *name; /* Triplet base name */
+ struct file_info file[FILE_TYPE_COUNT]; /* Components */
+ unsigned version; /* Protocol version */
+ const struct spool *spool; /* Owning spool */
+ char *relative_dir; /* Directory relative to spool->dest_dir */
+ char **directive; /* Decoded directive pairs (key: value\0) */
+ char *blurb; /* Block of directives: directive[i] points
here */
- char *tmp; /* Temporary storage */
- size_t tmpsize; /* Size of memory allocated in tmp */
- struct grecs_txtacc *acc; /* Text accumulator for string allocation */
- /* 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 wy_triplet *prev, *next;
- /* 2) "job queue", a list of triplets processed by the same job: */
- 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
- requests belonging to it are removed from the table to avoid them
- being processed by subsequent jobs.
- If started as a cron job, or awoken by a TCP listener, both
- job and jq_prev, jq_next are NULL. */
- struct job *job;
- /* User data */
- struct wy_user *uploader_list;
- struct wy_user *uploader;
- /* Admin data */
- struct wy_user *admin_list;
- /* Special data for template formatting */
- char *project; /* Triplet project name (if known) */
- int check_result; /* Result of external check */
- char *check_diag; /* External check diagnostics */
+ char *tmp; /* Temporary storage */
+ size_t tmpsize; /* Size of memory allocated in tmp */
+ struct grecs_txtacc *acc; /* Text accumulator for string allocation */
+ /* 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 wy_triplet *prev, *next;
+ /* 2) "job queue", a list of triplets processed by the same job: */
+ 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
+ requests belonging to it are removed from the table to avoid them
+ being processed by subsequent jobs.
+ If started as a cron job, or awoken by a TCP listener, both
+ job and jq_prev, jq_next are NULL. */
+ struct job *job;
+ /* User data */
+ struct wy_user *uploader_list;
+ struct wy_user *uploader;
+ /* Admin data */
+ struct wy_user *admin_list;
+ /* Special data for template formatting */
+ char *project; /* Triplet project name (if known) */
+ int check_result; /* Result of external check */
+ char *check_diag; /* External check diagnostics */
};
/* Macros to access owner UID and GID. */
@@ -223,37 +223,36 @@ const char *wy_url_printable(wy_url_t url);
int wy_url_is_local(wy_url_t url);
struct virt_tab {
- int (*test_url) (wy_url_t url, grecs_locus_t * loc);
- 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 wy_triplet * trp,
- const char *file_name);
+ int (*test_url) (wy_url_t url, grecs_locus_t * loc);
+ 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 wy_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 */
- int source_fd; /* File handle of the source directory */
- struct directory_metadata source_metadata;
- wy_url_t dest_url; /* Destination URL */
- const char *dest_dir; /* Directory part of the above */
- struct directory_metadata dest_metadata;
- struct virt_tab vtab; /* Virtual method table */
- int inotify_enable;
-
- time_t file_sweep_time; /* Remove invalid/unprocessed files
+ char *tag;
+ struct grecs_list *aliases;
+ char *url; /* Download URL */
+ char *source_dir; /* Source directory */
+ int source_fd; /* File handle of the source directory */
+ struct directory_metadata source_metadata;
+ wy_url_t dest_url; /* Destination URL */
+ const char *dest_dir; /* Directory part of the above */
+ struct directory_metadata dest_metadata;
+ struct virt_tab vtab; /* Virtual method table */
+ int inotify_enable;
+
+ 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;
+ 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 { \
@@ -268,43 +267,42 @@ struct spool {
} while (0)
struct notification {
- struct notification *next;
- enum wy_event ev;
- char *modname;
- void *modcfg;
- grecs_node_t *modnode;
+ struct notification *next;
+ enum wy_event ev;
+ char *modname;
+ void *modcfg;
+ grecs_node_t *modnode;
};
-void notify(struct notification *, struct wy_triplet *,
- enum wy_event);
+void notify(struct notification *, struct wy_triplet *, enum wy_event);
void notify_stats(void);
void notify_flush(struct spool *sp);
void notify_finish(void);
-
+
/* Modules */
struct module {
- struct module *next;
- char *name;
- char *path;
- grecs_locus_t locus;
- grecs_node_t *modinit;
- void *handle;
- int (*open) (grecs_node_t *);
- void *(*config) (grecs_node_t *);
- int (*notify) (void *, int, struct wy_triplet *);
- void (*flush) (void *);
- void (*close) (void);
+ struct module *next;
+ char *name;
+ char *path;
+ grecs_locus_t locus;
+ grecs_node_t *modinit;
+ void *handle;
+ int (*open) (grecs_node_t *);
+ void *(*config) (grecs_node_t *);
+ int (*notify) (void *, int, struct wy_triplet *);
+ void (*flush) (void *);
+ void (*close) (void);
};
-int cb_module(enum grecs_callback_command cmd, grecs_node_t *node,
+int cb_module(enum grecs_callback_command cmd, grecs_node_t * node,
void *varptr, void *cb_data);
void modules_load(void);
void modules_close(void);
void modules_help(void);
-int module_set_init(const char *name, grecs_node_t *node);
+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,
@@ -376,9 +374,9 @@ void parse_config(void);
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 */
+ 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);
@@ -403,7 +401,8 @@ void spool_commit_triplets(struct spool *, struct wy_triplet *);
struct wy_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
-char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
+char *triplet_expand_dictionary_query(struct dictionary *dict,
+ void *handle,
struct wy_triplet *trp);
void triplet_remove_file(struct spool *spool, const char *name);
@@ -418,13 +417,15 @@ 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);
+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);
+ const char *input, char **poutput,
+ size_t * psize);
unsigned dictionary_num_rows(struct dictionary *dict);
unsigned dictionary_num_cols(struct dictionary *dict);
@@ -436,15 +437,15 @@ 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);
+struct wy_user *uploader_find_frp(struct wy_user *list, const char *frp);
/* Directive file support */
int directive_parse(struct wy_triplet *trp);
int directive_get_value(struct wy_triplet const *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_unpack_version(unsigned version, char **pbuf,
+ size_t * psize);
int directive_version_in_range_p(struct wy_triplet *trp,
unsigned from, unsigned to);
@@ -468,14 +469,14 @@ void config_finish(struct grecs_node *);
void config_help(void);
int wy_assert_string_arg(grecs_locus_t *, enum grecs_callback_command,
const grecs_value_t *);
-grecs_value_t *get_arg(grecs_value_t *value, unsigned n, int type);
+grecs_value_t *get_arg(grecs_value_t * value, unsigned n, int type);
int wy_strtofac(const char *str);
int wy_strtopri(const char *str);
const char *wy_pritostr(int pri);
const char *wy_factostr(int fac);
-
+
/* vtab.c */
int url_to_vtab(wy_url_t url, struct virt_tab *vtab);
@@ -524,37 +525,37 @@ extern char *report_string;
/* job.c */
/* Wydawca job types */
enum job_type {
- JOB_TRIPLET, /* Process a list of complete triplets */
- JOB_SPOOL, /* Scan single spool */
- JOB_ALL_SPOOLS /* Scan all spools */
+ JOB_TRIPLET, /* Process a list of complete triplets */
+ JOB_SPOOL, /* Scan single spool */
+ JOB_ALL_SPOOLS /* Scan all spools */
};
struct job_spool_id {
- struct spool *spool;
- uid_t uid;
+ struct spool *spool;
+ uid_t uid;
};
void job_schedule(int type, void *data);
-static inline void
+static inline void
job_schedule_all(void)
{
- job_schedule(JOB_ALL_SPOOLS, NULL);
+ job_schedule(JOB_ALL_SPOOLS, NULL);
}
static inline void
job_schedule_triplet(struct wy_triplet *tp)
{
- job_schedule(JOB_TRIPLET, tp);
+ job_schedule(JOB_TRIPLET, tp);
}
static inline void
job_schedule_spool(struct spool *spool, uid_t uid)
{
- struct job_spool_id jid;
- jid.spool = spool;
- jid.uid = uid;
- job_schedule(JOB_SPOOL, &jid);
+ struct job_spool_id jid;
+ jid.spool = spool;
+ jid.uid = uid;
+ job_schedule(JOB_SPOOL, &jid);
}
void job_init(void);

Return to:

Send suggestions and report system problems to the System administrator.