4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 * Internals of libslp-setting
25 * @file setting-internals.h
26 * @author Sangjung Woo (sangjung.woo@samsung.com)
28 * @brief This file is the header file of internal functions.
31 #ifndef __VCONF_GCONF_H__
32 #define __VCONF_GCONF_H__
34 #include "vconf-log.h"
37 #define BACKEND_DB_PREFIX "db/"
38 #define BACKEND_FILE_PREFIX "file/"
39 #define BACKEND_MEMORY_PREFIX "memory/"
41 #define BACKEND_SYSTEM_DIR "/opt/var/kdb/"
42 #define BACKEND_MEMORY_DIR "/var/run/"
44 /* This value can be optimized according to the device characteristcs and file system configuration */
45 #define FILE_ATOMIC_GUARANTEE_SIZE 4096
47 #define VCONF_BACKUP_COMPLETE_MARK 0x64416548
49 #define VCONF_KEY_PATH_LEN 1024
53 #define VCONF_TYPE_SIZE sizeof(int)
54 #define VCONF_BACKUP_COMP_MARK_SIZE sizeof(int)
57 VCONF_BACKEND_NULL = 0,
66 VCONF_TYPE_STRING = 40, /*KEY_TYPE_STRING of KDB is 40 */
68 VCONF_TYPE_DOUBLE = 42,
73 typedef int get_option_t;
80 /*This is a callback function pointer signature for value return*/
81 typedef void (*vconf_callback_fn) (keynode_t *node, void *user_data);
88 #define VCONF_ERROR -1
91 VCONF_ERROR_WRONG_PREFIX = 1,
92 VCONF_ERROR_WRONG_TYPE,
93 VCONF_ERROR_WRONG_VALUE,
95 VCONF_ERROR_NOT_INITIALIZED,
96 VCONF_ERROR_FILE_OPEN = 11,
97 VCONF_ERROR_FILE_FREAD,
98 VCONF_ERROR_FILE_FGETS,
99 VCONF_ERROR_FILE_WRITE,
100 VCONF_ERROR_FILE_SYNC,
101 VCONF_ERROR_FILE_CLOSE,
102 VCONF_ERROR_FILE_ACCESS,
103 VCONF_ERROR_FILE_CHMOD,
104 VCONF_ERROR_FILE_LOCK,
105 VCONF_ERROR_FILE_REMOVE,
106 VCONF_ERROR_FILE_SEEK,
107 VCONF_ERROR_FILE_TRUNCATE
110 #define return_err(err) return 0-err;
112 /* Error codes returned by the configuration manager */
116 VCONF_ERROR_UNKNOWN = -1,
117 VCONF_ERROR_SUCCESS = 0,
118 /* Something didn't work, don't know why, probably unrecoverable
119 so there's no point having a more specific errno */
120 VCONF_ERROR_FAILED = 1,
121 /* Server can't be launched/contacted */
122 VCONF_ERROR_NO_SERVER = 2,
123 /* don't have permission for that */
124 VCONF_ERROR_NO_PERMISSION = 3,
125 /* Address couldn't be resolved */
126 VCONF_ERROR_BAD_ADDRESS = 4,
127 /* directory or key isn't valid
128 (contains bad characters, or malformed slash arrangement) */
129 VCONF_ERROR_BAD_KEY = 5,
130 /* Syntax error when parsing */
131 VCONF_ERROR_PARSE_ERROR = 6,
132 /* Fatal error parsing/loading information inside the backend */
133 VCONF_ERROR_CORRUPT = 7,
134 /* Type requested doesn't match type found */
135 VCONF_ERROR_TYPE_MISMATCH = 8,
136 /* Requested key operation on a dir */
137 VCONF_ERROR_IS_DIR = 9,
138 /* Requested dir operation on a key */
139 VCONF_ERROR_IS_KEY = 10,
140 /* Read-only source at front of path has set the value */
141 VCONF_ERROR_OVERRIDDEN = 11,
143 VCONF_ERROR_OAF_ERROR = 12,
144 /* Tried to use remote operations on a local engine */
145 VCONF_ERROR_LOCAL_ENGINE = 13,
146 /* Failed to get a lockfile */
147 VCONF_ERROR_LOCK_FAILED = 14,
148 /* nowhere to write a value */
149 VCONF_ERROR_NO_WRITABLE_DATABASE = 15,
150 /* server is shutting down */
151 VCONF_ERROR_IN_SHUTDOWN = 16,
154 /* connection failure */
155 VCONF_CONF_CONNECTION_FAIL = 18,
156 /* invalid parameter */
157 VCONF_CONF_INVALID_PARAMETER = 19,
158 /* unable to get kdb key new */
159 VCONF_CONF_ERROR_GET_KDB_KEY_NEW = 20,
160 /* kdb open failure */
161 VCONF_CONF_ERROR_KDB_OPEN = 21,
162 /* unable to set kdb key val */
163 VCONF_CONF_ERROR_KDB_KEY_SET = 22,
164 /* unable to get kdb key val */
165 VCONF_CONF_ERROR_KDB_KEY_GET = 23,
166 /* unable to register callback notification */
167 VCONF_ERROR_NOTI_ADD_FILE_CB = 24,
168 /* kdb remove failure */
169 VCONF_CONF_ERROR_KDB_REMOVE = 25,
170 /* unable to remove callback function registered */
171 VCONF_ERROR_NOTI_DEL_FILE_CB = 26,
172 /*Supplied keylist is empty/Non existing */
173 VCONF_ERROR_NO_KEYLIST = 27,
174 /*This functionality is not supported */
175 VCONF_ERROR_NOT_SUPPORTED = 28,
176 /*Callback could not be called/Failed */
177 VCONF_ERROR_CALLBACK_FAILED = 29
181 int _vconf_kdb_add_notify
182 (const char *keyname, vconf_callback_fn cb, void *data);
183 int _vconf_kdb_del_notify
184 (const char *keyname, vconf_callback_fn cb);
186 int _vconf_get_key_path(const char *keyname, char *path);
187 int _vconf_get_key(keynode_t *keynode);
189 int _vconf_keynode_set_keyname(keynode_t *keynode, const char *keyname);
190 inline void _vconf_keynode_set_null(keynode_t *keynode);
191 inline keynode_t *_vconf_keynode_new(void);
192 inline void _vconf_keynode_free(keynode_t *keynode);