]> git.meshlink.io Git - meshlink/blob - src/conf.h
63d5fef4aef369143af63faa1f9a2a20853852fe
[meshlink] / src / conf.h
1 #ifndef MESHLINK_CONF_H
2 #define MESHLINK_CONF_H
3
4 /*
5     econf.h -- header for econf.c
6     Copyright (C) 2018 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 struct meshlink_handle;
24
25 typedef struct config_t {
26         const uint8_t *buf;
27         size_t len;
28 } config_t;
29
30 typedef void (*config_scan_action_t)(struct meshlink_handle *mesh, const char *name);
31
32 //extern bool config_read_file(struct meshlink_handle *mesh, FILE *f, struct config_t *);
33 //extern bool config_write_file(struct meshlink_handle *mesh, FILE *f, const struct config_t *);
34 extern void config_free(struct config_t *config);
35
36 extern bool config_init(struct meshlink_handle *mesh);
37 extern bool config_destroy(const char *confbase);
38
39 extern bool main_config_exists(struct meshlink_handle *mesh);
40 extern bool main_config_lock(struct meshlink_handle *mesh);
41 extern void main_config_unlock(struct meshlink_handle *mesh);
42 extern bool main_config_read(struct meshlink_handle *mesh, struct config_t *);
43 extern bool main_config_write(struct meshlink_handle *mesh, const struct config_t *);
44
45 extern bool config_exists(struct meshlink_handle *mesh, const char *name);
46 extern bool config_read(struct meshlink_handle *mesh, const char *name, struct config_t *);
47 extern bool config_write(struct meshlink_handle *mesh, const char *name, const struct config_t *);
48 extern void config_scan_all(struct meshlink_handle *mesh, config_scan_action_t action);
49
50 extern bool invitation_read(struct meshlink_handle *mesh, const char *name, struct config_t *);
51 extern bool invitation_write(struct meshlink_handle *mesh, const char *name, const struct config_t *);
52 extern size_t invitation_purge_old(struct meshlink_handle *mesh, time_t deadline);
53
54 #endif