Tizen RT Libs&Environment  v1.1 D4
inifile.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * apps/include/inifile.h
20  *
21  * Copyright (C) 2014 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
52 
53 #ifndef __APPS_INCLUDE_INIFILE_H
54 #define __APPS_INCLUDE_INIFILE_H
55 
56 /****************************************************************************
57  * Included Files
58  ****************************************************************************/
59 
60 #include <tinyara/config.h>
61 
62 /****************************************************************************
63  * Pre-Processor Definitions
64  ****************************************************************************/
65 
66 /****************************************************************************
67  * Public Types
68  ****************************************************************************/
69 
70 typedef FAR void *INIHANDLE;
71 
72 /****************************************************************************
73  * Public Data
74  ****************************************************************************/
75 
76 #ifdef __cplusplus
77 // *INDENT-OFF*
78 #define EXTERN extern "C"
79 extern "C" {
80 #else
81 #define EXTERN extern
82 // *INDENT-ON*
83 #endif
84 
85 /****************************************************************************
86  * Public Function Prototypes
87  ****************************************************************************/
88 
89 /****************************************************************************
90  * Name: inifile_initialize
91  *
92  * Description:
93  * Initialize for access to the INI file 'inifile_name'
94  *
95  ****************************************************************************/
96 
97 INIHANDLE inifile_initialize(FAR const char *inifile_name);
98 
99 /****************************************************************************
100  * Name: inifile_uninitialize
101  *
102  * Description:
103  * Free resources commit to INI file parsing
104  *
105  ****************************************************************************/
106 
107 void inifile_uninitialize(INIHANDLE handle);
108 
109 /****************************************************************************
110  * Name: inifile_read_string
111  *
112  * Description:
113  * Obtains the specified string value for the specified variable name
114  * within the specified section of the INI file. The receiver of the
115  * value string should call inifile_free_string when it no longer needs
116  * the memory held by the value string.
117  *
118  ****************************************************************************/
119 
120 FAR char *inifile_read_string(INIHANDLE handle, FAR const char *section, FAR const char *variable, FAR const char *defvalue);
121 
122 /****************************************************************************
123  * Name: inifile_read_integer
124  *
125  * Description:
126  * Obtains the specified integer value for the specified variable name
127  * within the specified section of the INI file
128  *
129  ****************************************************************************/
130 
131 long inifile_read_integer(INIHANDLE handle, FAR const char *section, FAR const char *variable, FAR long defvalue);
132 
133 /****************************************************************************
134  * Name: inifile_free_string
135  *
136  * Description:
137  * Release resources allocated for the value string previously obtained
138  * from inifile_read_string. The purpose of this inline function is to
139  * hide the memory allocator used by this implementation.
140  *
141  ****************************************************************************/
142 
143 void inifile_free_string(FAR char *value);
144 
145 #undef EXTERN
146 #ifdef __cplusplus
147 // *INDENT-OFF*
148 }
149 // *INDENT-ON*
150 #endif
151 
152 #endif /* __APPS_INCLUDE_INIFILE_H */
long inifile_read_integer(INIHANDLE handle, FAR const char *section, FAR const char *variable, FAR long defvalue)
void inifile_free_string(FAR char *value)
INIHANDLE inifile_initialize(FAR const char *inifile_name)
FAR void * INIHANDLE
Definition: inifile.h:70
void inifile_uninitialize(INIHANDLE handle)
FAR char * inifile_read_string(INIHANDLE handle, FAR const char *section, FAR const char *variable, FAR const char *defvalue)