4 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
5 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __LASH_CONFIG_H__
23 #define __LASH_CONFIG_H__
27 #include <lash/types.h>
34 * Append a key-value pair of typed data to a config message.
36 * @param handle An opaque config message handle passed
37 * to the callback function by liblash.
38 * @param key The key string pointer.
39 * @param value The value pointer.
40 * @param type The value type. Must be one out of \ref LASH_TYPE_DOUBLE,
41 * \ref LASH_TYPE_INTEGER, and \ref LASH_TYPE_STRING.
42 * @return True if writing succeeded, false otherwise.
45 lash_config_write(lash_config_handle_t
*handle
,
51 * Append a key-value pair of raw data to a config message.
53 * @param handle An opaque config message handle passed
54 * to the callback function by liblash.
55 * @param key The key string pointer.
56 * @param buf The data buffer pointer.
57 * @param size The size of the data buffer in bytes.
58 * @return True if writing succeeded, false otherwise.
61 lash_config_write_raw(lash_config_handle_t
*handle
,
67 * Read a key-value pair of data from a config message.
69 * @param handle An opaque config message handle passed
70 * to the callback function by liblash.
71 * @param key_ptr A pointer to the memory location in which to
72 * save the key pointer.
73 * @param value_ptr A pointer to the memory location in which to
74 * save the value pointer.
75 * @param type_ptr A pointer to the memory location in which to
76 * save the value type.
77 * @return If reading succeeds the return value will be equal to the
78 * config value's size in bytes (for strings this includes the
79 * terminating NUL). If no data remains in the message the return
80 * value will 0, and -1 if an error occurred during reading.
83 lash_config_read(lash_config_handle_t
*handle
,
94 lash_config_new(void);
97 lash_config_destroy(lash_config_t
*config
);
100 lash_config_dup(const lash_config_t
*config
);
103 lash_config_new_with_key(const char *key
);
106 lash_config_get_key(const lash_config_t
*config
);
109 lash_config_get_value(const lash_config_t
*config
);
112 lash_config_get_value_size(const lash_config_t
*config
);
115 lash_config_set_key(lash_config_t
*config
,
119 lash_config_set_value(lash_config_t
*config
,
124 * With these functions, no type checking is done; you can do
125 * lash_config_get_value_int on a config that was set with
126 * lash_config_set_value_float.
130 lash_config_get_value_int(const lash_config_t
*config
);
133 lash_config_get_value_float(const lash_config_t
*config
);
136 lash_config_get_value_double(const lash_config_t
*config
);
139 lash_config_get_value_string(const lash_config_t
*config
);
142 lash_config_set_value_int(lash_config_t
*config
,
146 lash_config_set_value_float(lash_config_t
*config
,
149 lash_config_set_value_double(lash_config_t
*config
,
153 lash_config_set_value_string(lash_config_t
*config
,
162 #endif /* __LASH_CONFIG_H__ */