Remove __media_svc_malloc_and_strncpy 18/140518/3
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 25 Jul 2017 08:09:19 +0000 (17:09 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 25 Jul 2017 08:22:09 +0000 (17:22 +0900)
Use g_strdup instead of __media_svc_malloc_and_strncpy

Change-Id: Id4c31b18c9e7ff096b05d32d1f882ca2cef12c7b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc-album.c
src/common/media-svc-media.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-util.h

index 1c6cd44..74c57da 100755 (executable)
@@ -77,13 +77,8 @@ int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **a
        }
 
        value = (char *)sqlite3_column_text(sql_stmt, 0);
-
        if (STRING_VALID(value)) {
-               ret = __media_svc_malloc_and_strncpy(album_art, value);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       SQLITE3_FINALIZE(sql_stmt);
-                       return ret;
-               }
+               *album_art = g_strdup(value);
        } else {
                *album_art = NULL;
        }
index 08d95f5..11f9181 100755 (executable)
@@ -208,11 +208,8 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
 
                ret = _media_svc_request_thumbnail(content_info->path, thumb_path, sizeof(thumb_path), uid);
-               if (ret == MS_MEDIA_ERR_NONE) {
-                       ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               content_info->thumbnail_path = NULL;
-               }
+               if (ret == MS_MEDIA_ERR_NONE)
+                       content_info->thumbnail_path = g_strdup(thumb_path);
        }
 
        /*Update Pinyin If Support Pinyin*/
index 58574a6..b23983f 100755 (executable)
@@ -178,32 +178,6 @@ void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
        x_dst[max_len - 1] = '\0';
 }
 
-int __media_svc_malloc_and_strncpy(char **dst, const char *src)
-{
-       int len = 0;
-
-       if (!STRING_VALID(src)) {
-               media_svc_error("invalid src");
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       SAFE_FREE(*dst);
-
-       len = strlen(src) + 1;
-       *dst = malloc(len);
-
-       if (*dst == NULL) {
-               media_svc_error("malloc failed");
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       strncpy(*dst, src, len);
-       char *p = *dst;
-       p[len - 1] = '\0';
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 static int __media_svc_split_to_double(char *input, double *arr)
 {
        char tmp_arr[255] = {0, };
@@ -1047,8 +1021,6 @@ int _media_svc_get_file_time(const char *full_path)
 
 int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh)
 {
-       int ret = MS_MEDIA_ERR_NONE;
-
        /* Set default GPS value before extracting meta information */
        content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
        content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
@@ -1058,10 +1030,9 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re
        char *title = NULL;
        title = __media_svc_get_title_from_filepath(content_info->path);
        if (title) {
-               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy error");
+               content_info->media_meta.title = g_strdup(title);
                SAFE_FREE(title);
+               media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
        } else {
                media_svc_error("Can't extract title");
                content_info->media_meta.title = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
@@ -1119,8 +1090,8 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        bool drm_type = false;
        char mime_type[256] = {0, };
 
-       ret = __media_svc_malloc_and_strncpy(&content_info->path, path);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+       content_info->path = g_strdup(path);
+       media_svc_retv_del_if(content_info->path == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        struct stat st;
        memset(&st, 0, sizeof(struct stat));
@@ -1140,8 +1111,8 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
                return MS_MEDIA_ERR_NONE;
        }
 
-       ret = __media_svc_malloc_and_strncpy(&content_info->storage_uuid, storage_id);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+       content_info->storage_uuid = g_strdup(storage_id);
+       media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        content_info->storage_type = storage_type;
        time(&content_info->added_time);
@@ -1152,13 +1123,13 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
                return MS_MEDIA_ERR_INTERNAL;
        }
 
-       ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+       content_info->media_uuid = g_strdup(media_uuid);
+       media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        file_name = g_path_get_basename(path);
-       ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name);
+       content_info->file_name = g_strdup(file_name);
        SAFE_FREE(file_name);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+       media_svc_retv_del_if(content_info->file_name == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        /* if the file is DRM file, drm_type value is DRM_TRUE(1).
        if drm_contentinfo is not NULL, the file is OMA DRM.*/
@@ -1175,8 +1146,8 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+       content_info->mime_type = g_strdup(mime_type);
+       media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
 
@@ -1288,7 +1259,6 @@ ERROR:
 
 int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info)
 {
-       int ret = MS_MEDIA_ERR_NONE;
        double value = 0.0;
        int orient_value = 0;
        int exif_width = 0;
@@ -1357,28 +1327,18 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
        memset(buf, 0x00, sizeof(buf));
 
        if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) == 0) {
-                       /*media_svc_debug("Use 'No description'"); */
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-               } else {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, buf);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-               }
+               if (strlen(buf) == 0)
+                       content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+               else
+                       content_info->media_meta.description = g_strdup(buf);
        } else {
-               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy error");
+               content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
        }
 
        memset(buf, 0x00, sizeof(buf));
 
        if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) == 0) {
-                       /*media_svc_debug("time is NULL"); */
-               } else {
+               if (strlen(buf) > 0) {
                        has_datetaken = TRUE;
                        content_info->media_meta.datetaken = g_strdup(buf);
 
@@ -1390,9 +1350,7 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
        memset(buf, 0x00, sizeof(buf));
 
        if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) == 0) {
-                       /*media_svc_debug("time is NULL"); */
-               } else {
+               if (strlen(buf) > 0) {
                        has_datetaken = TRUE;
                        content_info->media_meta.datetaken = g_strdup(buf);
 
@@ -1413,13 +1371,8 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
 
        /* Get exposure_time value from exif. */
        if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) == 0) {
-                       /* media_svc_debug("exposure_time_buf is NULL"); */
-               } else {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.exposure_time, buf);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-               }
+               if (strlen(buf) > 0)
+                       content_info->media_meta.exposure_time = g_strdup(buf);
        }
 
        /* Get fnumber value from exif. */
@@ -1446,13 +1399,8 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
 
        /* Get model value from exif. */
        if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
-               if (strlen(buf) == 0) {
-                       /* media_svc_debug("model_buf is NULL"); */
-               } else {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.model, buf);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-               }
+               if (strlen(buf) > 0)
+                       content_info->media_meta.model = g_strdup(buf);
        }
 
        /* Get orientation value from exif. */
@@ -1489,15 +1437,13 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s
 
 GET_WIDTH_HEIGHT:
 
-       if (content_info->media_meta.width == 0 ||
-               content_info->media_meta.height == 0) {
+       if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) {
                /*Get image width, height*/
                unsigned int img_width = 0;
                unsigned int img_height = 0;
                ImgCodecType img_type = IMG_CODEC_NONE;
 
-               ret = ImgGetImageInfo(path, &img_type, &img_width, &img_height);
-
+               ImgGetImageInfo(path, &img_type, &img_width, &img_height);
                if (content_info->media_meta.width == 0)
                        content_info->media_meta.width = img_width;
 
@@ -1517,7 +1463,6 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont
        int mmf_error = FILEINFO_ERROR_NONE;
        char *err_attr_name = NULL;
        int album_id = 0;
-       int ret = MS_MEDIA_ERR_NONE;
 
        /*Get Content Tag attribute ===========*/
        mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
@@ -1525,45 +1470,29 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont
        if (mmf_error == FILEINFO_ERROR_NONE) {
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-
-                       /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */
+                       content_info->media_meta.album = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("album - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */
+                       content_info->media_meta.artist = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("artist - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */
+                       content_info->media_meta.album_artist = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("album_artist - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
+                       content_info->media_meta.genre = g_strdup(p);
 
-                       /*media_svc_debug("genre : %s", content_info->media_meta.genre); */
                        /* If genre is Ringtone, it's categorized as sound. But this logic is commented */
                        /*
                        if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
@@ -1572,15 +1501,12 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont
                        */
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("genre - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
-               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
                        if (!isspace(*p)) {
-                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
-                               if (ret != MS_MEDIA_ERR_NONE)
-                                       media_svc_error("strcpy error");
+                               content_info->media_meta.title = g_strdup(p);
 
                                extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
                        } else {
@@ -1593,9 +1519,7 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont
                                                continue;
                                        } else {
                                                media_svc_debug("Not SPACE [%s]", p);
-                                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
-                                               if (ret != MS_MEDIA_ERR_NONE)
-                                                       media_svc_error("strcpy error");
+                                               content_info->media_meta.title = g_strdup(p);
                                                break;
                                        }
                                }
@@ -1604,35 +1528,24 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("desc : %s", content_info->media_meta.description); */
+                       content_info->media_meta.description = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
+                       content_info->media_meta.composer = g_strdup(p);
                        extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
-                       /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */
                } else {
-                       /*media_svc_debug("composer - unknown"); */
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
-                       /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */
+                       content_info->media_meta.copyright = g_strdup(p);
+                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
                } else {
-                       /*media_svc_debug("copyright - unknown"); */
                        SAFE_FREE(err_attr_name);
                }
 
@@ -1670,45 +1583,29 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
        if (mmf_error == FILEINFO_ERROR_NONE) {
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-
-                       /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */
+                       content_info->media_meta.album = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("album - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */
+                       content_info->media_meta.artist = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("artist - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */
+                       content_info->media_meta.album_artist = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("album_artist - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
+                       content_info->media_meta.genre = g_strdup(p);
 
-                       /*media_svc_debug("genre : %s", content_info->media_meta.genre); */
                        /* If genre is Ringtone, it's categorized as sound. But this logic is commented */
                        /*
                        if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
@@ -1717,16 +1614,12 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                        */
                } else {
                        SAFE_FREE(err_attr_name);
-                       /*media_svc_debug("genre - unknown"); */
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
-               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
+               if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
                        if (!isspace(*p)) {
-                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
-                               if (ret != MS_MEDIA_ERR_NONE)
-                                       media_svc_error("strcpy error");
-
+                               content_info->media_meta.title = g_strdup(p);
                                extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
                        } else {
                                int idx = 0;
@@ -1738,9 +1631,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                                                continue;
                                        } else {
                                                media_svc_debug("Not SPACE [%s]", p);
-                                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
-                                               if (ret != MS_MEDIA_ERR_NONE)
-                                                       media_svc_error("strcpy error");
+                                               content_info->media_meta.title = g_strdup(p);
                                                break;
                                        }
                                }
@@ -1749,16 +1640,12 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       /*media_svc_debug("desc : %s", content_info->media_meta.description); */
+                       content_info->media_meta.description = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
-
                if (mmf_error != FILEINFO_ERROR_NONE)
                        SAFE_FREE(err_attr_name);
 
@@ -1779,19 +1666,17 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                                                p_value++;
                                        }
                                        *time_value = '\0';
-                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, time_info);
+                                       content_info->media_meta.recorded_date = g_strdup(time_info);
                                        SAFE_FREE(time_info);
                                } else {
                                        media_svc_error("memory allocation error");
                                        ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
                                }
                        } else {
-                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p);
+                               content_info->media_meta.recorded_date = g_strdup(p);
                        }
 
-                       if (ret != MS_MEDIA_ERR_NONE) {
-                               media_svc_error("strcpy error");
-                       } else {
+                       if (STRING_VALID(content_info->media_meta.recorded_date)) {
                                /* This is same as datetaken */
                                content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
 
@@ -1801,40 +1686,29 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                                else
                                        media_svc_debug("Timeline : %ld", content_info->timeline);
                        }
-                       /*media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date); */
                } else {
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
+                       content_info->media_meta.composer = g_strdup(p);
                        extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
-                       /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */
                } else {
-                       /*media_svc_debug("composer - unknown"); */
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
-                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
-                       /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */
+                       content_info->media_meta.copyright = g_strdup(p);
+                       extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
                } else {
-                       /*media_svc_debug("copyright - unknown"); */
                        SAFE_FREE(err_attr_name);
                }
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, p);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy error");
+                       content_info->media_meta.track_num = g_strdup(p);
                } else {
                        SAFE_FREE(err_attr_name);
                }
@@ -1843,9 +1717,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_YEAR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size == 4)) {
                        int year = 0;
                        if ((p != NULL) && ((ret != __media_svc_safe_atoi(p, &year)) == MS_MEDIA_ERR_NONE)) {
-                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p);
-                               if (ret != MS_MEDIA_ERR_NONE)
-                                       media_svc_error("strcpy error");
+                               content_info->media_meta.year = g_strdup(p);
                        } else {
                                media_svc_debug("Wrong Year Information [%s]", p);
                        }
@@ -1855,7 +1727,9 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
 
                mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RATING, &p, &size, NULL);
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
-                       content_info->media_meta.rating = atoi(p);
+                       int rate = 0;
+                       if (__media_svc_safe_atoi(p, &rate) == MS_MEDIA_ERR_NONE)
+                               content_info->media_meta.rating = rate;
                } else {
                        SAFE_FREE(err_attr_name);
                        content_info->media_meta.rating = 0;
@@ -1929,9 +1803,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                media_svc_error("Fail to Save Thumbnail Image");
                                        } else {
-                                               ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
-                                               if (ret != MS_MEDIA_ERR_NONE)
-                                                       media_svc_error("strcpy error");
+                                               content_info->thumbnail_path = g_strdup(thumb_path);
                                        }
                                }
                        }
index b62909c..509f714 100755 (executable)
@@ -368,8 +368,8 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m
        ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
-       ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+       content_info.folder_uuid = g_strdup(folder_uuid);
+       media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
 
        if (g_media_svc_insert_item_data_cnt == 1) {
 
@@ -459,8 +459,8 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
-       ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+       content_info.folder_uuid = g_strdup(folder_uuid);
+       media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
 
        /* Extracting thumbnail */
        if (content_info.thumbnail_path == NULL) {
@@ -469,7 +469,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
 
                        ret = _media_svc_request_thumbnail(content_info.path, thumb_path, sizeof(thumb_path), uid);
                        if (ret == MS_MEDIA_ERR_NONE)
-                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                               content_info.thumbnail_path = g_strdup(thumb_path);
                }
        }
 
@@ -927,7 +927,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
 
                        ret = _media_svc_request_thumbnail(content_info.path, thumb_path, sizeof(thumb_path), uid);
                        if (ret == MS_MEDIA_ERR_NONE)
-                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                               content_info.thumbnail_path = g_strdup(thumb_path);
                }
        }
 
@@ -1413,8 +1413,6 @@ int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, cha
 
 static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_info, media_svc_content_info_s *new_content_info)
 {
-       int ret = MS_MEDIA_ERR_NONE;
-
        media_svc_retvm_if(content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(new_content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
 
@@ -1424,124 +1422,28 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in
        new_content_info->played_count = content_info->played_count;
        new_content_info->favourate = content_info->favourate;
 
-       if (STRING_VALID(content_info->file_name)) {
-                       ret = __media_svc_malloc_and_strncpy(&new_content_info->file_name, content_info->file_name);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("strcpy file_name failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.title)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.title, content_info->media_meta.title);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy title failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.album)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album, content_info->media_meta.album);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy album failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.artist)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.artist, content_info->media_meta.artist);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy artist failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.genre)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.genre, content_info->media_meta.genre);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy genre failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.composer)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.composer, content_info->media_meta.composer);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy composer failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.year)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.year, content_info->media_meta.year);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy year failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.recorded_date)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.recorded_date, content_info->media_meta.recorded_date);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy recorded_date failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.copyright)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.copyright, content_info->media_meta.copyright);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy copyright failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.track_num)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.track_num, content_info->media_meta.track_num);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy track_num failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.description)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.description, content_info->media_meta.description);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy description failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.weather)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.weather, content_info->media_meta.weather);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy weather failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.category)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.category, content_info->media_meta.category);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy category failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.keyword)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.keyword, content_info->media_meta.keyword);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy keyword failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.location_tag)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.location_tag, content_info->media_meta.location_tag);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy location_tag failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.content_name)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.content_name, content_info->media_meta.content_name);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy content_name failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.age_rating)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.age_rating, content_info->media_meta.age_rating);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy age_rating failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.author)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.author, content_info->media_meta.author);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy author failed");
-       }
-
-       if (STRING_VALID(content_info->media_meta.provider)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.provider, content_info->media_meta.provider);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy provider failed");
-       }
+       new_content_info->file_name = g_strdup(content_info->file_name);
+       new_content_info->media_meta.title = g_strdup(content_info->media_meta.title);
+       new_content_info->media_meta.album = g_strdup(content_info->media_meta.album);
+       new_content_info->media_meta.artist = g_strdup(content_info->media_meta.artist);
+       new_content_info->media_meta.genre = g_strdup(content_info->media_meta.genre);
+       new_content_info->media_meta.composer = g_strdup(content_info->media_meta.composer);
+       new_content_info->media_meta.year = g_strdup(content_info->media_meta.year);
+       new_content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.recorded_date);
+       new_content_info->media_meta.copyright = g_strdup(content_info->media_meta.copyright);
+       new_content_info->media_meta.track_num = g_strdup(content_info->media_meta.track_num);
+       new_content_info->media_meta.description = g_strdup(content_info->media_meta.description);
+       new_content_info->media_meta.weather = g_strdup(content_info->media_meta.weather);
+       new_content_info->media_meta.category = g_strdup(content_info->media_meta.category);
+       new_content_info->media_meta.keyword = g_strdup(content_info->media_meta.keyword);
+       new_content_info->media_meta.location_tag = g_strdup(content_info->media_meta.location_tag);
+       new_content_info->media_meta.content_name = g_strdup(content_info->media_meta.content_name);
+       new_content_info->media_meta.age_rating = g_strdup(content_info->media_meta.age_rating);
+       new_content_info->media_meta.author = g_strdup(content_info->media_meta.author);
+       new_content_info->media_meta.provider = g_strdup(content_info->media_meta.provider);
 
        if (STRING_VALID(content_info->media_meta.datetaken)) {
-               ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.datetaken, content_info->media_meta.datetaken);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("strcpy datetaken failed");
+               new_content_info->media_meta.datetaken = g_strdup(content_info->media_meta.datetaken);
 
                new_content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
                if (new_content_info->timeline == 0) {
@@ -1567,7 +1469,7 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in
 
        new_content_info->media_meta.rating = content_info->media_meta.rating;
 
-       return 0;
+       return MS_MEDIA_ERR_NONE;
 }
 
 int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_svc_content_info_s *content_info, uid_t uid)
@@ -1608,7 +1510,7 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv
 
                        ret = _media_svc_request_thumbnail(_new_content_info.path, thumb_path, sizeof(thumb_path), uid);
                        if (ret == MS_MEDIA_ERR_NONE)
-                               ret = __media_svc_malloc_and_strncpy(&(_new_content_info.thumbnail_path), thumb_path);
+                               _new_content_info.thumbnail_path = g_strdup(thumb_path);
                }
        }
 
@@ -1617,11 +1519,11 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv
 
        /* Set or Get folder id */
        ret = _media_svc_get_and_append_folder_id_by_path(handle, _new_content_info.storage_uuid, _new_content_info.path, _new_content_info.storage_type, folder_uuid, uid);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       ret = __media_svc_malloc_and_strncpy(&_new_content_info.folder_uuid, folder_uuid);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &_new_content_info);
 
+       _new_content_info.folder_uuid = g_strdup(folder_uuid);
+       media_svc_retv_del_if(_new_content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &_new_content_info);
+
        /* register album table data */
 
        int album_id = 0;
@@ -1893,8 +1795,8 @@ int media_svc_insert_item_pass1(MediaSvcHandle *handle, const char *storage_id,
        ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
 
-       ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
-       media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+       content_info.folder_uuid = g_strdup(folder_uuid);
+       media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
 
        if (g_media_svc_insert_item_data_cnt == 1) {
 
@@ -2038,7 +1940,7 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id,
                media_type = db_data->media_type;
                /* media_svc_debug("path is %s, media type %d", db_data->path, media_type); */
                memset(&content_info, 0, sizeof(media_svc_content_info_s));
-               __media_svc_malloc_and_strncpy(&content_info.path, db_data->path);
+               content_info.path = g_strdup(db_data->path);
 
                content_info.media_type = media_type;
                content_info.storage_type = storage_type;
index 68def00..8924b01 100755 (executable)
@@ -61,7 +61,6 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
                const char *path, media_svc_media_type_e *media_type, bool refresh);
 int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info);
 int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid);
-int __media_svc_malloc_and_strncpy(char **dst, const char *src);
 time_t __media_svc_get_timeline_from_str(const char *timstr);
 void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
 char *_media_svc_replace_path(char *s, const char *olds, const char *news);