]> git.meshlink.io Git - meshlink/blob - src/conf.h
Lock meshlink.conf to ensure only one instance can run at a time.
[meshlink] / src / conf.h
1 #ifndef MESHLINK_CONF_H
2 #define MESHLINK_CONF_H
3
4 /*
5     conf.h -- header for conf.c
6     Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
7
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write to the Free Software Foundation, Inc.,
20     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 #include "list.h"
24 #include "meshlink_internal.h"
25 #include "splay_tree.h"
26
27 typedef struct config_t {
28         char *variable;
29         char *value;
30         int line;
31 } config_t;
32
33 extern void init_configuration(struct splay_tree_t **);
34 extern void exit_configuration(struct splay_tree_t **);
35 extern config_t *new_config(void) __attribute__((__malloc__));
36 extern void free_config(config_t *);
37 extern void config_add(struct splay_tree_t *, config_t *);
38 extern config_t *lookup_config(struct splay_tree_t *, char *);
39 extern config_t *lookup_config_next(struct splay_tree_t *, const config_t *);
40 extern bool get_config_bool(const config_t *, bool *);
41 extern bool get_config_int(const config_t *, int *);
42 extern bool set_config_int(config_t *, int);
43 extern bool get_config_string(const config_t *, char **);
44 extern bool set_config_string(config_t *, const char *);
45 extern bool get_config_address(const config_t *, struct addrinfo **);
46
47 extern bool read_server_config(struct meshlink_handle *mesh);
48 extern bool read_host_config(struct meshlink_handle *mesh, struct splay_tree_t *, const char *);
49 extern bool write_host_config(struct meshlink_handle *mesh, const struct splay_tree_t *, const char *);
50 extern bool modify_config_file(struct meshlink_handle *mesh, const char *name, const char *key, const char *value, int trim);
51 extern bool append_config_file(struct meshlink_handle *mesh, const char *name, const char *key, const char *value);
52
53 #endif