void util_runtime_info_unset_changed_cb(runtime_info_key_e key, runtime_info_changed_cb cb);
/**
+ * @brief Copy src string to dest and null-termianates dest string.
+ *
+ * @param dest destination string
+ * @param src source string
+ * @param dest_size size of dest buffer
+ *
+ * @return number of chars copied to dest buffer or value <= 0 if no characters
+ * has been copied.
+ */
+int util_strlcpy(char *dest, const char *src, size_t dest_size);
+
+/**
* @}
*/
#define ICON_PRIORITY INDICATOR_PRIORITY_FIXED8
#define MODULE_NAME "clock"
-static void indicator_get_apm_by_region(char* output, void* data);
-static void indicator_get_time_by_region(char* output, void* data);
+static void indicator_get_apm_by_region(char* output, size_t output_size);
+static void indicator_get_time_by_region(char* output, size_t output_size);
#ifdef _SUPPORT_SCREEN_READER
static void ICU_set_timezone(const char *timezone);
_E("Fail to add timer !");
}
- indicator_get_apm_by_region(icu_apm,data);
- indicator_get_time_by_region(time_buf,data);
+ indicator_get_apm_by_region(icu_apm, CLOCK_STR_LEN);
+ indicator_get_time_by_region(time_buf, CLOCK_STR_LEN);
if (clock_mode == INDICATOR_CLOCK_MODE_12H) {
return result;
}
-
-
-void indicator_get_apm_by_region(char* output,void *data)
+void indicator_get_apm_by_region(char* output, size_t output_size)
{
int ret = -1;
char *locale = NULL;
- retm_if(data == NULL, "Data parameter is NULL");
retm_if(output == NULL, "output parameter is NULL");
i18n_uchar u_custom_skeleton[CLOCK_STR_LEN] = { 0, };
i18n_ustring_copy_au(s_formatted, u_formatted);
apm_length = i18n_ustring_get_length(u_formatted);
- if (strlen(s_formatted) < CLOCK_STR_LEN) {
- strncpy(output, s_formatted, strlen(s_formatted));
- }
- else {
- strncpy(output, s_formatted, CLOCK_STR_LEN - 1);
- }
+ util_strlcpy(output, s_formatted, output_size);
return;
}
-void indicator_get_time_by_region(char* output,void *data)
+void indicator_get_time_by_region(char* output, size_t output_size)
{
int ret = -1;
char *locale;
- retm_if(data == NULL, "Data parameter is NULL");
retm_if(output == NULL, "output parameter is NULL");
i18n_uchar u_custom_skeleton[CLOCK_STR_LEN] = { 0, };
return;
}
- if (strlen(s_convert_formatted) < CLOCK_STR_LEN) {
- strncpy(output, s_convert_formatted, strlen(s_convert_formatted));
- }
- else {
- strncpy(output, s_convert_formatted, CLOCK_STR_LEN - 1);
- }
+ util_strlcpy(output, s_convert_formatted, output_size);
free(s_convert_formatted);