aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-24 00:49:40 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-24 00:57:16 +0200
commit4213ec5ef9695aa504938c0e764ba9a4f08921b2 (patch)
tree88ac2b2eb01337f0924d687df38b2a163bc94e11
parent337a06f32fb530e0e0884fef2f5f630cca9911a1 (diff)
downloadwydawca-4213ec5ef9695aa504938c0e764ba9a4f08921b2.tar.gz
wydawca-4213ec5ef9695aa504938c0e764ba9a4f08921b2.tar.bz2
Initial implementation of daemon mode.
* gconf/gconf-gram.y (string_to_sockaddr_: Take struct gconf_sockaddr as the first argument. * gconf/gconf.h (struct gconf_sockaddr): New data type. * src/job.c, src/net.c, src/pidfile.c: New files. * src/Makefile.am (wydawca_SOURCES): Add job.c, net.c, pidfile.c * src/cmdline.opt: New options: --cron (change semantics), --force, --foreground, --single-process, --spool * src/wydawca.c: New daemon mode. * src/config.c: New statements: spool.alias, daemon, foreground, single-process, wakeup-interval, pidfile, listen * src/directive.c, src/diskio.c, src/gpg.c, src/mail.c, src/null.c, src/process.c, src/triplet.c, src/verify.c, src/vtab.c, src/wydawca.h: use static struct spool wherever feasible. * src/triplet.c: New meta-variable "spool" * tests/etc/wydawca.rcin: Update. * tests/upload-dry.at: Update.
-rw-r--r--gconf/gconf-gram.y20
-rw-r--r--gconf/gconf.h5
-rw-r--r--src/Makefile.am4
-rw-r--r--src/cmdline.opt48
-rw-r--r--src/config.c40
-rw-r--r--src/directive.c2
-rw-r--r--src/diskio.c14
-rw-r--r--src/gpg.c4
-rw-r--r--src/job.c278
-rw-r--r--src/mail.c15
-rw-r--r--src/net.c227
-rw-r--r--src/null.c22
-rw-r--r--src/pidfile.c90
-rw-r--r--src/process.c66
-rw-r--r--src/triplet.c18
-rw-r--r--src/verify.c4
-rw-r--r--src/vtab.c8
-rw-r--r--src/wydawca.c112
-rw-r--r--src/wydawca.h83
-rw-r--r--tests/etc/wydawca.rcin3
-rw-r--r--tests/mailstats.at2
-rw-r--r--tests/notify-upl.at2
-rw-r--r--tests/upload-dry.at10
-rw-r--r--tests/upload.at2
24 files changed, 913 insertions, 166 deletions
diff --git a/gconf/gconf-gram.y b/gconf/gconf-gram.y
index a1d9f2a..f7ee710 100644
--- a/gconf/gconf-gram.y
+++ b/gconf/gconf-gram.y
@@ -506,19 +506,23 @@ string_to_host (struct in_addr *in, const char *string)
506} 506}
507 507
508static int 508static int
509string_to_sockaddr (sockaddr_union_t *s, const char *string) 509string_to_sockaddr (struct gconf_sockaddr *sp, const char *string)
510{ 510{
511 if (string[0] == '/') 511 if (string[0] == '/')
512 { 512 {
513 if (strlen (string) >= sizeof (s->s_un.sun_path)) 513 struct sockaddr_un s_un;
514 if (strlen (string) >= sizeof (s_un.sun_path))
514 { 515 {
515 gconf_error (&gconf_current_locus, 0, 516 gconf_error (&gconf_current_locus, 0,
516 _("%s: UNIX socket name too long"), 517 _("%s: UNIX socket name too long"),
517 string); 518 string);
518 return 1; 519 return 1;
519 } 520 }
520 s->s_un.sun_family = AF_UNIX; 521 s_un.sun_family = AF_UNIX;
521 strcpy (s->s_un.sun_path, string); 522 strcpy (s_un.sun_path, string);
523 sp->len = sizeof (s_un);
524 sp->sa = xmalloc (sp->len);
525 memcpy (sp->sa, &s_un, sp->len);
522 } 526 }
523 else 527 else
524 { 528 {
@@ -583,7 +587,9 @@ string_to_sockaddr (sockaddr_union_t *s, const char *string)
583 gconf_error (&gconf_current_locus, 0, _("missing port number")); 587 gconf_error (&gconf_current_locus, 0, _("missing port number"));
584 return 1; 588 return 1;
585 } 589 }
586 s->s_in = sa; 590 sp->len = sizeof (sa);
591 sp->sa = xmalloc (sp->len);
592 memcpy (sp->sa, &sa, sp->len);
587 } 593 }
588 return 0; 594 return 0;
589} 595}
@@ -689,7 +695,7 @@ string_convert (void *target, enum gconf_data_type type, const char *string)
689 break; 695 break;
690 696
691 case gconf_type_sockaddr: 697 case gconf_type_sockaddr:
692 return string_to_sockaddr ((sockaddr_union_t*)target, string); 698 return string_to_sockaddr ((struct gconf_sockaddr *)target, string);
693 699
694 /* FIXME: */ 700 /* FIXME: */
695 case gconf_type_cidr: 701 case gconf_type_cidr:
@@ -720,7 +726,7 @@ size_t gconf_type_size_tab[] = {
720 sizeof (struct in_addr) /* gconf_type_ipv4 */, 726 sizeof (struct in_addr) /* gconf_type_ipv4 */,
721 0 /* FIXME: gconf_type_cidr */, 727 0 /* FIXME: gconf_type_cidr */,
722 sizeof (struct in_addr) /* gconf_type_host */, 728 sizeof (struct in_addr) /* gconf_type_host */,
723 sizeof (sockaddr_union_t) /* gconf_type_sockaddr */, 729 sizeof (struct gconf_sockaddr) /* gconf_type_sockaddr */,
724 0 /* gconf_type_section */ 730 0 /* gconf_type_section */
725}; 731};
726#define gconf_type_size_count \ 732#define gconf_type_size_count \
diff --git a/gconf/gconf.h b/gconf/gconf.h
index f88e87a..56792a0 100644
--- a/gconf/gconf.h
+++ b/gconf/gconf.h
@@ -97,6 +97,11 @@ struct gconf_keyword {
97 struct gconf_keyword *kwd; 97 struct gconf_keyword *kwd;
98}; 98};
99 99
100struct gconf_sockaddr {
101 int len;
102 struct sockaddr *sa;
103};
104
100gconf_value_t *gconf_value_dup(gconf_value_t *input); 105gconf_value_t *gconf_value_dup(gconf_value_t *input);
101 106
102extern void gconf_print_diag(gconf_locus_t *, int, int, const char*); 107extern void gconf_print_diag(gconf_locus_t *, int, int, const char*);
diff --git a/src/Makefile.am b/src/Makefile.am
index 7ba9832..903b754 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,8 +25,11 @@ wydawca_SOURCES=\
25 exec.c\ 25 exec.c\
26 gpg.c\ 26 gpg.c\
27 interval.c\ 27 interval.c\
28 job.c\
28 meta.c\ 29 meta.c\
29 method.c\ 30 method.c\
31 net.c\
32 pidfile.c\
30 process.c\ 33 process.c\
31 sql.c\ 34 sql.c\
32 sql.h\ 35 sql.h\
@@ -56,6 +59,7 @@ LDADD=../gconf/libgconf.a ../gnu/libgnu.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@
56INCLUDES = -I$(top_srcdir)/gconf -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@ 59INCLUDES = -I$(top_srcdir)/gconf -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@
57AM_CPPFLAGS= \ 60AM_CPPFLAGS= \
58 -DSYSCONFDIR=\"$(sysconfdir)\"\ 61 -DSYSCONFDIR=\"$(sysconfdir)\"\
62 -DLOCALSTATEDIR=\"$(localstatedir)\"\
59 -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ 63 -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
60 -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ 64 -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\
61 -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" 65 -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 53bdd00..b61517b 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -18,6 +18,7 @@ static struct obstack pp_cmd_stack;
18static int pp_cmd_stack_init; 18static int pp_cmd_stack_init;
19 19
20static gl_list_t source_list; 20static gl_list_t source_list;
21static gl_list_t tag_list;
21 22
22static bool 23static bool
23source_eq (const void *elt1, const void *elt2) 24source_eq (const void *elt1, const void *elt2)
@@ -28,9 +29,10 @@ source_eq (const void *elt1, const void *elt2)
28int 29int
29enabled_spool_p (const struct spool *spool) 30enabled_spool_p (const struct spool *spool)
30{ 31{
31 if (!source_list) 32 if (source_list || tag_list)
32 return 1; 33 return (source_list && gl_list_search (source_list, spool->source_dir))
33 return !!gl_list_search (source_list, spool->source_dir); 34 || (tag_list && gl_list_search (tag_list, spool->tag));
35 return 1;
34} 36}
35 37
36OPTIONS_BEGIN(gnu, "wydawca", 38OPTIONS_BEGIN(gnu, "wydawca",
@@ -61,12 +63,47 @@ BEGIN
61 dry_run_mode = 1; 63 dry_run_mode = 1;
62END 64END
63 65
66OPTION(cron,,,
67 [<force cron mode>])
68BEGIN
69 cron_option = 1;
70 log_to_stderr = 0;
71END
72
73OPTION(force,,,
74 [<force start up even if the pid file already exists>])
75BEGIN
76 force_startup = 1;
77END
78
79OPTION(foreground,,,
80 [<foreground mode>])
81BEGIN
82 foreground_option = 1;
83END
84
85OPTION(single-process,,,
86 [<single process mode>])
87BEGIN
88 single_process_option = 1;
89END
90
64OPTION(config-file,c,FILE, 91OPTION(config-file,c,FILE,
65 [<use FILE instead of the default configuration>]) 92 [<use FILE instead of the default configuration>])
66BEGIN 93BEGIN
67 conffile = optarg; 94 conffile = optarg;
68END 95END
69 96
97OPTION(spool,S,TAG,
98 [<process only spool with the given tag>])
99BEGIN
100 if (!tag_list)
101 tag_list = gl_list_create_empty (&gl_linked_list_implementation,
102 source_eq, NULL,
103 NULL, false);
104 gl_list_add_last (tag_list, optarg);
105END
106
70OPTION(source,s,SOURCE-DIR, 107OPTION(source,s,SOURCE-DIR,
71 [<process only spool with the given source (may be used multiple times)>]) 108 [<process only spool with the given source (may be used multiple times)>])
72BEGIN 109BEGIN
@@ -79,9 +116,8 @@ END
79 116
80GROUP(Logging) 117GROUP(Logging)
81 118
82OPTION(cron,,, 119OPTION(syslog,,,
83