Add support for resolver modules
[connman] / src / resolver.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "connman.h"
27
28 static GStaticRWLock resolver_lock = G_STATIC_RW_LOCK_INIT;
29 static GSList *resolver_list = NULL;
30
31 /**
32  * connman_resolver_register:
33  * @resolver: resolver module
34  *
35  * Register a new resolver module
36  *
37  * Returns: %0 on success
38  */
39 int connman_resolver_register(struct connman_resolver *resolver)
40 {
41         DBG("resolver %p name %s", resolver, resolver->name);
42
43         g_static_rw_lock_writer_lock(&resolver_lock);
44
45         resolver_list = g_slist_append(resolver_list, resolver);
46
47         g_static_rw_lock_writer_unlock(&resolver_lock);
48
49         return 0;
50 }
51
52 /**
53  * connman_resolver_unregister:
54  * @resolver: resolver module
55  *
56  * Remove a previously registered resolver module
57  */
58 void connman_resolver_unregister(struct connman_resolver *resolver)
59 {
60         DBG("resolver %p name %s", resolver, resolver->name);
61
62         g_static_rw_lock_writer_lock(&resolver_lock);
63
64         resolver_list = g_slist_remove(resolver_list, resolver);
65
66         g_static_rw_lock_writer_unlock(&resolver_lock);
67 }