aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-16 01:30:44 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-16 01:37:24 +0200
commit5000c56d29cf616c8df80f8ec9a19682769f512e (patch)
treed2cc46fda9e8905bdd2fb81bffdaf3a58898be53 /src/wydawca.c
parenta72cd5987c404080f18ba40bdc4c06811493ab1c (diff)
downloadwydawca-5000c56d29cf616c8df80f8ec9a19682769f512e.tar.gz
wydawca-5000c56d29cf616c8df80f8ec9a19682769f512e.tar.bz2
Rewrite configuration parser, drop dependency on GSC
* bootstrap: Replaced with a modified version from gnulib. * configure.ac: Bump version to 1.9.90 (--without-preprocessor): New option Require Mailutils 2.0 (AC_CONFIG_FILES): Remove lib, add gconf * gconf/: New directory. Contains general-purpose configuration file parser, distilled from Dico and Mailutils. * src/Makefile.am (wydawca_SOURCES): Add interval.c * src/pp-setup, src/update-2.0.awk: New files. * src/config.c: Full rewrite. * src/exec.c (start_prog): Use getdtablesize unconditionally. * src/mail.c: Keep templates in a hash table. Template references begin with a single @ * src/process.c, src/triplet.c, src/verify.c: Reflect changes to struct directory_pair * src/wydawca.c: Change configuration parsing. * src/wydawca.h (enum access_method_id): New constants (struct directory_pair): Replace four access methods with an array. * Makefile.am (SUBDIRS): Remove lib, add gconf * .gitignore, NEWS, doc/.gitignore, src/.gitignore
Diffstat (limited to 'src/wydawca.c')
-rw-r--r--src/wydawca.c73
1 files changed, 63 insertions, 10 deletions
diff --git a/src/wydawca.c b/src/wydawca.c
index a1153cc..36201ca 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -1,5 +1,5 @@
/* wydawca - automatic release submission daemon
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2009 Sergey Poznyakoff
Wydawca is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -16,6 +16,8 @@
#include "wydawca.h"
#include "mail.h"
+#include "argmatch.h"
+#include "version-etc.h"
char *conffile = SYSCONFDIR "/wydawca.rc" ;
int debug_level;
@@ -55,7 +57,8 @@ usage ()
printf ("\nThe defaults are:\n");
printf ("Configuration file: %s\n", conffile);
- printf ("Syslog facility: %s\n", gsc_syslog_facility_to_str (log_facility));
+ printf ("Syslog facility: %s\n",
+ mu_syslog_facility_to_string (log_facility));
printf ("Syslog tag: %s\n", syslog_tag);
printf ("\n");
printf ("Report bugs to <%s>\n", PACKAGE_BUGREPORT);
@@ -70,7 +73,7 @@ syslog_printer (int prio, const char *fmt, va_list ap)
{
static char *fmtbuf;
static size_t fmtsize;
- const char *p = gsc_syslog_priority_to_str (prio);
+ const char *p = mu_syslog_priority_to_string (prio);
size_t size = strlen (p) + 3 + strlen (fmt) + 1;
if (size > fmtsize)
@@ -94,7 +97,7 @@ syslog_printer (int prio, const char *fmt, va_list ap)
void
stderr_printer (int prio, const char *fmt, va_list ap)
{
- const char *p = gsc_syslog_priority_to_str (prio);
+ const char *p = mu_syslog_priority_to_string (prio);
fprintf (stderr, "%s: ", program_name);
if (p)
@@ -134,11 +137,17 @@ logmsg (int prio, char *fmt, ...)
enum {
- SYSLOG_OPTION = 256
+ SYSLOG_OPTION = 256,
+ CONFIG_HELP_OPTION,
+ DUMP_GRAMMAR_TRACE_OPTION,
+ DUMP_LEX_TRACE_OPTION
};
struct option options[] = {
{ "config-file", required_argument, NULL, 'c' },
+ { "config-help", no_argument, NULL, CONFIG_HELP_OPTION },
+ { "dump-grammar-trace", no_argument, NULL, DUMP_GRAMMAR_TRACE_OPTION },
+ { "dump-lex-trace", no_argument, NULL, DUMP_LEX_TRACE_OPTION },
{ "debug", no_argument, NULL, 'd' },
{ "stderr", no_argument, NULL, 'e' },
{ "syslog", no_argument, NULL, SYSLOG_OPTION },
@@ -233,6 +242,35 @@ logstats ()
}
+void
+gconf_print_diag (gconf_locus_t *locus, int err, int errcode, const char *msg)
+{
+ if (locus)
+ {
+ if (errcode)
+ logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s: %s",
+ locus->file, (unsigned long)locus->line, msg,
+ strerror (errcode));
+ else
+ logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s",
+ locus->file, (unsigned long)locus->line, msg);
+ }
+ else
+ {
+ if (errcode)
+ logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s", msg,
+ strerror (errcode));
+ else
+ logmsg (err ? LOG_ERR : LOG_WARNING, "%s", msg);
+ }
+}
+
+const char version_etc_copyright[] =
+ /* Do *not* mark this string for translation. %s is a copyright
+ symbol suitable for this locale, and %d is the copyright
+ year. */
+ "Copyright %s %d Sergey Poznyakoff, Inc.";
+
int
main (int argc, char **argv)
@@ -241,8 +279,8 @@ main (int argc, char **argv)
int lint_mode = 0;
program_name = argv[0];
- gsc_config_include_dir = SYSCONFDIR;
mu_register_all_mailer_formats ();
+ config_init ();
while ((c = getopt_long (argc, argv, "c:dehI::ntv", options, NULL)) != EOF)
{
switch (c)
@@ -268,7 +306,7 @@ main (int argc, char **argv)
exit (0);
case 'I':
- gsc_config_include_dir = optarg;
+ gconf_preproc_add_include_dir (optarg);
break;
case 'n':
@@ -277,13 +315,26 @@ main (int argc, char **argv)
dry_run_mode = 1;
break;
+ case CONFIG_HELP_OPTION:
+ config_help ();
+ exit (0);
+
+ case DUMP_GRAMMAR_TRACE_OPTION:
+ gconf_gram_trace (1);
+ break;
+
+ case DUMP_LEX_TRACE_OPTION:
+ gconf_lex_trace (1);
+ break;
+
case 't':
lint_mode = 1;
log_to_stderr = 1;
break;
case 'v':
- gsc_version ("wydawca");
+ version_etc (stdout, argv[0], PACKAGE_NAME,
+ PACKAGE_VERSION, "Sergey Poznyakoff", NULL);
exit (0);
default:
@@ -294,13 +345,15 @@ main (int argc, char **argv)
if (argc != optind)
error (1, 0, "extra command line arguments");
- parse_config ();
+ gconf_parse (conffile);
+
if (lint_mode)
exit (0);
if (log_to_stderr == -1)
log_to_stderr = isatty (0);
-
+
+ gconf_log_to_stderr = log_to_stderr;
if (!log_to_stderr)
{
openlog (syslog_tag, LOG_PID, log_facility);

Return to:

Send suggestions and report system problems to the System administrator.