configure: more regex troubles
[vlock.git] / src / plugin.c
blob654ad61e2458f0d3f2463c845df28318e92ab4c8
1 /* plugin.c -- generic plugin routines for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software which is freely distributable under the terms of the
6 * GNU General Public License version 2, included as the file COPYING in this
7 * distribution. It is NOT public domain software, and any
8 * redistribution not permitted by the GNU General Public License is
9 * expressly forbidden without prior written permission from
10 * the author.
14 #include <stdlib.h>
15 #include <string.h>
17 #include "list.h"
19 #include "plugin.h"
20 #include "util.h"
22 /* Allocate a new plugin struct. */
23 struct plugin *__allocate_plugin(const char *name)
25 struct plugin *p = ensure_malloc(sizeof *p);
27 p->name = strdup(name);
28 p->save_disabled = false;
30 for (size_t i = 0; i < nr_dependencies; i++)
31 p->dependencies[i] = list_new();
33 return p;
36 /* Destroy the given plugin. (Internal version.) */
37 void __destroy_plugin(struct plugin *p)
39 for (size_t i = 0; i < nr_dependencies; i++) {
40 list_delete_for_each(p->dependencies[i], dependency_item)
41 free(dependency_item->data);
43 list_free(p->dependencies[i]);
46 free(p->name);
47 free(p);
50 /* Destroy the given plugin. (External version.) */
51 void destroy_plugin(struct plugin *p)
53 p->close(p);
54 __destroy_plugin(p);