typedef struct cf_value_map_s
{
- char *key;
+ const char *key;
int (*func) (oconfig_item_t *);
} cf_value_map_t;
typedef struct cf_global_option_s
{
- char *key;
+ const char *key;
char *value;
- char *def;
+ const char *def;
} cf_global_option_t;
/*
static int dispatch_value_plugindir (oconfig_item_t *ci)
{
assert (strcasecmp (ci->key, "PluginDir") == 0);
-
+
if (ci->values_num != 1)
return (-1);
if (ci->values[0].type != OCONFIG_TYPE_STRING)
static int dispatch_block_plugin (oconfig_item_t *ci)
{
int i;
- char *name;
+ const char *name;
cf_complex_callback_t *cb;
return (NULL);
}
- root = (oconfig_item_t *) malloc (sizeof (oconfig_item_t));
+ root = calloc (1, sizeof (*root));
if (root == NULL)
{
- ERROR ("configfile: malloc failed.");
+ ERROR ("configfile: calloc failed.");
closedir (dh);
return (NULL);
}
- memset (root, 0, sizeof (oconfig_item_t));
while ((de = readdir (dh)) != NULL)
{
return (NULL);
}
- root = (oconfig_item_t *) malloc (sizeof (oconfig_item_t));
+ root = calloc (1, sizeof (*root));
if (root == NULL)
{
- ERROR ("configfile: malloc failed.");
+ ERROR ("configfile: calloc failed.");
return (NULL);
}
- memset (root, '\0', sizeof (oconfig_item_t));
/* wordexp() might return a sorted list already. That's not
* documented though, so let's make sure we get what we want. */
} /* oconfig_item_t *cf_read_generic */
#endif /* !HAVE_WORDEXP_H */
-/*
+/*
* Public functions
*/
int global_option_set (const char *option, const char *value)
if (i >= cf_global_options_num)
return (NULL);
-
+
return ((cf_global_options[i].value != NULL)
? cf_global_options[i].value
: cf_global_options[i].def);
cf_unregister (type);
/* This pointer will be free'd in `cf_unregister' */
- if ((cf_cb = (cf_callback_t *) malloc (sizeof (cf_callback_t))) == NULL)
+ if ((cf_cb = malloc (sizeof (*cf_cb))) == NULL)
return;
cf_cb->type = type;
{
cf_complex_callback_t *new;
- new = (cf_complex_callback_t *) malloc (sizeof (cf_complex_callback_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
return (-1);
return (0);
} /* int cf_register_complex */
-int cf_read (char *filename)
+int cf_read (const char *filename)
{
oconfig_item_t *conf;
int i;