root/src/noit_conf.h

Revision 4fd2f1f5cb3d57993fc34dc8d6e742d38454609f, 5.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

This appears to work... now we need to make sure it works well. refs #142

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _NOIT_CONF_H
34 #define _NOIT_CONF_H
35
36 #include "noit_defines.h"
37 #include "utils/noit_hash.h"
38 #include "noit_console.h"
39
40 #include <uuid/uuid.h>
41
42 typedef void * noit_conf_section_t;
43
44 #define NOIT_CONF_T_USERDATA "noit::state::conf_t"
45 typedef struct {
46   char *path;
47   uuid_t current_check;
48   char prompt[50];
49 } noit_conf_t_userdata_t;
50
51 /* seconds == 0 disable config journaling watchdog */
52 API_EXPORT(void) noit_conf_coalesce_changes(u_int32_t seconds);
53 /* Start the watchdog */
54 API_EXPORT(void) noit_conf_watch_and_journal_watchdog(int (*f)(void *), void *c);
55
56 /* marks the config as changed.. if you manipulate the XML tree in any way
57  * you must call this function to "let the system know."  This is used
58  * to notice changes which are in turn flushed out.
59  */
60 API_EXPORT(void) noit_conf_mark_changed();
61
62 API_EXPORT(void) noit_conf_init(const char *toplevel);
63 API_EXPORT(int) noit_conf_load(const char *path);
64 API_EXPORT(int) noit_conf_save(const char *path);
65 API_EXPORT(char *) noit_conf_config_filename();
66
67 API_EXPORT(noit_conf_section_t)
68   noit_conf_get_section(noit_conf_section_t section, const char *path);
69 API_EXPORT(noit_conf_section_t *)
70   noit_conf_get_sections(noit_conf_section_t section, const char *path,
71                          int *cnt);
72
73 API_EXPORT(noit_hash_table *)
74   noit_conf_get_hash(noit_conf_section_t section, const char *path);
75
76 API_EXPORT(int) noit_conf_get_string(noit_conf_section_t section,
77                                      const char *path, char **value);
78
79 API_EXPORT(int) noit_conf_get_stringbuf(noit_conf_section_t section,
80                                         const char *path, char *value, int len);
81 API_EXPORT(int) noit_conf_get_int(noit_conf_section_t section,
82                                   const char *path, int *value);
83 API_EXPORT(int) noit_conf_get_float(noit_conf_section_t section,
84                                     const char *path, float *value);
85 API_EXPORT(int) noit_conf_get_boolean(noit_conf_section_t section,
86                                       const char *path, noit_boolean *value);
87 API_EXPORT(int)
88   noit_conf_get_uuid(noit_conf_section_t section,
89                      const char *path, uuid_t out);
90
91 API_EXPORT(int) noit_conf_set_string(noit_conf_section_t section,
92                                      const char *path, const char *value);
93 API_EXPORT(int) noit_conf_set_int(noit_conf_section_t section,
94                                   const char *path, int value);
95 API_EXPORT(int) noit_conf_set_float(noit_conf_section_t section,
96                                     const char *path, float value);
97 API_EXPORT(int) noit_conf_set_boolean(noit_conf_section_t section,
98                                       const char *path, noit_boolean value);
99
100 API_EXPORT(int)
101   noit_conf_reload(noit_console_closure_t ncct,
102                    int argc, char **argv,
103                    noit_console_state_t *state, void *closure);
104 API_EXPORT(int)
105   noit_conf_write_terminal(noit_console_closure_t ncct,
106                            int argc, char **argv,
107                            noit_console_state_t *state, void *closure);
108 API_EXPORT(int)
109   noit_conf_write_file(noit_console_closure_t ncct,
110                        int argc, char **argv,
111                        noit_console_state_t *state, void *closure);
112
113 API_EXPORT(char *)
114   noit_conf_xml_in_mem(size_t *len);
115
116 API_EXPORT(int)
117   noit_conf_write_log();
118
119 API_EXPORT(void) noit_conf_log_init(const char *toplevel);
120
121 #endif
Note: See TracBrowser for help on using the browser.