diff options
Diffstat (limited to 'src/wydawca.h')
-rw-r--r-- | src/wydawca.h | 83 |
1 files changed, 59 insertions, 24 deletions
diff --git a/src/wydawca.h b/src/wydawca.h index 3f28919..8a716e4 100644 --- a/src/wydawca.h +++ b/src/wydawca.h | |||
@@ -32,7 +32,14 @@ | |||
32 | #include <limits.h> | 32 | #include <limits.h> |
33 | #include <dirent.h> | 33 | #include <dirent.h> |
34 | #include <sys/stat.h> | 34 | #include <sys/stat.h> |
35 | #include <sys/socket.h> | ||
36 | #include <netinet/in.h> | ||
37 | #include <sys/un.h> | ||
38 | #include <sys/wait.h> | ||
39 | #include <netdb.h> | ||
40 | #include <arpa/inet.h> | ||
35 | #include <fcntl.h> | 41 | #include <fcntl.h> |
42 | #include <time.h> | ||
36 | 43 | ||
37 | #include <mailutils/types.h> | 44 | #include <mailutils/types.h> |
38 | #include <mailutils/url.h> | 45 | #include <mailutils/url.h> |
@@ -47,6 +54,7 @@ | |||
47 | #include "backupfile.h" | 54 | #include "backupfile.h" |
48 | #include "inttostr.h" | 55 | #include "inttostr.h" |
49 | #include "gconf.h" | 56 | #include "gconf.h" |
57 | #include "gl_list.h" | ||
50 | #include "argcv.h" | 58 | #include "argcv.h" |
51 | 59 | ||
52 | #define gettext(s) s | 60 | #define gettext(s) s |
@@ -156,7 +164,7 @@ struct file_triplet | |||
156 | char *name; /* Triplet base name */ | 164 | char *name; /* Triplet base name */ |
157 | gid_t gid; /* Owner GID */ | 165 | gid_t gid; /* Owner GID */ |
158 | struct file_info file[FILE_TYPE_COUNT]; /* Components */ | 166 | struct file_info file[FILE_TYPE_COUNT]; /* Components */ |
159 | struct spool *spool; /* Owning spool */ | 167 | const struct spool *spool; /* Owning spool */ |
160 | char **directive; /* Decoded directive pairs (key: value\0) */ | 168 | char **directive; /* Decoded directive pairs (key: value\0) */ |
161 | char *blurb; /* Block of directives: directive[i] points here */ | 169 | char *blurb; /* Block of directives: directive[i] points here */ |
162 | char *tmp; /* Temporary storage */ | 170 | char *tmp; /* Temporary storage */ |
@@ -179,20 +187,20 @@ struct virt_tab | |||
179 | { | 187 | { |
180 | int (*test_url) (mu_url_t url, gconf_locus_t *loc); | 188 | int (*test_url) (mu_url_t url, gconf_locus_t *loc); |
181 | int (*move_file) (struct file_triplet *trp, | 189 | int (*move_file) (struct file_triplet *trp, |
182 | struct spool *spool, | 190 | const struct spool *spool, |
183 | enum file_type file_id, | 191 | enum file_type file_id, |
184 | const char *reldir); | 192 | const char *reldir); |
185 | int (*archive_file) (struct file_triplet *trp, | 193 | int (*archive_file) (struct file_triplet *trp, |
186 | struct spool *spool, | 194 | const struct spool *spool, |
187 | const char *reldir, | 195 | const char *reldir, |
188 | const char *file_name); | 196 | const char *file_name); |
189 | int (*symlink_file) (struct file_triplet *trp, | 197 | int (*symlink_file) (struct file_triplet *trp, |
190 | struct spool *spool, | 198 | const struct spool *spool, |
191 | const char *reldir, | 199 | const char *reldir, |
192 | const char *wanted_src, | 200 | const char *wanted_src, |
193 | const char *wanted_dst); | 201 | const char *wanted_dst); |
194 | int (*rmsymlink_file)(struct file_triplet *trp, | 202 | int (*rmsymlink_file)(struct file_triplet *trp, |
195 | struct spool *spool, | 203 | const struct spool *spool, |
196 | const char *reldir, | 204 | const char *reldir, |
197 | const char *file_name); | 205 | const char *file_name); |
198 | }; | 206 | }; |
@@ -201,6 +209,8 @@ struct virt_tab | |||
201 | files from source to destination */ | 209 | files from source to destination */ |
202 | struct spool | 210 | struct spool |
203 | { | 211 | { |
212 | char *tag; | ||
213 | gl_list_t aliases; | ||
204 | char *url; /* Download URL */ | 214 | char *url; /* Download URL */ |
205 | char *source_dir; /* Source directory */ | 215 | char *source_dir; /* Source directory */ |
206 | mu_url_t dest_url; /* Destination URL */ | 216 | mu_url_t dest_url; /* Destination URL */ |
@@ -306,6 +316,15 @@ extern int archive_signatures; | |||
306 | 316 | ||
307 | extern char *admin_stat_message; | 317 | extern char *admin_stat_message; |
308 | 318 | ||
319 | extern char *pidfile; | ||
320 | extern int force_startup; | ||
321 | |||
322 | extern int daemon_mode; | ||
323 | extern time_t wakeup_interval; | ||
324 | extern int foreground; | ||
325 | extern int single_process; | ||
326 | extern struct gconf_sockaddr listen_sockaddr; | ||
327 | |||
309 | #define UPDATE_STATS(what) \ | 328 | #define UPDATE_STATS(what) \ |
310 | do \ | 329 | do \ |
311 | { \ | 330 | { \ |
@@ -341,10 +360,13 @@ enum exec_result wydawca_exec (int argc, const char **argv, int *retcode); | |||
341 | 360 | ||
342 | 361 | ||
343 | /* Directory scanning and registering */ | 362 | /* Directory scanning and registering */ |
344 | void scan_directories (void); | 363 | void scan_spool (const struct spool *spool, int uc, uid_t *uv); |
364 | void scan_directories (int, uid_t *); | ||
365 | |||
345 | void register_spool (struct spool *spool); | 366 | void register_spool (struct spool *spool); |
367 | struct spool *wydawca_find_spool (const char *name); | ||
346 | void register_file (struct file_info *finfo); | 368 | void register_file (struct file_info *finfo); |
347 | void enumerate_triplets (struct spool *); | 369 | void enumerate_triplets (const struct spool *); |
348 | size_t count_collected_triplets (void); | 370 | size_t count_collected_triplets (void); |
349 | char *triplet_expand_param (const char *tmpl, struct file_triplet *trp); | 371 | char *triplet_expand_param (const char *tmpl, struct file_triplet *trp); |
350 | 372 | ||
@@ -369,12 +391,12 @@ unsigned method_num_cols (struct access_method *method); | |||
369 | 391 | ||
370 | /* Verification functions */ | 392 | /* Verification functions */ |
371 | int verify_directive_file (struct file_triplet *trp, | 393 | int verify_directive_file (struct file_triplet *trp, |
372 | struct spool *spool); | 394 | const struct spool *spool); |
373 | int verify_directive_signature (struct file_triplet *trp, | 395 | int verify_directive_signature (struct file_triplet *trp, |
374 | struct spool *spool, | 396 | const struct spool *spool, |
375 | const char *pubkey); | 397 | const char *pubkey); |
376 | int verify_detached_signature (struct file_triplet *trp, | 398 | int verify_detached_signature (struct file_triplet *trp, |
377 | struct spool *spool); | 399 | const struct spool *spool); |
378 | int fill_project_name (struct file_triplet *trp); | 400 | int fill_project_name (struct file_triplet *trp); |
379 | 401 | ||
380 | /* Directive file support */ | 402 | /* Directive file support */ |
@@ -390,9 +412,8 @@ int directive_first (struct file_triplet *trp, | |||
390 | int directive_next (struct file_triplet *trp, int n, | 412 | int directive_next (struct file_triplet *trp, int n, |
391 | const char **pkey, const char **pval); | 413 | const char **pkey, const char **pval); |
392 | int process_directives (struct file_triplet *trp, | 414 | int process_directives (struct file_triplet *trp, |
393 | struct spool *spool); | 415 | const struct spool *spool); |
394 | 416 | ||
395 | int match_uid_p (uid_t uid); | ||
396 | int enabled_spool_p (const struct spool *spool); | 417 | int enabled_spool_p (const struct spool *spool); |
397 | 418 | ||
398 | int wydawca_uid (uid_t uid); | 419 | int wydawca_uid (uid_t uid); |
@@ -410,42 +431,42 @@ void config_help (void); | |||
410 | int url_to_vtab (mu_url_t url, struct virt_tab *vtab); | 431 | int url_to_vtab (mu_url_t url, struct virt_tab *vtab); |
411 | 432 | ||
412 | int | 433 | int |
413 | move_file (struct file_triplet *trp, struct spool *spool, | 434 | move_file (struct file_triplet *trp, const struct spool *spool, |
414 | enum file_type file_id, const char *reldir); | 435 | enum file_type file_id, const char *reldir); |
415 | int | 436 | int |
416 | archive_file (struct file_triplet *trp, struct spool *spool, | 437 | archive_file (struct file_triplet *trp, const struct spool *spool, |
417 | const char *reldir, const char *file_name); | 438 | const char *reldir, const char *file_name); |
418 | int | 439 | int |
419 | symlink_file (struct file_triplet *trp, struct spool *spool, | 440 | symlink_file (struct file_triplet *trp, const struct spool *spool, |
420 | const char *reldir, | 441 | const char *reldir, |
421 | const char *wanted_src, const char *wanted_dst); | 442 | const char *wanted_src, const char *wanted_dst); |
422 | int | 443 | int |
423 | rmsymlink_file (struct file_triplet *trp, struct spool *spool, | 444 | rmsymlink_file (struct file_triplet *trp, const struct spool *spool, |
424 | const char *reldir, const char *file_name); | 445 | const char *reldir, const char *file_name); |
425 | 446 | ||
426 | 447 | ||
427 | /* diskio.c */ | 448 | /* diskio.c */ |
428 | 449 | ||
429 | int dir_test_url (mu_url_t url, gconf_locus_t *locus); | 450 | int dir_test_url (mu_url_t url, gconf_locus_t *locus); |
430 | int dir_move_file (struct file_triplet *trp, struct spool *spool, | 451 | int dir_move_file (struct file_triplet *trp, const struct spool *spool, |
431 | enum file_type file_id, const char *reldir); | 452 | enum file_type file_id, const char *reldir); |
432 | int dir_archive_file (struct file_triplet *trp, struct spool *spool, | 453 | int dir_archive_file (struct file_triplet *trp, const struct spool *spool, |
433 | const char *file_name, const char *reldir); | 454 | const char *file_name, const char *reldir); |
434 | int dir_symlink_file (struct file_triplet *trp, struct spool *spool, | 455 | int dir_symlink_file (struct file_triplet *trp, const struct spool *spool, |
435 | const char *reldir, | 456 | const char *reldir, |
436 | const char *wanted_src, const char *wanted_dst); | 457 | const char *wanted_src, const char *wanted_dst); |
437 | int dir_rmsymlink_file (struct file_triplet *trp, struct spool *spool, | 458 | int dir_rmsymlink_file (struct file_triplet *trp, const struct spool *spool, |
438 | const char *reldir, const char *file_name); | 459 | const char *reldir, const char *file_name); |
439 | 460 | ||
440 | /* null.c */ | 461 | /* null.c */ |
441 | int null_move_file (struct file_triplet *trp, struct spool *spool, | 462 | int null_move_file (struct file_triplet *trp, const struct spool *spool, |
442 | enum file_type file_id, const char *reldir); | 463 | enum file_type file_id, const char *reldir); |
443 | int null_archive_file (struct file_triplet *trp, struct spool *spool, | 464 | int null_archive_file (struct file_triplet *trp, const struct spool *spool, |
444 | const char *file_name, const char *reldir); | 465 | const char *file_name, const char *reldir); |
445 | int null_symlink_file (struct file_triplet *trp, struct spool *spool, | 466 | int null_symlink_file (struct file_triplet *trp, const struct spool *spool, |
446 | const char *reldir, | 467 | const char *reldir, |
447 | const char *wanted_src, const char *wanted_dst); | 468 | const char *wanted_src, const char *wanted_dst); |
448 | int null_rmsymlink_file (struct file_triplet *trp, struct spool *spool, | 469 | int null_rmsymlink_file (struct file_triplet *trp, const struct spool *spool, |
449 | const char *reldir, const char *file_name); | 470 | const char *reldir, const char *file_name); |
450 | 471 | ||
451 | 472 | ||
@@ -469,3 +490,17 @@ void report_init (void); | |||
469 | void report_add (const char *fmt, ...); | 490 | void report_add (const char *fmt, ...); |
470 | void report_finish (void); | 491 | void report_finish (void); |
471 | extern char *report_string; | 492 | extern char *report_string; |
493 | |||
494 | |||
495 | /* job.c */ | ||
496 | int schedule_job (const struct spool *spool, uid_t uid); | ||
497 | void job_init (void); | ||
498 | void job_queue_runner (void); | ||
499 | |||
500 | |||
501 | /* profile.c */ | ||
502< |