2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief user experiance library(common function in read configuration)
17 #include <sys/types.h>
25 #include "ico_apf_log.h"
26 #include "ico_apf_apimacro.h"
27 #include "ico_uxf_conf_common.h"
29 /* Number of hash table */
30 #define ICO_UXF_MISC_HASHSIZE 64 /* Must be 2's factorial */
32 /*--------------------------------------------------------------------------*/
34 * @brief ico_uxf_misc_hashByName: create hash value by name string
35 * there is no distinction of an english capital letter/small
37 * @param[in] name character string changed into a hash value(NULL termination)
39 * @return create hash value
41 /*--------------------------------------------------------------------------*/
43 ico_uxf_misc_hashByName(const char *name)
48 for (i = 0; name[i]; i++) {
49 hash = (hash << 1) | (name[i] & 0x1f);
51 return hash & (ICO_UXF_MISC_HASHSIZE-1);
54 /*--------------------------------------------------------------------------*/
56 * @brief ico_uxf_conf_getUint: convert value string to value
58 * @param[in] str string
59 * @return converted value
61 /*--------------------------------------------------------------------------*/
63 ico_uxf_conf_getUint(const char* str)
67 if ((strcasecmp(str, "true") == 0) ||
68 (strcasecmp(str, "yes") == 0)) {
71 else if ((strcasecmp(str, "false") == 0) ||
72 (strcasecmp(str, "no") == 0)) {
76 char *errpt = (char *)0;
77 key = strtol(str, &errpt, 0);
78 if ((errpt) && (*errpt != 0)) {
86 /*--------------------------------------------------------------------------*/
88 * @brief ico_uxf_conf_countNumericalKey: count numerical keys in configuration file
90 * @param[in] keyfile configuration file
91 * @param[in] group configuration groupe(ex.[display])
92 * @return configuration list
94 /*--------------------------------------------------------------------------*/
96 ico_uxf_conf_countNumericalKey(GKeyFile *keyfile, const char* group)
103 result = g_key_file_get_keys(keyfile, group, &length,NULL);
105 for (i = 0; i < (int)length; i++) {
106 int id = ico_uxf_conf_getUint(result[i]);
108 list=g_list_append(list,g_strdup(result[i]));
115 /*--------------------------------------------------------------------------*/
117 * @brief ico_uxf_conf_appendStr: connect strings
119 * @param[in] str1 string 1
120 * @param[in] str2 string 2
121 * @return static connected string (str1+str2)
123 /*--------------------------------------------------------------------------*/
125 ico_uxf_conf_appendStr(const char* str1, const char* str2)
127 static char buf[256];
128 sprintf(buf, "%s%s", str1, str2);
132 /*--------------------------------------------------------------------------*/
134 * @brief ico_uxf_conf_checkGerror: output configuration error message
136 * @param[in] error error information
139 /*--------------------------------------------------------------------------*/
141 ico_uxf_conf_checkGerror(GError** error)
143 if (*error != NULL) {
144 uifw_warn("%s",(*error)->message);
146 g_clear_error(error);