degesch: refactoring
This commit is contained in:
parent
7d531a9bbf
commit
25bb7a978d
32
degesch.c
32
degesch.c
|
@ -2156,18 +2156,8 @@ log_message_attributed (void *user_data, const char *quote, const char *fmt,
|
||||||
input_show (&ctx->input);
|
input_show (&ctx->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static ssize_t
|
||||||
apply_attribute_change (struct config_item *item, int id)
|
attr_by_name (const char *name)
|
||||||
{
|
|
||||||
struct app_context *ctx = item->user_data;
|
|
||||||
free (ctx->attrs[id]);
|
|
||||||
ctx->attrs[id] = xstrdup (item->type == CONFIG_ITEM_NULL
|
|
||||||
? ctx->attrs_defaults[id]
|
|
||||||
: item->value.string.str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_config_attribute_change (struct config_item *item)
|
|
||||||
{
|
{
|
||||||
static const char *table[ATTR_COUNT] =
|
static const char *table[ATTR_COUNT] =
|
||||||
{
|
{
|
||||||
|
@ -2177,10 +2167,22 @@ on_config_attribute_change (struct config_item *item)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < N_ELEMENTS (table); i++)
|
for (size_t i = 0; i < N_ELEMENTS (table); i++)
|
||||||
if (!strcmp (item->schema->name, table[i]))
|
if (!strcmp (name, table[i]))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_config_attribute_change (struct config_item *item)
|
||||||
{
|
{
|
||||||
apply_attribute_change (item, i);
|
struct app_context *ctx = item->user_data;
|
||||||
return;
|
ssize_t id = attr_by_name (item->schema->name);
|
||||||
|
if (id != -1)
|
||||||
|
{
|
||||||
|
free (ctx->attrs[id]);
|
||||||
|
ctx->attrs[id] = xstrdup (item->type == CONFIG_ITEM_NULL
|
||||||
|
? ctx->attrs_defaults[id]
|
||||||
|
: item->value.string.str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue