Apply tizen coding rule
[platform/framework/web/download-provider.git] / agent / include / download-agent-type.h
1 /*
2  * Copyright (c) 2012 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 #ifndef _DOWNLOAD_AGENT_TYPE_H
18 #define _DOWNLOAD_AGENT_TYPE_H
19
20 #include "linux/limits.h"
21 #include "download-agent-defs.h"
22 #include <tzplatform_config.h>
23
24 typedef int     da_ret_t;
25 typedef int     da_bool_t;
26 typedef unsigned long long da_size_t;
27
28 #define IS_NOT_VALID_ID(x)  (x <= DA_INVALID_ID)
29
30 #define DA_MAX_URI_LEN                  1024
31 #define DA_MAX_FULL_PATH_LEN    PATH_MAX - 1 /* 4096 -1 chars in a path name excluding NULL */
32 #define DA_MAX_FILE_NAME_LEN    NAME_MAX /* 255 chars in a file name excluding NULL */
33 #define DA_MAX_STR_LEN                  256
34 #define DA_MAX_MIME_STR_LEN             256
35 #define DA_MAX_PROXY_ADDR_LEN   64              // e.g. 100.200.300.400:10000
36
37 #define SCHEME_HTTP             "http://"
38
39 #define DA_DEFAULT_INSTALL_PATH_FOR_PHONE tzplatform_getenv(TZ_USER_DOWNLOADS)
40 // #define DA_DEFAULT_INSTALL_PATH_FOR_PHONE "/home/owner/content/Downloads"
41
42 #define DA_MAX_ID       DA_MAX_DOWNLOAD_REQ_AT_ONCE
43
44 #define SAVE_FILE_BUFFERING_SIZE_50KB (50*1024)
45
46 #define NULL_CHECK(DATA) {\
47         if (!DATA) {\
48                 DA_LOGE("NULL CHECK!:%s", (#DATA));\
49                 return;\
50         } \
51 }
52
53 #define NULL_CHECK_RET(DATA) {\
54         if (!DATA) {\
55                 DA_LOGE("NULL CHECK!:%s", (#DATA));\
56                 return DA_ERR_INVALID_ARGUMENT;\
57         } \
58 }
59
60 #define NULL_CHECK_GOTO(DATA) {\
61         if (!DATA) {\
62                 DA_LOGE("NULL CHECK!:%s", (#DATA));\
63                 ret = DA_ERR_INVALID_ARGUMENT;\
64                 goto ERR;\
65         } \
66 }
67
68 #define NULL_CHECK_RET_OPT(DATA, RET_DATA) {\
69         if (!DATA) {\
70                 DA_LOGE("NULL CHECK!:%s", (#DATA));\
71                 return RET_DATA;\
72         } \
73 }
74
75 #define NULL_CHECK_AND_FREE(DATA) {\
76         if (DATA) {\
77                 free(DATA);\
78                 DATA = DA_NULL;\
79         } \
80 }
81 #endif
82