attribute_manager supports attribute_handler's to handle configuration attributes...
[strongswan.git] / src / charon / plugins / attr / attr_plugin.c
1 /*
2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 #include "attr_plugin.h"
19 #include "attr_provider.h"
20
21 #include <daemon.h>
22
23 typedef struct private_attr_plugin_t private_attr_plugin_t;
24
25 /**
26 * private data of attr plugin
27 */
28 struct private_attr_plugin_t {
29
30 /**
31 * implements plugin interface
32 */
33 attr_plugin_t public;
34
35 /**
36 * CFG attributes provider
37 */
38 attr_provider_t *provider;
39 };
40
41 /**
42 * Implementation of plugin_t.destroy
43 */
44 static void destroy(private_attr_plugin_t *this)
45 {
46 charon->attributes->remove_provider(charon->attributes, &this->provider->provider);
47 this->provider->destroy(this->provider);
48 free(this);
49 }
50
51 /*
52 * see header file
53 */
54 plugin_t *plugin_create()
55 {
56 private_attr_plugin_t *this = malloc_thing(private_attr_plugin_t);
57
58 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
59
60 this->provider = attr_provider_create();
61 charon->attributes->add_provider(charon->attributes, &this->provider->provider);
62
63 return &this->public.plugin;
64 }
65