aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-16 13:58:09 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-16 13:58:09 +0300
commit3a16bc5620b4c664248bc5b5c586ddd0103f7050 (patch)
treeac32d299f907f5288cfffc10dceab87b1b682d8b
parent4549c2d6d9f7533541eb9ee4f4cf3190b94565f7 (diff)
downloadwydawca-3a16bc5620b4c664248bc5b5c586ddd0103f7050.tar.gz
wydawca-3a16bc5620b4c664248bc5b5c586ddd0103f7050.tar.bz2
Bugfix
* src/config.c: Case-insensitive comparison for syslog facility and priority names.
-rw-r--r--src/config.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/config.c b/src/config.c
index 6342f2f..692dbd5 100644
--- a/src/config.c
+++ b/src/config.c
@@ -21,17 +21,22 @@
struct keyword {
char *name;
int tok;
};
+enum {
+ CASE_SENSITIVE,
+ CASE_INSENSITIVE
+};
+
static int
-keyword_to_tok(const char *str, struct keyword *kw, int *pres)
+keyword_to_tok(const char *str, struct keyword *kw, int ci, int *pres)
{
for (; kw->name; kw++)
- if (strcmp(kw->name, str) == 0) {
+ if ((ci ? strcasecmp : strcmp)(kw->name, str) == 0) {
*pres = kw->tok;
return 0;
}
return 1;
}
@@ -77,22 +82,22 @@ static struct keyword kwpri[] = {
};
int
wy_strtofac(const char *str)
{
int res;
- if (keyword_to_tok(str, kwfac, &res))
+ if (keyword_to_tok(str, kwfac, CASE_INSENSITIVE, &res))
return -1;
return res;
}
int
wy_strtopri(const char *str)
{
int res;
- if (keyword_to_tok(str, kwpri, &res))
+ if (keyword_to_tok(str, kwpri, CASE_INSENSITIVE, &res))
return -1;
return res;
}
const char *
wy_pritostr(int pri)
@@ -231,13 +236,13 @@ wy_event_str(enum wy_event evt)
int
string_to_wy_event(grecs_locus_t *locus, const char *val,
enum wy_event *pret)
{
int res;
- if (keyword_to_tok(val, event_tab, &res)) {
+ if (keyword_to_tok(val, event_tab, CASE_SENSITIVE, &res)) {
grecs_error(locus, 0,
_("unknown notification event: %s"), val);
return 1;
}
*pret = res;
return 0;
@@ -383,13 +388,13 @@ parse_single_statmask(grecs_locus_t *locus, const grecs_value_t *val,
} else if (strcmp(arg, "none") == 0) {
*pmask = STAT_MASK_NONE;
*invert = 0;
return 0;
}
- if (keyword_to_tok(arg, stat_tab, &x)) {
+ if (keyword_to_tok(arg, stat_tab, CASE_SENSITIVE, &x)) {
grecs_error(&val->locus, 0, _("unknown statistics type: %s"),
arg);
return 1;
}
*pmask = STAT_MASK(x);
return 0;
@@ -610,13 +615,13 @@ static enum backup_type
get_backup_version(grecs_locus_t *locus, const char *ctx, const char *version)
{
int d;
if (version == 0 || *version == 0)
return numbered_existing_backups;
- else if (keyword_to_tok(version, backup_tab, &d)) {
+ else if (keyword_to_tok(version, backup_tab, CASE_SENSITIVE, &d)) {
if (ctx)
grecs_error(locus, 0,
_("%s: ambiguous backup type `%s'"), ctx,
version);
else
grecs_error(locus, 0, _("ambiguous backup type `%s'"),
@@ -887,13 +892,13 @@ string_to_dictionary_id(grecs_locus_t *locus,
{"project-uploader", project_uploader_dict},
{"project-owner", project_owner_dict},
{NULL}
};
int res;
- if (keyword_to_tok(str, id_tab, &res)) {
+ if (keyword_to_tok(str, id_tab, CASE_SENSITIVE, &res)) {
grecs_error(locus, 0, _("unknown dictionary ID: %s"), str);
return 1;
}
*idp = res;
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.