diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-02-26 16:24:03 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-02-26 16:36:32 +0200 |
commit | 5b29f3ecc4e2edb172d50b23732a588b7a71ce62 (patch) | |
tree | 79b94cbcd5b3a5456ad2a2b2c410886b7e1fb143 /src | |
parent | 1eeab02e9de4d54178279b347296e98fd97e2a00 (diff) | |
download | wydawca-5b29f3ecc4e2edb172d50b23732a588b7a71ce62.tar.gz wydawca-5b29f3ecc4e2edb172d50b23732a588b7a71ce62.tar.bz2 |
Introduce loadable modules.
* .gitignore: Update.
* configure.ac: Require libtool
Require Grecs tree-api.
* Makefile.am: Incorporate libtool
* bootstrap: Create m4 if it does not exist.
* doc/Makefile.am: Use texi2html
* grecs: Upgrade
* src/module.c: New file.
* src/Makefile.am (wydawca_SOURCES): Add module.c
* src/config.c: Switch callbacks to tree-api.
Add statements for working with modules:
module-load-path, module-prepend-load-path and
module in the global scope and module and
module-config in notify-event blocks.
* src/mail.c (do_notify): Call module_notify if a module
is configured.
* src/tcpwrap.c: Switch callbacks to tree-api.
* src/wydawca.c (main): Load modules.
* src/wydawca.h (notification) <modname>
<modcfg,modnode>: New members.
(module): New struct.
(cb_module,modules_load,module_notify): New functions.
(module_load_path)
(module_prepend_load_path): New globals.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/config.c | 201 | ||||
-rw-r--r-- | src/mail.c | 5 | ||||
-rw-r--r-- | src/module.c | 236 | ||||
-rw-r--r-- | src/tcpwrap.c | 8 | ||||
-rw-r--r-- | src/wydawca.c | 1 | ||||
-rw-r--r-- | src/wydawca.h | 26 |
7 files changed, 401 insertions, 82 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2c8f3c4..d7241e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -35,6 +35,7 @@ wydawca_SOURCES=\ | |||
35 | job.c\ | 35 | job.c\ |
36 | lock.c\ | 36 | lock.c\ |
37 | meta.c\ | 37 | meta.c\ |
38 | module.c\ | ||
38 | net.c\ | 39 | net.c\ |
39 | pidfile.c\ | 40 | pidfile.c\ |
40 | process.c\ | 41 | process.c\ |
@@ -67,12 +68,13 @@ SUFFIXES=.opt .c .h | |||
67 | incdir=$(pkgdatadir)/$(VERSION)/include | 68 | incdir=$(pkgdatadir)/$(VERSION)/include |
68 | inc_DATA = $(PP_SETUP_FILE) | 69 | inc_DATA = $(PP_SETUP_FILE) |
69 | 70 | ||
70 | LDADD=../grecs/src/libgrecs.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ | 71 | LDADD=../grecs/src/libgrecs.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ @LIBLTDL@ |
71 | AM_CPPFLAGS= \ | 72 | AM_CPPFLAGS= \ |
72 | -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@\ | 73 | -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@\ |
73 | -DSYSCONFDIR=\"$(sysconfdir)\"\ | 74 | -DSYSCONFDIR=\"$(sysconfdir)\"\ |
74 | -DLOCALSTATEDIR=\"$(localstatedir)\"\ | 75 | -DLOCALSTATEDIR=\"$(localstatedir)\"\ |
76 | -DWYDAWCA_MODDIR=\"$(WYDAWCA_MODDIR)\"\ | ||
75 | -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ | 77 | -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ |
76 | -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ | 78 | -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ |
77 | -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" | 79 | -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" |
78 | 80 | AM_LDFLAGS=-export-dynamic | |
diff --git a/src/config.c b/src/config.c index d6f6a89..b381834 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -230,10 +230,10 @@ assert_string_arg(grecs_locus_t *locus, | |||
230 | } | 230 | } |
231 | 231 | ||
232 | grecs_value_t * | 232 | grecs_value_t * |
233 | get_arg(grecs_locus_t *locus, grecs_value_t *value, unsigned n, int type) | 233 | get_arg(grecs_value_t *value, unsigned n, int type) |
234 | { | 234 | { |
235 | if (n >= value->v.arg.c) { | 235 | if (!value || value->type != GRECS_TYPE_ARRAY || n >= value->v.arg.c) { |
236 | grecs_error(locus, 0, _("not enough arguments")); | 236 | grecs_error(&value->locus, 0, _("not enough arguments")); |
237 | return NULL; | 237 | return NULL; |
238 | } | 238 | } |
239 | value = value->v.arg.v[n]; | 239 | value = value->v.arg.v[n]; |
@@ -246,12 +246,13 @@ get_arg(grecs_locus_t *locus, grecs_value_t *value, unsigned n, int type) | |||
246 | } | 246 | } |
247 | 247 | ||
248 | static int | 248 | static int |
249 | cb_mailer(enum grecs_callback_command cmd, | 249 | cb_mailer(enum grecs_callback_command cmd, grecs_node_t *node, |
250 | grecs_locus_t *locus, | 250 | void *varptr, void *cb_data) |
251 | void *varptr, grecs_value_t *value, void *cb_data) | ||
252 | { | 251 | { |
253 | int rc; | 252 | int rc; |
254 | 253 | grecs_locus_t *locus = &node->locus; | |
254 | grecs_value_t *value = node->v.value; | ||
255 | |||
255 | if (assert_string_arg(locus, cmd, value)) | 256 | if (assert_string_arg(locus, cmd, value)) |
256 | return 1; | 257 | return 1; |
257 | rc = mu_mailer_create(&mailer, value->v.string); | 258 | rc = mu_mailer_create(&mailer, value->v.string); |
@@ -264,12 +265,13 @@ cb_mailer(enum grecs_callback_command cmd, | |||
264 | } | 265 | } |
265 | 266 | ||
266 | static int | 267 | static int |
267 | cb_email_address(enum grecs_callback_command cmd, | 268 | cb_email_address(enum grecs_callback_command cmd, grecs_node_t *node, |
268 | grecs_locus_t *locus, | 269 | void *varptr, void *cb_data) |
269 | void *varptr, grecs_value_t *value, void *cb_data) | ||
270 | { | 270 | { |
271 | int rc = 1; | 271 | int rc = 1; |
272 | mu_address_t addr = NULL; | 272 | mu_address_t addr = NULL; |
273 | grecs_locus_t *locus = &node->locus; | ||
274 | grecs_value_t *value = node->v.value; | ||
273 | struct grecs_list_entry *ep; | 275 | struct grecs_list_entry *ep; |
274 | 276 | ||
275 | switch (value->type) { | 277 | switch (value->type) { |
@@ -315,13 +317,14 @@ cb_email_address(enum grecs_callback_command cmd, | |||
315 | } | 317 | } |
316 | 318 | ||
317 | static int | 319 | static int |
318 | cb_interval(enum grecs_callback_command cmd, | 320 | cb_interval(enum grecs_callback_command cmd, grecs_node_t *node, |
319 | grecs_locus_t *locus, | 321 | void *varptr, void *cb_data) |
320 | void *varptr, grecs_value_t *value, void *cb_data) | ||
321 | { | 322 | { |
322 | int rc; | 323 | int rc; |
323 | time_t interval; | 324 | time_t interval; |
324 | const char *endp; | 325 | const char *endp; |
326 | grecs_locus_t *locus = &node->locus; | ||
327 | grecs_value_t *value = node->v.value; | ||
325 | 328 | ||
326 | /* FIXME 1: Support arrays */ | 329 | /* FIXME 1: Support arrays */ |
327 | if (assert_string_arg(locus, cmd, value)) | 330 | if (assert_string_arg(locus, cmd, value)) |
@@ -340,10 +343,12 @@ cb_interval(enum grecs_callback_command cmd, | |||
340 | 343 | ||
341 | static int | 344 | static int |
342 | cb_absolute_name(enum grecs_callback_command cmd, | 345 | cb_absolute_name(enum grecs_callback_command cmd, |
343 | grecs_locus_t *locus, | 346 | grecs_node_t *node, |
344 | void *varptr, grecs_value_t *value, void *cb_data) | 347 | void *varptr, void *cb_data) |
345 | { | 348 | { |
346 | char *word; | 349 | char *word; |
350 | grecs_locus_t *locus = &node->locus; | ||
351 | grecs_value_t *value = node->v.value; | ||
347 | 352 | ||
348 | /* FIXME 1: Support arrays */ | 353 | /* FIXME 1: Support arrays */ |
349 | if (assert_string_arg(locus, cmd, value)) | 354 | if (assert_string_arg(locus, cmd, value)) |
@@ -360,11 +365,13 @@ cb_absolute_name(enum grecs_callback_command cmd, | |||
360 | 365 | ||
361 | static int | 366 | static int |
362 | cb_set_umask(enum grecs_callback_command cmd, | 367 | cb_set_umask(enum grecs_callback_command cmd, |
363 | grecs_locus_t *locus, | 368 | grecs_node_t *node, |
364 | void *varptr, grecs_value_t *value, void *cb_data) | 369 | void *varptr, void *cb_data) |
365 | { | 370 | { |
366 | char *p; | 371 | char *p; |
367 | mode_t m; | 372 | mode_t m; |
373 | grecs_locus_t *locus = &node->locus; | ||
374 | grecs_value_t *value = node->v.value; | ||
368 | 375 | ||
369 | if (assert_string_arg(locus, cmd, value)) | 376 | if (assert_string_arg(locus, cmd, value)) |
370 | return 1; | 377 | return 1; |
@@ -474,20 +481,20 @@ parse_statmask(grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask) | |||
474 | } | 481 | } |
475 | 482 | ||
476 | static int | 483 | static int |
477 | cb_statistics(enum grecs_callback_command cmd, | 484 | cb_statistics(enum grecs_callback_command cmd, grecs_node_t *node, |
478 | grecs_locus_t *locus, | 485 | void *varptr, void *cb_data) |
479 | void *varptr, grecs_value_t *value, void *cb_data) | ||
480 | { | 486 | { |
481 | return parse_statmask(locus, value, varptr); | 487 | return parse_statmask(&node->locus, node->v.value, varptr); |
482 | } | 488 | } |
483 | 489 | ||
484 | static int | 490 | static int |
485 | cb_sql_host(enum grecs_callback_command cmd, | 491 | cb_sql_host(enum grecs_callback_command cmd, grecs_node_t *node, |
486 | grecs_locus_t *locus, | 492 | void *varptr, void *cb_data) |
487 | void *varptr, grecs_value_t *value, void *cb_data) | ||
488 | { | 493 | { |
489 | struct sqlconn *pconn = varptr; | 494 | struct sqlconn *pconn = varptr; |
490 | char *p; | 495 | char *p; |
496 | grecs_locus_t *locus = &node->locus; | ||
497 | grecs_value_t *value = node->v.value; | ||
491 | 498 | ||
492 | if (assert_string_arg(locus, cmd, value)) | 499 | if (assert_string_arg(locus, cmd, value)) |
493 | return 1; | 500 | return 1; |
@@ -524,12 +531,13 @@ cb_sql_host(enum grecs_callback_command cmd, | |||
524 | } | 531 | } |
525 | 532 | ||
526 | static int | 533 | static int |
527 | cb_sql(enum grecs_callback_command cmd, | 534 | cb_sql(enum grecs_callback_command cmd, grecs_node_t *node, |
528 | grecs_locus_t *locus, | 535 | void *varptr, void *cb_data) |
529 | void *varptr, grecs_value_t *value, void *cb_data) | ||
530 | { | 536 | { |
531 | struct sqlconn *pconn; | 537 | struct sqlconn *pconn; |
532 | void **pdata = cb_data; | 538 | void **pdata = cb_data; |
539 | grecs_locus_t *locus = &node->locus; | ||
540 | grecs_value_t *value = node->v.value; | ||
533 | 541 | ||
534 | switch (cmd) { | 542 | switch (cmd) { |
535 | case grecs_callback_section_begin: | 543 | case grecs_callback_section_begin: |
@@ -586,10 +594,12 @@ static struct grecs_keyword sql_kw[] = { | |||
586 | }; | 594 | }; |
587 | 595 | ||
588 | static int | 596 | static int |
589 | cb_syslog_facility(enum grecs_callback_command cmd, | 597 | cb_syslog_facility(enum grecs_callback_command cmd, grecs_node_t *node, |
590 | grecs_locus_t *locus, | 598 | void *varptr, void *cb_data) |
591 | void *varptr, grecs_value_t *value, void *cb_data) | ||
592 | { | 599 | { |
600 | grecs_locus_t *locus = &node->locus; | ||
601 | grecs_value_t *value = node->v.value; | ||
602 | |||
593 | if (assert_string_arg(locus, cmd, value)) | 603 | if (assert_string_arg(locus, cmd, value)) |
594 | return 1; | 604 | return 1; |
595 | 605 | ||
@@ -601,11 +611,12 @@ cb_syslog_facility(enum grecs_callback_command cmd, | |||
601 | } | 611 | } |
602 | 612 | ||
603 | static int | 613 | static int |
604 | cb_define_message(enum grecs_callback_command cmd, | 614 | cb_define_message(enum grecs_callback_command cmd, grecs_node_t *node, |
605 | grecs_locus_t *locus, | 615 | void *varptr, void *cb_data) |
606 | void *varptr, grecs_value_t *value, void *cb |