Init basesystem source codes.
[staging/basesystem.git] / nsframework / framework_unified / client / NS_XMLConfigeParser / library / include / ns_config_parser_cfg.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 //////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup MY 14 Platform Software Team
19 /// \brief   Internal Header for ns_config_parser_cfg.c
20 ///
21 ///  These functions are used to read  from and write to cfg file.
22 ///
23 ///
24 //////////////////////////////////////////////////////////////////////////////////////////////////
25
26 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
27 #define FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 ///////////////////////////////////////////////////////////////////////////////
34 // Include Files
35 ///////////////////////////////////////////////////////////////////////////////
36 #include <ns_config_parser_internal.h>
37 ////////////////////////////////////////////////////////////////////////////////////////////
38 /// CFGGetValue:
39 /// Function : Traverse cfg file and read value corresponding to key.
40 ///
41 /// \param [in] filePtr
42 ///       FILE * - filePtr is a Pointer to a file descriptor.
43 /// \param [in] pKey
44 ///       const char * -pKey is a Pointer to user key.
45 /// \param [in] pRetValue
46 ///       char *  - pRetValue is a Pointer to value or values to be returned corresponding to user key.
47 /// \return status
48 ///       int  - value returned depending upon user provided Key is valid or not.\n
49 ///       returns 1 if user passed invalid key.\n
50 ///       returns 0 if user passed valid key.\n
51 ///
52 ///////////////////////////////////////////////////////////////////////////////////////////
53 int CFGGetValue(FILE *file_ptr, const char *p_key, char *p_ret_value);
54
55 ////////////////////////////////////////////////////////////////////////////////////////////
56 /// CFGUpdateOldValue:
57 /// Function : Traverse the cfg file and update the value corresponding to given key.
58 ///
59 /// \param [in] hConfigFile
60 ///       HANDLE       - hConfigFile is a handle to given file.
61 /// \param [in] pKey
62 ///       const char * - pKey is a Pointer to user key.
63 /// \param [in] pValue
64 ///       const char * - pValue is a Pointer to new value corresponding to user key.
65 /// \return status
66 ///       int - returns 1 if user passed invalid key.\n
67 ///             returns 0 if user passed valid key.\n
68 ///                   returns -1 if memory allocation fail.\n
69 ///             returns -6 if value not updated in file.\n
70 ///
71 ///////////////////////////////////////////////////////////////////////////////////////////
72 int  CFGUpdateOldValue(HANDLE h_config_file, const char *p_key, const char *p_value);
73
74 ////////////////////////////////////////////////////////////////////////////////////////////
75 /// CFGUpdateOldValueWithNewValue
76 /// Function : Traverse the cfg file read value to given node,compare with old value,\n
77 ///            if old value matched then write new value in place of old value.\n
78 ///
79 /// \param [in] hConfigFile
80 ///       HANDLE       - hConfigFile is a handle to given file.
81 /// \param [in] pKey
82 ///       const char * - pKey is a Pointer to user key.
83 /// \param [in] pOldValue
84 ///       const char * - pOldValue is a Pointer to Old Value corresponding to user key.
85 /// \param [in] pNewValue
86 ///       const char * - pNewValue is a Pointer to New Value corresponding to user key.
87 /// \return status
88 ///       int - returns 1 if user passed invalid key.\n
89 ///             returns 0 if user passed valid key.\n
90 ///                   returns -1 if memory allocation fail.\n
91 ///             returns -6 if value not updated in file.\n
92 ///
93 ///////////////////////////////////////////////////////////////////////////////////////////
94
95 int  CFGUpdateOldValueWithNewValue(HANDLE h_config_file, const char *p_key,
96                                    const char *p_old_value, const char *p_new_value);
97
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101
102 #endif  // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
103
104 // EOF