deacbadd43a131bce7c2c0bb246f3498e59204ab
[platform/core/api/thumbnail-util.git] / include / thumbnail_util_private.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18
19 #ifndef __TIZEN_THUMBNAIL_UTIL_PRIVATE_H__
20 #define __TIZEN_THUMBNAIL_UTIL_PRIVATE_H__
21
22
23 #include <unistd.h>
24 #include <asm/unistd.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <glib.h>
29 #include <thumbnail_util_type.h>
30 #include <dlog.h>
31 #include <tzplatform_config.h>
32
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37
38 #ifdef LOG_TAG
39 #undef LOG_TAG
40 #endif
41
42 #define LOG_TAG "CAPI_MEDIA_THUMBNAIL_UTIL"
43
44 #define SAFE_STRLCPY(dst, src, n)       ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
45 #define SAFE_STRLCAT(dst, src, n)       g_strlcat(dst, src, n);
46 #define SAFE_FREE(src)          {if(src) {free(src); src = NULL;}}
47 #define STRING_VALID(str)               ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
48
49 typedef struct {
50         int request_id;
51         char *file_path;
52         int dst_width;
53         int dst_height;
54         int thumb_size;
55         unsigned char *thumb_data;
56 }thumbnail_s;
57
58 typedef struct {
59         thumbnail_s *handle;
60         thumbnail_extracted_cb thumb_extract_cb;
61         void *user_data;
62 }thumbnail_extract_cb_s;
63
64 #define FONT_COLOR_RESET    "\033[0m"
65 #define FONT_COLOR_RED      "\033[31m"
66 #define FONT_COLOR_GREEN    "\033[32m"
67 #define FONT_COLOR_YELLOW   "\033[33m"
68 #define FONT_COLOR_BLUE     "\033[34m"
69 #define FONT_COLOR_PURPLE   "\033[35m"
70 #define FONT_COLOR_CYAN     "\033[36m"
71 #define FONT_COLOR_GRAY     "\033[37m"
72
73 #define thumbnail_util_gettid() syscall(__NR_gettid)
74
75 #define thumbnail_util_retv_if(expr, val) do { \
76                 if(expr) { \
77                         LOGE(FONT_COLOR_RED"[%d]", media_content_gettid());    \
78                         return (val); \
79                 } \
80         } while (0)
81
82 #define thumbnail_util_debug(fmt, arg...) do { \
83                 LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
84         } while (0)
85
86 #define thumbnail_util_info(fmt, arg...) do { \
87                 LOGI(FONT_COLOR_GREEN"[%d]"fmt"", thumbnail_util_gettid() ,##arg);     \
88         } while (0)
89
90 #define thumbnail_util_error(fmt, arg...) do { \
91                 LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
92         } while (0)
93
94 #define thumbnail_util_debug_func() do { \
95                 LOGD(FONT_COLOR_RESET"[%d]", thumbnail_util_gettid());     \
96         } while (0)
97
98 #define thumbnail_util_sec_debug(fmt, arg...) do { \
99                 SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
100         } while (0)
101
102 #define thumbnail_util_sec_warn(fmt, arg...) do { \
103                 SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
104         } while (0)
105
106 #define thumbnail_util_sec_error(fmt, arg...) do { \
107                 SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
108         } while (0)
109
110 #ifdef __cplusplus
111 }
112 #endif /* __cplusplus */
113 #endif /*__TIZEN_THUMBNAIL_UTIL_PRIVATE_H__*/