2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / common tools sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
25 #ifndef _GF_CONFIG_FILE_H_
\r
26 #define _GF_CONFIG_FILE_H_
\r
33 * \file <gpac/config_file.h>
\r
34 * \brief configuration file functions.
\r
38 * \addtogroup cfg_grp configuration
\r
39 * \ingroup utils_grp
\r
40 * \brief Configuration File object
\r
42 * This section documents the configuration file object of the GPAC framework.
\r
43 * This file is formatted as the INI file mode of WIN32 in sections and keys.\n
\r
44 *\note For more information on the GPAC configuration file itself, please refer to the GPAC configuration help provided with GPAC.
\r
48 #include <gpac/tools.h>
\r
51 typedef struct __tag_config GF_Config;
\r
54 * \brief configuration file constructor
\r
56 *Constructs a configuration file
\r
57 *\param filePath directory the file is located in
\r
58 *\param fileName name of the configuration file
\r
59 *\return the configuration file object
\r
61 GF_Config *gf_cfg_new(const char *filePath, const char *fileName);
\r
63 * \brief configuration file destructor
\r
65 *Destroys the configuration file and saves it if needed.
\r
66 *\param cfgFile the target configuration file
\r
68 void gf_cfg_del(GF_Config *cfgFile);
\r
70 * \brief configuration saving
\r
72 *Saves the configuration file if modified.
\r
73 *\param cfgFile the target configuration file
\r
75 GF_Err gf_cfg_save(GF_Config *iniFile);
\r
77 * \brief key value query
\r
79 *Gets a key value from its section and name.
\r
80 *\param cfgFile the target configuration file
\r
81 *\param secName the desired key parent section name
\r
82 *\param keyName the desired key name
\r
83 *\return the desired key value if found, NULL otherwise.
\r
85 const char *gf_cfg_get_key(GF_Config *cfgFile, const char *secName, const char *keyName);
\r
87 * \brief key value update
\r
89 *Sets a key value from its section and name.
\r
90 *\param cfgFile the target configuration file
\r
91 *\param secName the desired key parent section name
\r
92 *\param keyName the desired key name
\r
93 *\param keyValue the desired key value
\r
94 *\note this will also create both section and key if they are not found in the configuration file
\r
96 GF_Err gf_cfg_set_key(GF_Config *cfgFile, const char *secName, const char *keyName, const char *keyValue);
\r
98 * \brief section count query
\r
100 *Gets the number of sections in the configuration file
\r
101 *\param cfgFile the target configuration file
\r
102 *\return the number of sections
\r
104 u32 gf_cfg_get_section_count(GF_Config *cfgFile);
\r
106 * \brief section name query
\r
108 *Gets a section name based on its index
\r
109 *\param cfgFile the target configuration file
\r
110 *\param secIndex 0-based index of the section to query
\r
111 *\return the section name if found, NULL otherwise
\r
113 const char *gf_cfg_get_section_name(GF_Config *cfgFile, u32 secIndex);
\r
115 * \brief key count query
\r
117 *Gets the number of keys in a section of the configuration file
\r
118 *\param cfgFile the target configuration file
\r
119 *\param secName the target section
\r
120 *\return the number of keys in the section
\r
122 u32 gf_cfg_get_key_count(GF_Config *cfgFile, const char *secName);
\r
124 * \brief key count query
\r
126 *Gets the number of keys in a section of the configuration file
\r
127 *\param cfgFile the target configuration file
\r
128 *\param secName the target section
\r
129 *\param keyIndex 0-based index of the key in the section
\r
130 *\return the key name if found, NULL otherwise
\r
132 const char *gf_cfg_get_key_name(GF_Config *cfgFile, const char *secName, u32 keyIndex);
\r
135 * \brief key insertion
\r
137 *Inserts a new key in a given section. Returns an error if a key with the given name
\r
138 *already exists in the section
\r
139 *\param cfgFile the target configuration file
\r
140 *\param secName the target section
\r
141 *\param keyName the name of the target key
\r
142 *\param keyValue the value for the new key
\r
143 *\param index the 0-based index position of the new key
\r
145 GF_Err gf_cfg_insert_key(GF_Config *cfgFile, const char *secName, const char *keyName, const char *keyValue, u32 index);
\r
148 * \brief section destrouction
\r
150 *Removes all entries in the given section
\r
151 *\param cfgFile the target configuration file
\r
152 *\param secName the target section
\r
154 void gf_cfg_del_section(GF_Config *cfgFile, const char *secName);
\r
164 #endif /*_GF_CONFIG_FILE_H_*/
\r