apply FSL(Flora Software License)
[apps/native/ug-wifi-direct.git] / popup-wifidirect / include / wfd-app-util.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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  * This file declares wifi direct application util functions.
19  *
20  * @file    wfd-app-util.h
21  * @author  Sungsik Jang (sungsik.jang@samsung.com)
22  * @version 0.1
23  */
24
25
26 #ifndef __WFD_APP_UTIL_H__
27 #define __WFD_APP_UTIL_H__
28
29
30 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
31 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
32
33 #ifdef VITA_FEATURE
34 #include <dlog.h>
35
36 #define WIFI_DIRECT_APP_MID             "wfd-app"
37
38 #define WFD_APP_LOG_LOW         LOG_VERBOSE
39 #define WFD_APP_LOG_HIGH        LOG_INFO
40 #define WFD_APP_LOG_ERROR       LOG_ERROR
41 #define WFD_APP_LOG_WARN        LOG_WARN
42 #define WFD_APP_LOG_ASSERT      LOG_FATAL
43 #define WFD_APP_LOG_EXCEPTION   LOG_FATAL
44
45 char *wfd_app_trim_path(const char *filewithpath);
46 int wfd_app_gettid();
47
48 #define WFD_APP_LOG(log_level, format, args...) \
49         LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),##args)
50 #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__)
51 #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__)
52
53 #else /** _DLOG_UTIL */
54
55 #define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(), ##args)
56 #define __WFD_APP_FUNC_ENTER__  printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
57 #define __WFD_APP_FUNC_EXIT__   printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
58
59 #endif /** _USE_DLOG_UTIL */
60
61
62
63 #define assertm_if(expr, fmt, arg...) do { \
64    if(expr) { \
65           WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
66                  exit(1); \
67    } \
68 } while (0)
69
70
71
72 #endif                          /* __WFD_APP_UTIL_H__ */