Change strncpy to g_strlcpy
[platform/core/multimedia/libmedia-thumbnail.git] / src / include / util / media-thumb-util.h
1 /*
2  * libmedia-thumbnail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include "media-util.h"
23 #include <tzplatform_config.h>
24
25 #ifndef _MEDIA_THUMB_UTIL_H_
26 #define _MEDIA_THUMB_UTIL_H_
27
28 #define SAFE_FREE(src)      { if (src) {free(src); src = NULL; } }
29 #define THUMB_MALLOC(src, size) { if (size <= 0) {src = NULL; } \
30                                                         else { src = malloc(size); if (src) memset(src, 0x0, size); } }
31 #define SAFE_STRLCPY(dst, src, n)      g_strlcpy(dst, src, n);
32
33 typedef enum {
34         MEDIA_THUMB_BGRA,                       /* BGRA, especially provided for evas users */
35         MEDIA_THUMB_RGB888,                     /* RGB888 */
36 } media_thumb_format;
37
38 #define THUMB_NONE_TYPE    -1   /* None */
39 #define THUMB_IMAGE_TYPE   0    /* Image */
40 #define THUMB_VIDEO_TYPE   1    /* Video */
41
42 #define THUMB_PATH_PHONE                MEDIA_ROOT_PATH_INTERNAL                /**< File path prefix of files stored in phone */
43 #define THUMB_PATH_MMC          MEDIA_ROOT_PATH_SDCARD          /**< File path prefix of files stored in mmc card */
44
45 #define THUMB_PHONE_PATH        tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone")
46 #define THUMB_MMC_PATH          tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc")
47
48 #define THUMB_DEFAULT_PATH      tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png")
49
50 typedef enum {
51         THUMB_PHONE,                    /**< Stored only in phone */
52         THUMB_MMC                               /**< Stored only in MMC */
53 } media_thumb_store_type;
54
55 int _media_thumb_get_store_type_by_path(const char *full_path);
56
57 int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
58
59 int _media_thumb_get_file_type(const char *file_full_path);
60
61 char* _media_thumb_generate_hash_name(const char *file);
62
63 int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
64
65 int _media_thumb_remove_file(const char *path);
66
67 #endif /*_MEDIA_THUMB_UTIL_H_*/
68