From: Youngjae Shin Date: Wed, 10 Jun 2015 06:27:12 +0000 (+0900) Subject: apply coding style X-Git-Tag: submit/tizen/20150610.115312^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F40874%2F2;p=platform%2Fcore%2Ftelephony%2Fphonenumber-utils.git apply coding style Change-Id: I7f0dbe61916ef3f04e6f2b7bf3bfca242689865d --- diff --git a/doc/phnumber_doc.h b/doc/phnumber_doc.h index 3670c62..7ea5ba5 100644 --- a/doc/phnumber_doc.h +++ b/doc/phnumber_doc.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__ #define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__ @@ -33,4 +32,4 @@ * The phonenumber utils API provides methods for parsing and formatting phone numbers. */ -#endif // __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__ +#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__ */ diff --git a/include/phone_number.h b/include/phone_number.h index f90f678..e2edfb5 100644 --- a/include/phone_number.h +++ b/include/phone_number.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__ #define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__ @@ -53,16 +52,17 @@ extern "C" * @return @c 0 on success, * otherwise a negative error value * - * @retval #PHONE_NUMBER_ERROR_NONE Successful - * @retval #PHONE_NUMBER_ERROR_OUT_OF_MEMORY Out of memory - * @retval #PHONE_NUMBER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE FS Full - * @retval #PHONE_NUMBER_ERROR_PERMISSION_DENIED Permission denied - * @retval #PHONE_NUMBER_ERROR_NOT_SUPPORTED Not supported - * @retval #PHONE_NUMBER_ERROR_NO_DATA Requested data does not exist + * @retval #PHONE_NUMBER_ERROR_NONE Successful + * @retval #PHONE_NUMBER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #PHONE_NUMBER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE FS Full + * @retval #PHONE_NUMBER_ERROR_PERMISSION_DENIED Permission denied + * @retval #PHONE_NUMBER_ERROR_NOT_SUPPORTED Not supported + * @retval #PHONE_NUMBER_ERROR_NO_DATA Requested data does not exist * */ -int phone_number_get_location_from_number(const char *number, phone_number_region_e region, phone_number_lang_e language, char **location); +int phone_number_get_location_from_number(const char *number, + phone_number_region_e region, phone_number_lang_e language, char **location); /** * @brief This function gets the formatted number. @@ -78,16 +78,17 @@ int phone_number_get_location_from_number(const char *number, phone_number_regio * @return @c 0 on success, * otherwise a negative error value * - * @retval #PHONE_NUMBER_ERROR_NONE Successful - * @retval #PHONE_NUMBER_ERROR_OUT_OF_MEMORY Out of memory - * @retval #PHONE_NUMBER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE FS Full - * @retval #PHONE_NUMBER_ERROR_PERMISSION_DENIED Permission denied - * @retval #PHONE_NUMBER_ERROR_NOT_SUPPORTED Not supported - * @retval #PHONE_NUMBER_ERROR_NO_DATA Requested data does not exist + * @retval #PHONE_NUMBER_ERROR_NONE Successful + * @retval #PHONE_NUMBER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #PHONE_NUMBER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE FS Full + * @retval #PHONE_NUMBER_ERROR_PERMISSION_DENIED Permission denied + * @retval #PHONE_NUMBER_ERROR_NOT_SUPPORTED Not supported + * @retval #PHONE_NUMBER_ERROR_NO_DATA Requested data does not exist * */ -int phone_number_get_formatted_number(const char *number, phone_number_region_e region, char **formatted_number); +int phone_number_get_formatted_number(const char *number, phone_number_region_e region, + char **formatted_number); /** * @} @@ -97,4 +98,4 @@ int phone_number_get_formatted_number(const char *number, phone_number_region_e } #endif -#endif // __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__ \ No newline at end of file +#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__ */ diff --git a/include/phone_number_errors.h b/include/phone_number_errors.h index 1c85224..419b139 100644 --- a/include/phone_number_errors.h +++ b/include/phone_number_errors.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__ #define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__ @@ -38,8 +37,7 @@ * @since_tizen 2.4 * */ -typedef enum -{ +typedef enum { /* GENERAL */ PHONE_NUMBER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ PHONE_NUMBER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O Error */ @@ -56,4 +54,4 @@ typedef enum * @} */ -#endif // __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__ \ No newline at end of file +#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__ */ diff --git a/include/phone_number_types.h b/include/phone_number_types.h index fae9ba9..3a7a01a 100644 --- a/include/phone_number_types.h +++ b/include/phone_number_types.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__ #define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__ @@ -69,7 +68,7 @@ typedef enum { PHONE_NUMBER_LANG_TURKISH, /**< Turkish */ PHONE_NUMBER_LANG_VIETNAMESE, /**< Vietnamese */ PHONE_NUMBER_LANG_MAX, -}phone_number_lang_e; +} phone_number_lang_e; /** * @brief Enumeration for region type. @@ -211,11 +210,11 @@ typedef enum { PHONE_NUMBER_REGION_ZAMBIA, /**< Zambia */ PHONE_NUMBER_REGION_ZIMBABWE, /**< Zimbabwe */ PHONE_NUMBER_REGION_MAX, -}phone_number_region_e; +} phone_number_region_e; /** * @} */ -#endif // __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__ +#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__ */ diff --git a/src/phn_common.h b/src/phn_common.h index 3d8428e..10d0b6c 100644 --- a/src/phn_common.h +++ b/src/phn_common.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __PHN_COMMON_H__ #define __PHN_COMMON_H__ @@ -32,7 +31,7 @@ #endif #define DLOG(prio, fmt, arg...) \ - do { SLOG(prio, LOG_TAG, fmt, ##arg); } while(0); + do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0); #define INFO(fmt, arg...) SLOGI(fmt, ##arg) #define WARN(fmt, arg...) SLOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg) #define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg) @@ -68,4 +67,4 @@ } \ } while (0) -#endif // __PHN_COMMON_H__ +#endif /* __PHN_COMMON_H__ */ diff --git a/src/phn_location.c b/src/phn_location.c index bdac93e..89f5ea3 100644 --- a/src/phn_location.c +++ b/src/phn_location.c @@ -16,7 +16,6 @@ * limitations under the License. * */ - #include #include #include @@ -61,19 +60,23 @@ struct phn_location_header { int phn_location_find_extra_data(const char *region_str, char **p_location_file) { - char *location_file = NULL; DIR *dirp = NULL; + struct dirent **dir_list; + char *location_file = NULL; + dirp = opendir(PHN_LOCATION_DIR); if (NULL == dirp) { ERR("opendir() return NULL"); return PHONE_NUMBER_ERROR_NO_DATA; } - struct dirent **dir_list; + int count = scandir(PHN_LOCATION_DIR, &dir_list, 0, alphasort); if (count) { int idx = 0; char location_prefix[PHN_STR_SHORT_LEN] = {0}; - snprintf(location_prefix, sizeof(location_prefix), "%s-%s", PHN_LOCATION_FILE_PREFIX, region_str); + + snprintf(location_prefix, sizeof(location_prefix), "%s-%s", + PHN_LOCATION_FILE_PREFIX, region_str); while (idx != count) { const char *file_name = dir_list[idx]->d_name; if (0 == strncmp(file_name, location_prefix, strlen(location_prefix))) { @@ -89,6 +92,7 @@ int phn_location_find_extra_data(const char *region_str, char **p_location_file) *p_location_file = location_file; return PHONE_NUMBER_ERROR_NONE; } + return PHONE_NUMBER_ERROR_NO_DATA; } @@ -96,16 +100,19 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb phone_number_region_e region, phone_number_lang_e lang, char **p_location) { int ret = 0; - gchar* province_temp = NULL; - gchar* city_temp = NULL; - int province_str_len = 0; int city_str_len = 0; - const gunichar2 *province_str = NULL; - const gunichar2 *city_str = NULL; + int province_str_len = 0; + size_t read_size; + gchar *city_temp = NULL; + gchar *province_temp = NULL; const char *real_number = number; + const gunichar2 *city_str = NULL; + const gunichar2 *province_str = NULL; + char file_path[PHN_STR_SHORT_LEN] = {0}; - // support region - CN, support lang - zh,en,ko - RETVM_IF(region != PHONE_NUMBER_REGION_CHINA, PHONE_NUMBER_ERROR_NOT_SUPPORTED, "Not supported region(%d)", region); + /* support region - CN, support lang - zh,en,ko */ + RETVM_IF(region != PHONE_NUMBER_REGION_CHINA, PHONE_NUMBER_ERROR_NOT_SUPPORTED, + "Not supported region(%d)", region); int lang_index = 0; switch (lang) { @@ -123,17 +130,17 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb return PHONE_NUMBER_ERROR_NOT_SUPPORTED; } - while (real_number && real_number[0] == '0') { + while (real_number && real_number[0] == '0') real_number++; - } - RETVM_IF(NULL == real_number, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "number=%s", number); + RETVM_IF(NULL == real_number, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "number=%s", + number); - char file_path[PHN_STR_SHORT_LEN] = {0}; snprintf(file_path, sizeof(file_path), "%s/%s", PHN_LOCATION_DIR, file); + int fd = open(file_path, O_RDONLY); RETVM_IF(fd < 0, PHONE_NUMBER_ERROR_NOT_SUPPORTED, "open() Fail(%d)", errno); - ret = lseek(fd, sizeof(int), SEEK_CUR); // start_mark + ret = lseek(fd, sizeof(int), SEEK_CUR); /* start_mark */ if (ret <= 0) { ERR("lseek() Fail(%d)", errno); close(fd); @@ -154,7 +161,7 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb gunichar2 name3[header.province_name_len[2]/2]; }; - #pragma pack(1) +#pragma pack(1) struct phn_telephone_city_info { gint8 province_index; gunichar2 city1[header.telephone_city_len[0]/2]; @@ -163,7 +170,7 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb gint16 prefix; }; - #pragma pack(1) +#pragma pack(1) struct phn_mobile_city_info { gint8 province_index; gunichar2 city1[header.mobile_city_len[0]/2]; @@ -172,7 +179,8 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb }; struct phn_province_info province_info[header.province_count]; - ret = read(fd, &province_info, sizeof(struct phn_province_info)*header.province_count); + ret = read(fd, &province_info, + sizeof(struct phn_province_info)*header.province_count); if (ret <= 0) { ERR("read() Fail(%d)", errno); close(fd); @@ -180,7 +188,8 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb } struct phn_telephone_city_info telephone_city_info[header.telephone_city_count]; - ret = read(fd, &telephone_city_info, sizeof(struct phn_telephone_city_info)*header.telephone_city_count); + ret = read(fd, &telephone_city_info, + sizeof(struct phn_telephone_city_info)*header.telephone_city_count); if (ret <= 0) { ERR("read() Fail(%d)", errno); close(fd); @@ -188,13 +197,14 @@ int phn_location_get_location_from_extra_data(const char *file, const char *numb } int i; - for (i=0;i #include #include diff --git a/src/phn_phonenumber_wrapper.h b/src/phn_phonenumber_wrapper.h index 7cfe6b7..275905c 100644 --- a/src/phn_phonenumber_wrapper.h +++ b/src/phn_phonenumber_wrapper.h @@ -16,7 +16,6 @@ * limitations under the License. * */ - #ifndef __PHN_PHONENUMBER_WRAPPER_H__ #define __PHN_PHONENUMBER_WRAPPER_H__ @@ -24,11 +23,13 @@ extern "C" { #endif -int phn_get_formatted_number(const char *number, const char *region, char **formatted_number); -int phn_get_location_from_number(const char *number, const char *region, const char *language, char **location); +int phn_get_formatted_number(const char *number, const char *region, + char **formatted_number); +int phn_get_location_from_number(const char *number, const char *region, + const char *language, char **location); #ifdef __cplusplus } #endif -#endif // __PHN_PHONENUMBER_WRAPPER_H__ \ No newline at end of file +#endif /* __PHN_PHONENUMBER_WRAPPER_H__ */ diff --git a/src/phn_region_data.c b/src/phn_region_data.c index f0bea2c..34fd94d 100644 --- a/src/phn_region_data.c +++ b/src/phn_region_data.c @@ -16,7 +16,6 @@ * limitations under the License. * */ - #include "phn_common.h" #include "phn_region_data.h" @@ -282,10 +281,10 @@ const struct phn_region_info phn_region_info_table[] = { const char* phn_region_data_get_region_str(phone_number_region_e region) { int i; - for (i=0;i