diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-06 22:33:05 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-06 22:45:10 +0200 |
commit | 826bb71c57d903f760c89406f93d19fe0c131de0 (patch) | |
tree | f2fc240d52d9be2d668a6ea8a813ab5de5732647 /src/config.c | |
parent | 5b29f3ecc4e2edb172d50b23732a588b7a71ce62 (diff) | |
download | wydawca-826bb71c57d903f760c89406f93d19fe0c131de0.tar.gz wydawca-826bb71c57d903f760c89406f93d19fe0c131de0.tar.bz2 |
Replace mu_url_t with a custom URL.
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 89 |
1 files changed, 79 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c index b381834..05d76de 100644 --- a/src/config.c +++ b/src/config.c @@ -45,6 +45,72 @@ tok_to_keyword(int tok, struct keyword *kw, const char **pres) return 1; } +static struct keyword kwfac[] = { + { "USER", LOG_USER }, + { "DAEMON", LOG_DAEMON }, + { "AUTH", LOG_AUTH }, + { "AUTHPRIV",LOG_AUTHPRIV }, + { "MAIL", LOG_MAIL }, + { "CRON", LOG_CRON }, + { "LOCAL0", LOG_LOCAL0 }, + { "LOCAL1", LOG_LOCAL1 }, + { "LOCAL2", LOG_LOCAL2 }, + { "LOCAL3", LOG_LOCAL3 }, + { "LOCAL4", LOG_LOCAL4 }, + { "LOCAL5", LOG_LOCAL5 }, + { "LOCAL6", LOG_LOCAL6 }, + { "LOCAL7", LOG_LOCAL7 }, + { NULL } +}; + +static struct keyword kwpri[] = { + { "EMERG", LOG_EMERG }, + { "ALERT", LOG_ALERT }, + { "CRIT", LOG_CRIT }, + { "ERR", LOG_ERR }, + { "WARNING", LOG_WARNING }, + { "NOTICE", LOG_NOTICE }, + { "INFO", LOG_INFO }, + { "DEBUG", LOG_DEBUG }, + { NULL } +}; + +int +wy_strtofac(const char *str) +{ + int res; + if (keyword_to_tok(str, kwfac, &res)) + return -1; + return res; +} + +int +wy_strtopri(const char *str) +{ + int res; + if (keyword_to_tok(str, kwpri, &res)) + return -1; + return res; +} + +const char * +wy_pritostr(int pri) +{ + const char *res; + if (tok_to_keyword(pri, kwpri, &res)) + return NULL; + return res; +} + +const char * +wy_factostr(int fac) +{ + const char *res; + if (tok_to_keyword(fac, kwfac, &res)) + return NULL; + return res; +} + static struct archive_descr default_archive_descr = { archive_none, NULL, @@ -599,14 +665,18 @@ cb_syslog_facility(enum grecs_callback_command cmd, grecs_node_t *node, { grecs_locus_t *locus = &node->locus; grecs_value_t *value = node->v.value; - + int fac; + if (assert_string_arg(locus, cmd, value)) return 1; - if (mu_string_to_syslog_facility(value->v.string, varptr)) + fac = wy_strtofac(value->v.string); + if (fac == -1) grecs_error(&value->locus, 0, _("Unknown syslog facility `%s'"), value->v.string); + else + *(int*)varptr = fac; return 0; } @@ -1052,18 +1122,17 @@ static int cb_url(enum grecs_callback_command cmd, grecs_node_t *node, void *varptr, void *cb_data) { - mu_url_t *purl = varptr, url; - int rc; + wy_url_t *purl = varptr, url; grecs_locus_t *locus = &node->locus; grecs_value_t *value = node->v.value; if (assert_string_arg(locus, cmd, value)) return 1; - rc = mu_url_create(&url, value->v.string); - if (rc) { + url = wy_url_create(value->v.string); + if (!url) { grecs_error(&value->locus, 0, _("cannot create URL `%s': %s"), - value->v.string, mu_strerror(rc)); - return rc; + value->v.string, strerror(errno)); + return 1; } *purl = url; return 0; @@ -1158,7 +1227,7 @@ cb_spool(enum grecs_callback_command cmd, grecs_node_t *node, rc = 1; } else if (url_to_vtab(spool->dest_url, &spool->vtab)) { grecs_error(locus, 0, _("unsupported url: %s"), - mu_url_to_string(spool->dest_url)); + wy_url_printable(spool->dest_url)); rc = 1; } else if (spool->vtab.test_url && spool->vtab.test_url(spool->dest_url, locus)) @@ -1179,7 +1248,7 @@ cb_spool(enum grecs_callback_command cmd, grecs_node_t *node, if (!spool->notification) spool->notification = default_notification; - mu_url_sget_path(spool->dest_url, &spool->dest_dir); + spool->dest_dir = wy_url_printable(spool->dest_url); register_spool(spool); free(spool); *pdata = NULL; |