2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 //////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup MY 14 Platform Software Team
19 /// \brief Internal Header for ns_config_parser_cfg.c
21 /// These functions are used to read from and write to cfg file.
24 //////////////////////////////////////////////////////////////////////////////////////////////////
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_
33 ///////////////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////////////
36 #include <ns_config_parser_internal.h>
37 ////////////////////////////////////////////////////////////////////////////////////////////
39 /// Function : Traverse cfg file and read value corresponding to key.
41 /// \param [in] filePtr
42 /// FILE * - filePtr is a Pointer to a file descriptor.
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.
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
52 ///////////////////////////////////////////////////////////////////////////////////////////
53 int CFGGetValue(FILE *file_ptr, const char *p_key, char *p_ret_value);
55 ////////////////////////////////////////////////////////////////////////////////////////////
56 /// CFGUpdateOldValue:
57 /// Function : Traverse the cfg file and update the value corresponding to given key.
59 /// \param [in] hConfigFile
60 /// HANDLE - hConfigFile is a handle to given file.
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.
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
71 ///////////////////////////////////////////////////////////////////////////////////////////
72 int CFGUpdateOldValue(HANDLE h_config_file, const char *p_key, const char *p_value);
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
79 /// \param [in] hConfigFile
80 /// HANDLE - hConfigFile is a handle to given file.
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.
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
93 ///////////////////////////////////////////////////////////////////////////////////////////
95 int CFGUpdateOldValueWithNewValue(HANDLE h_config_file, const char *p_key,
96 const char *p_old_value, const char *p_new_value);
102 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_