-}
-
-void cf_unregister (char *type)
-{
- cf_callback_t *this, *prev;
-
- for (prev = NULL, this = first_callback;
- this != NULL;
- prev = this, this = this->next)
- if (strcasecmp (this->type, type) == 0)
- {
- if (prev == NULL)
- first_callback = this->next;
- else
- prev->next = this->next;
-
- free (this);
- break;
- }
-}
-
-void cf_register (char *type,
- int (*callback) (char *, char *),
- char **keys, int keys_num)
-{
- cf_callback_t *cf_cb;
- char buf[64];
- int i;
-
- /* Remove this module from the list, if it already exists */
- cf_unregister (type);
-
- /* This pointer will be free'd in `cf_unregister' */
- if ((cf_cb = (cf_callback_t *) malloc (sizeof (cf_callback_t))) == NULL)
- return;
-
- cf_cb->type = type;
- cf_cb->callback = callback;
- cf_cb->keys = keys;
- cf_cb->keys_num = keys_num;
-
- cf_cb->next = first_callback;
- first_callback = cf_cb;
-
- for (i = 0; i < keys_num; i++)
- {
- if (snprintf (buf, 64, "Plugin.%s", keys[i]) < 64)
- {
- /* This may be called multiple times for the same
- * `key', but apparently `lc_register_*' can handle
- * it.. */
- lc_register_callback (buf, SHORTOPT_NONE,
- LC_VAR_STRING, cf_callback_plugin_dispatch,
- NULL);
- }
- else
- {
- DBG ("Key was truncated: `%s'", keys[i]);
- }
- }
-}