2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief private header file of library for communicate
15 #ifndef __ICO_UWS_PRIVATE_H__
16 #define __ICO_UWS_PRIVATE_H__
22 /*===========================================================================*/
23 /* variable & table */
24 /*===========================================================================*/
25 #define ICO_UWS_MAX_NUM 200 /**< max num of list's data */
26 #define ICO_UWS_MAX_FDS 4 /**< max num of file descriptors */
28 /* libwebsockets's protocol number */
29 enum ico_apf_protocols
31 PROTOCOL_HTTP = 0, /* always first */
32 PROTOCOL_ICO_UWS, /* for ico_uws communication */
33 PROTOCOL_END /* final */
36 /* structure for managing the ico_uws_context */
37 struct ico_uws_mng_context {
38 struct ico_uws_mng_context *next;
39 struct ico_uws_context *context;
42 /* structure for managing the ico_uws_context's list */
43 struct ico_uws_mng_context_list {
44 struct ico_uws_mng_context *first;
45 struct ico_uws_mng_context *last;
46 struct ico_uws_mng_context *free;
49 /* structure of connection info */
50 struct ico_uws_connect {
51 struct ico_uws_connect *next;
52 struct libwebsocket *wsi;
56 struct ico_uws_context {
57 struct libwebsocket_context *ws_context;
59 /* connection information list */
60 struct ico_uws_connect *con_list_first;
61 struct ico_uws_connect *con_list_last;
62 struct ico_uws_connect *con_list_free;
66 ico_uws_state_e state;
70 } callback_fd_list[ICO_UWS_MAX_FDS];
72 struct libwebsocket_protocols protocols[PROTOCOL_END + 1];
74 ico_uws_evt_cb callback;
78 /*============================================================================*/
80 /*============================================================================*/
81 #if defined(__GNUC__) && __GNUC__ >= 4
82 #define ICO_API __attribute__ ((visibility("default")))
87 /*============================================================================*/
89 /*============================================================================*/
96 #define LOG_TAG "ICO_UWS"
99 static int _ico_uws_debug = 0;
101 #define _ERR(fmt, arg...) \
103 fprintf(stderr, "ico_uws E: %s:%d [ "fmt" ]\n", \
107 LOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg); \
110 #define _WARN(fmt, arg...) \
112 LOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg); \
115 #define _INFO(fmt, arg...) \
117 LOGI("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg); \
120 #define _DBG(fmt, arg...) \
122 if (_ico_uws_debug == 0) { \
123 if (getenv("ICO_UWS_DEBUG")) \
124 _ico_uws_debug = 1; \
126 _ico_uws_debug = -1; \
128 if (_ico_uws_debug > 0) { \
129 LOGD("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg); \
135 #define _ERR(fmt, arg...) \
138 "ico_uws E: %s:%d [ "fmt" ]\n", \
144 #define _WARN(fmt, arg...) \
147 "ico_uws W: %s:%d [ "fmt" ]\n", \
154 #define _INFO(fmt, arg...) \
157 "ico_uws I: %s:%d [ "fmt" ]\n", \
163 #define _DBG(fmt, arg...) \
165 if (getenv("ICO_UWS_DEBUG")) { \
167 "ico_uws D: %s:%d [ "fmt" ]\n", \
180 #endif /* __ICO_UWS_PRIVATE_H__ */