tizen 2.0beta
[apps/native/ug-wifi-direct.git] / ugapp-wifidirect / include / wfd-ugapp-util.h
1 /*
2 *  WiFi-Direct UG
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 /**
21  * This file declares wifi direct application util functions.
22  *
23  * @file    wfd-app-util.h
24  * @author  Sungsik Jang (sungsik.jang@samsung.com)
25  * @version 0.1
26  */
27
28
29 #ifndef __WFD_APP_UTIL_H__
30 #define __WFD_APP_UTIL_H__
31
32
33 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
34 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
35
36 #ifdef VITA_FEATURE
37 #include <dlog.h>
38
39 #define WIFI_DIRECT_APP_MID             "wfd-ugapp"
40
41 #define WFD_APP_LOG_LOW         LOG_VERBOSE
42 #define WFD_APP_LOG_HIGH        LOG_INFO
43 #define WFD_APP_LOG_ERROR       LOG_ERROR
44 #define WFD_APP_LOG_WARN        LOG_WARN
45 #define WFD_APP_LOG_ASSERT      LOG_FATAL
46 #define WFD_APP_LOG_EXCEPTION   LOG_FATAL
47 #define WFD_MAX_SIZE            128
48 #define WFD_MAC_ADDRESS_SIZE    18
49
50 char * wfd_app_trim_path(const char* filewithpath);
51 int wfd_app_gettid();
52
53 #define WFD_APP_LOG(log_level, format, args...) \
54         LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),##args)
55 #define __WFD_APP_FUNC_ENTER__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
56 #define __WFD_APP_FUNC_EXIT__   LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
57
58 #else /** _DLOG_UTIL */
59
60 #define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(), ##args)
61 #define __WFD_APP_FUNC_ENTER__  printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
62 #define __WFD_APP_FUNC_EXIT__   printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
63
64 #endif /** _USE_DLOG_UTIL */
65
66
67
68 #define assertm_if(expr, fmt, arg...) do { \
69    if(expr) { \
70           WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
71                  exit(1); \
72    } \
73 } while (0)                     // retvm if
74
75
76
77 #endif /* __WFD_APP_UTIL_H__ */