From 1be04943bec1a325085fb5ebb5838a5a2b38f789 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Sat, 13 Feb 2016 14:42:13 +0900 Subject: [PATCH] sensord: clean up sf_common.h/sensor_common.h/sensor_logs.h - add command_common.h for command macro/struct/enum - clean up sensor_logs.h also Change-Id: I4241a7cf7955df79bfb54ea5fb3777da50e76adb Signed-off-by: kibak.yoon --- src/client/CMakeLists.txt | 2 +- src/client/client.cpp | 33 +++--- src/client/command_channel.cpp | 2 +- src/client/command_channel.h | 2 +- src/client/reg_event_info.h | 4 +- src/client/sensor_client_info.cpp | 1 - src/client/sensor_client_info.h | 1 - src/client/sensor_event_listener.cpp | 7 +- src/client/sensor_event_listener.h | 1 - src/client/sensor_handle_info.h | 1 + src/server/client_info_manager.cpp | 1 + src/server/client_sensor_record.h | 1 - src/server/command_worker.cpp | 5 +- src/server/command_worker.h | 1 + src/server/permission_checker.cpp | 1 - src/server/physical_sensor.h | 1 - .../plugins/auto_rotation/auto_rotation_sensor.cpp | 1 - src/server/plugins/fusion/fusion_sensor.cpp | 1 - src/server/plugins/gravity/gravity_sensor.cpp | 1 - .../plugins/linear_accel/linear_accel_sensor.cpp | 1 - .../plugins/orientation/orientation_sensor.cpp | 1 - .../rotation_vector/gaming_rv/gaming_rv_sensor.cpp | 1 - .../geomagnetic_rv/geomagnetic_rv_sensor.cpp | 1 - .../plugins/rotation_vector/rv/rv_sensor.cpp | 1 - src/server/plugins/sensor_module_create.cpp.in | 2 - src/server/plugins/tilt/tilt_sensor.cpp | 1 - src/server/sensor_event_dispatcher.cpp | 3 +- src/server/sensor_event_dispatcher.h | 1 - src/server/sensor_event_queue.h | 2 +- src/server/sensor_usage.h | 1 - src/server/server.cpp | 1 + src/server/worker_thread.cpp | 28 ++--- src/shared/{sf_common.h => command_common.h} | 48 +------- src/shared/cpacket.cpp | 2 +- src/shared/poller.cpp | 3 +- src/shared/sensor_common.h | 61 +++++++--- src/shared/sensor_info.h | 1 - src/shared/sensor_internal.h | 4 - src/shared/sensor_internal_deprecated.h | 28 ++--- src/shared/sensor_logs.cpp | 87 +------------- src/shared/sensor_logs.h | 130 +++------------------ 41 files changed, 130 insertions(+), 345 deletions(-) rename src/shared/{sf_common.h => command_common.h} (71%) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 80a1ddc..f002263 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(sensor CXX) -SET(DEPENDENTS "vconf glib-2.0") +SET(DEPENDENTS "vconf glib-2.0 dlog") SET(VERSION ${FULLVER}) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/src/client/client.cpp b/src/client/client.cpp index e64482f..3dcf35a 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -17,7 +17,6 @@ * */ -#include #include #include #include @@ -63,7 +62,7 @@ void init_client(void) static void good_bye(void) { - _D("Good bye! %s\n", get_client_name()); + DBG("Good bye! %s\n", get_client_name()); clean_up(); } @@ -72,14 +71,14 @@ static int g_power_save_state_cb_cnt = 0; static void set_power_save_state_cb(void) { if (g_power_save_state_cb_cnt < 0) - _E("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt); + ERR("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt); ++g_power_save_state_cb_cnt; if (g_power_save_state_cb_cnt == 1) { - _D("Power save callback is registered"); + DBG("Power save callback is registered"); g_power_save_state = get_power_save_state(); - _D("power_save_state = [%d]", g_power_save_state); + DBG("power_save_state = [%d]", g_power_save_state); vconf_notify_key_changed(VCONFKEY_PM_STATE, power_save_state_cb, NULL); } } @@ -89,10 +88,10 @@ static void unset_power_save_state_cb(void) --g_power_save_state_cb_cnt; if (g_power_save_state_cb_cnt < 0) - _E("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt); + ERR("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt); if (g_power_save_state_cb_cnt == 0) { - _D("Power save callback is unregistered"); + DBG("Power save callback is unregistered"); vconf_ignore_key_changed(VCONFKEY_PM_STATE, power_save_state_cb); } } @@ -106,7 +105,7 @@ static void clean_up(void) auto it_handle = handles.begin(); while (it_handle != handles.end()) { - sf_disconnect(*it_handle); + sensord_disconnect(*it_handle); ++it_handle; } } @@ -136,12 +135,12 @@ static void power_save_state_cb(keynode_t *node, void *data) cur_power_save_state = get_power_save_state(); if (cur_power_save_state == g_power_save_state) { - _T("g_power_save_state NOT changed : [%d]", cur_power_save_state); + DBG("g_power_save_state NOT changed : [%d]", cur_power_save_state); return; } g_power_save_state = cur_power_save_state; - _D("power_save_state: %d noti to %s", g_power_save_state, get_client_name()); + DBG("power_save_state: %d noti to %s", g_power_save_state, get_client_name()); client_info.get_listening_sensors(sensors); @@ -162,7 +161,7 @@ static void restore_session(void) { AUTOLOCK(lock); - _I("Trying to restore session for %s", get_client_name()); + INFO("Trying to restore session for %s", get_client_name()); command_channel *cmd_channel; int client_id; @@ -183,7 +182,7 @@ static void restore_session(void) retm_if (!cmd_channel, "Failed to allocate memory"); if (!cmd_channel->create_channel()) { - _E("%s failed to create command channel for %s", get_client_name(), get_sensor_name(*it_sensor)); + ERR("%s failed to create command channel for %s", get_client_name(), get_sensor_name(*it_sensor)); delete cmd_channel; goto FAILED; } @@ -193,7 +192,7 @@ static void restore_session(void) if (first_connection) { first_connection = false; if (!cmd_channel->cmd_get_id(client_id)) { - _E("Failed to get client id"); + ERR("Failed to get client id"); goto FAILED; } @@ -204,7 +203,7 @@ static void restore_session(void) cmd_channel->set_client_id(client_id); if (!cmd_channel->cmd_hello(*it_sensor)) { - _E("Sending cmd_hello(%s, %d) failed for %s", get_sensor_name(*it_sensor), client_id, get_client_name()); + ERR("Sending cmd_hello(%s, %d) failed for %s", get_sensor_name(*it_sensor), client_id, get_client_name()); goto FAILED; } @@ -215,20 +214,20 @@ static void restore_session(void) client_info.get_sensor_rep(*it_sensor, cur_rep); if (!change_sensor_rep(*it_sensor, prev_rep, cur_rep)) { - _E("Failed to change rep(%s) for %s", get_sensor_name(*it_sensor), get_client_name()); + ERR("Failed to change rep(%s) for %s", get_sensor_name(*it_sensor), get_client_name()); goto FAILED; } ++it_sensor; } - _I("Succeeded to restore session for %s", get_client_name()); + INFO("Succeeded to restore session for %s", get_client_name()); return; FAILED: event_listener.clear(); - _E("Failed to restore session for %s", get_client_name()); + ERR("Failed to restore session for %s", get_client_name()); } static bool get_events_diff(event_type_vector &a_vec, event_type_vector &b_vec, event_type_vector &add_vec, event_type_vector &del_vec) diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index 888503d..06cb549 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/client/command_channel.h b/src/client/command_channel.h index 439ace6..f205106 100644 --- a/src/client/command_channel.h +++ b/src/client/command_channel.h @@ -20,7 +20,7 @@ #ifndef _COMMAND_CHANNEL_H_ #define _COMMAND_CHANNEL_H_ -#include +#include #include #include #include diff --git a/src/client/reg_event_info.h b/src/client/reg_event_info.h index 44d8937..18e1335 100644 --- a/src/client/reg_event_info.h +++ b/src/client/reg_event_info.h @@ -20,8 +20,8 @@ #ifndef _REG_EVENT_INFO_H_ #define _REG_EVENT_INFO_H_ -#include -#include +#include +#include typedef enum { SENSOR_EVENT_CB, diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index bdae177..1e2c12c 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/src/client/sensor_client_info.h b/src/client/sensor_client_info.h index 9569f61..b408356 100644 --- a/src/client/sensor_client_info.h +++ b/src/client/sensor_client_info.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 028b8f2..6d62eb5 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -472,12 +471,12 @@ void sensor_event_listener::stop_event_listener(void) if (m_thread_state != THREAD_STATE_TERMINATE) { m_thread_state = THREAD_STATE_STOP; - _D("%s is waiting listener thread[state: %d] to be terminated", get_client_name(), m_thread_state); + DBG("%s is waiting listener thread[state: %d] to be terminated", get_client_name(), m_thread_state); if (m_thread_cond.wait_for(u, std::chrono::seconds(THREAD_TERMINATING_TIMEOUT)) == std::cv_status::timeout) - _E("Fail to stop listener thread after waiting %d seconds", THREAD_TERMINATING_TIMEOUT); + ERR("Fail to stop listener thread after waiting %d seconds", THREAD_TERMINATING_TIMEOUT); else - _D("Listener thread for %s is terminated", get_client_name()); + DBG("Listener thread for %s is terminated", get_client_name()); } } diff --git a/src/client/sensor_event_listener.h b/src/client/sensor_event_listener.h index 317f527..d9fc2f8 100644 --- a/src/client/sensor_event_listener.h +++ b/src/client/sensor_event_listener.h @@ -37,7 +37,6 @@ #include #include -#include #include #include #include diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index 2af4d95..e70c386 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -25,6 +25,7 @@ #include #include #include +#include typedef std::unordered_map event_info_map; diff --git a/src/server/client_info_manager.cpp b/src/server/client_info_manager.cpp index 52308ff..037e9a1 100644 --- a/src/server/client_info_manager.cpp +++ b/src/server/client_info_manager.cpp @@ -17,6 +17,7 @@ * */ +#include #include #include #include diff --git a/src/server/client_sensor_record.h b/src/server/client_sensor_record.h index d6968e9..cad13f4 100644 --- a/src/server/client_sensor_record.h +++ b/src/server/client_sensor_record.h @@ -21,7 +21,6 @@ #define _CLIENT_SENSOR_RECORD_H_ #include -#include #include #include #include diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 7407310..b6491ab 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -17,7 +17,7 @@ * */ -#include +#include #include #include #include @@ -25,8 +25,9 @@ #include #include #include -#include #include +#include +#include using std::string; using std::vector; diff --git a/src/server/command_worker.h b/src/server/command_worker.h index 8323571..f455cb6 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -20,6 +20,7 @@ #ifndef _COMMAND_WORKER_H_ #define _COMMAND_WORKER_H_ +#include #include #include #include diff --git a/src/server/permission_checker.cpp b/src/server/permission_checker.cpp index aa700b8..5a06dd9 100644 --- a/src/server/permission_checker.cpp +++ b/src/server/permission_checker.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/physical_sensor.h b/src/server/physical_sensor.h index c59ce89..32cfa38 100644 --- a/src/server/physical_sensor.h +++ b/src/server/physical_sensor.h @@ -21,7 +21,6 @@ #define _PHYSICAL_SENSOR_H_ #include -#include #include class physical_sensor : public sensor_base { diff --git a/src/server/plugins/auto_rotation/auto_rotation_sensor.cpp b/src/server/plugins/auto_rotation/auto_rotation_sensor.cpp index d8b1700..fbff5d5 100644 --- a/src/server/plugins/auto_rotation/auto_rotation_sensor.cpp +++ b/src/server/plugins/auto_rotation/auto_rotation_sensor.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include diff --git a/src/server/plugins/fusion/fusion_sensor.cpp b/src/server/plugins/fusion/fusion_sensor.cpp index 49d3f9e..98db53c 100644 --- a/src/server/plugins/fusion/fusion_sensor.cpp +++ b/src/server/plugins/fusion/fusion_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/gravity/gravity_sensor.cpp b/src/server/plugins/gravity/gravity_sensor.cpp index b39218f..390169f 100644 --- a/src/server/plugins/gravity/gravity_sensor.cpp +++ b/src/server/plugins/gravity/gravity_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/linear_accel/linear_accel_sensor.cpp b/src/server/plugins/linear_accel/linear_accel_sensor.cpp index 3c194f3..93f4086 100644 --- a/src/server/plugins/linear_accel/linear_accel_sensor.cpp +++ b/src/server/plugins/linear_accel/linear_accel_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/orientation/orientation_sensor.cpp b/src/server/plugins/orientation/orientation_sensor.cpp index 2775c4c..911b7f3 100644 --- a/src/server/plugins/orientation/orientation_sensor.cpp +++ b/src/server/plugins/orientation/orientation_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp b/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp index ac19b63..4d022c7 100644 --- a/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp +++ b/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp b/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp index 43abcf2..6f1e606 100644 --- a/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp +++ b/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/rotation_vector/rv/rv_sensor.cpp b/src/server/plugins/rotation_vector/rv/rv_sensor.cpp index 3a98182..f00ffef 100644 --- a/src/server/plugins/rotation_vector/rv/rv_sensor.cpp +++ b/src/server/plugins/rotation_vector/rv/rv_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/plugins/sensor_module_create.cpp.in b/src/server/plugins/sensor_module_create.cpp.in index 780461b..576fdf6 100644 --- a/src/server/plugins/sensor_module_create.cpp.in +++ b/src/server/plugins/sensor_module_create.cpp.in @@ -59,8 +59,6 @@ #include #endif -#include - extern "C" sensor_module* create(void) { sensor_module *module = new(std::nothrow) sensor_module; diff --git a/src/server/plugins/tilt/tilt_sensor.cpp b/src/server/plugins/tilt/tilt_sensor.cpp index ef1a088..cab3520 100644 --- a/src/server/plugins/tilt/tilt_sensor.cpp +++ b/src/server/plugins/tilt/tilt_sensor.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index 1db1c3a..f29a668 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -17,9 +17,9 @@ * */ +#include #include #include -#include #include using std::thread; @@ -137,7 +137,6 @@ void sensor_event_dispatcher::dispatch_event(void) while (true) { void *seed_event = get_event_queue().pop(); - unsigned int event_type = *((unsigned int *)(seed_event)); vector sensor_events; sensor_events.push_back(seed_event); diff --git a/src/server/sensor_event_dispatcher.h b/src/server/sensor_event_dispatcher.h index cd38f97..befa90e 100644 --- a/src/server/sensor_event_dispatcher.h +++ b/src/server/sensor_event_dispatcher.h @@ -20,7 +20,6 @@ #ifndef _SENSOR_EVENT_DISPATCHER_H_ #define _SENSOR_EVENT_DISPATCHER_H_ -#include #include #include #include diff --git a/src/server/sensor_event_queue.h b/src/server/sensor_event_queue.h index 28bf69e..ba9decb 100644 --- a/src/server/sensor_event_queue.h +++ b/src/server/sensor_event_queue.h @@ -20,13 +20,13 @@ #ifndef _SENSOR_EVENT_QUEUE_H_ #define _SENSOR_EVENT_QUEUE_H_ -#include #include #include #include #include #include #include +#include extern std::set priority_list; diff --git a/src/server/sensor_usage.h b/src/server/sensor_usage.h index 7e6d3ac..59165e4 100644 --- a/src/server/sensor_usage.h +++ b/src/server/sensor_usage.h @@ -20,7 +20,6 @@ #ifndef _SENSOR_USAGE_H_ #define _SENSOR_USAGE_H_ -#include #include #include diff --git a/src/server/server.cpp b/src/server/server.cpp index 8f572bc..ad28539 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/server/worker_thread.cpp b/src/server/worker_thread.cpp index 2726706..e6e7d4a 100644 --- a/src/server/worker_thread.cpp +++ b/src/server/worker_thread.cpp @@ -41,7 +41,7 @@ bool worker_thread::transition_function(trans_func_index index) { if (m_trans_func[index] != NULL) { if(!m_trans_func[index](m_context)) { - _T("Transition[%d] function returning false", index); + ERR("Transition[%d] function returning false", index); return false; } } @@ -61,7 +61,7 @@ bool worker_thread::start(void) lock l(m_mutex); if (m_state == WORKER_STATE_WORKING) { - _T("Worker thread is already working"); + INFO("Worker thread is already working"); return true; } @@ -79,7 +79,7 @@ bool worker_thread::start(void) return true; } - _T("Failed to start, because current state(%d) is not for START", m_state); + ERR("Failed to start, because current state(%d) is not for START", m_state); return false; } @@ -89,7 +89,7 @@ bool worker_thread::stop(void) lock l(m_mutex); if (m_state == WORKER_STATE_STOPPED) { - _T("Worker thread is already stopped"); + INFO("Worker thread is already stopped"); return true; } @@ -102,7 +102,7 @@ bool worker_thread::stop(void) return true; } - _T("Failed to stop, because current state(%d) is not for STOP", m_state); + ERR("Failed to stop, because current state(%d) is not for STOP", m_state); return false; } @@ -111,7 +111,7 @@ bool worker_thread::pause(void) lock l(m_mutex); if (m_state == WORKER_STATE_PAUSED) { - _T("Worker thread is already paused"); + INFO("Worker thread is already paused"); return true; } @@ -120,7 +120,7 @@ bool worker_thread::pause(void) return true; } - _T("Failed to pause, because current state(%d) is not for PAUSE", m_state); + ERR("Failed to pause, because current state(%d) is not for PAUSE", m_state); return false; @@ -131,7 +131,7 @@ bool worker_thread::resume(void) lock l(m_mutex); if (m_state == WORKER_STATE_WORKING) { - _T("Worker thread is already working"); + INFO("Worker thread is already working"); return true; } @@ -141,7 +141,7 @@ bool worker_thread::resume(void) return true; } - _T("Failed to resume, because current state(%d) is not for RESUME", m_state); + ERR("Failed to resume, because current state(%d) is not for RESUME", m_state); return false; } @@ -153,7 +153,7 @@ bool worker_thread::resume(void) void worker_thread::main(void) { - _T("Worker thread(0x%x) is created", std::this_thread::get_id()); + DBG("Worker thread(0x%x) is created", std::this_thread::get_id()); transition_function(STARTED); @@ -164,7 +164,7 @@ void worker_thread::main(void) if (state == WORKER_STATE_WORKING) { if (!transition_function(WORKING)) { m_state = WORKER_STATE_STOPPED; - _T("Worker thread(0x%x) exits from working state", std::this_thread::get_id()); + DBG("Worker thread(0x%x) exits from working state", std::this_thread::get_id()); m_thread_created = false; transition_function(STOPPED); break; @@ -177,12 +177,12 @@ void worker_thread::main(void) if (m_state == WORKER_STATE_PAUSED) { transition_function(PAUSED); - _T("Worker thread(0x%x) is paused", std::this_thread::get_id()); + DBG("Worker thread(0x%x) is paused", std::this_thread::get_id()); m_cond_working.wait(u); if (m_state == WORKER_STATE_WORKING) { transition_function(RESUMED); - _T("Worker thread(0x%x) is resumed", std::this_thread::get_id()); + DBG("Worker thread(0x%x) is resumed", std::this_thread::get_id()); } else if (m_state == WORKER_STATE_STOPPED) { m_thread_created = false; transition_function(STOPPED); @@ -194,7 +194,7 @@ void worker_thread::main(void) break; } } - _T("Worker thread(0x%x)'s main is terminated", std::this_thread::get_id()); + INFO("Worker thread(0x%x)'s main is terminated", std::this_thread::get_id()); } void worker_thread::set_started(trans_func_t func) diff --git a/src/shared/sf_common.h b/src/shared/command_common.h similarity index 71% rename from src/shared/sf_common.h rename to src/shared/command_common.h index 4df48eb..6fa17b4 100644 --- a/src/shared/sf_common.h +++ b/src/shared/command_common.h @@ -17,14 +17,10 @@ * */ -#ifndef _SF_COMMON_H_ -#define _SF_COMMON_H_ +#ifndef _COMMAND_COMMON_H_ +#define _COMMAND_COMMON_H_ -#include #include -#include -#include -#include #define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket" #define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket" @@ -32,8 +28,6 @@ #define MAX_HANDLE 256 #define MAX_HANDLE_REACHED -2 -#define CLIENT_ID_INVALID -1 - enum packet_type_t { CMD_NONE = 0, CMD_GET_ID, @@ -55,24 +49,6 @@ enum packet_type_t { CMD_CNT, }; -enum sensor_state_t { - SENSOR_STATE_UNKNOWN = -1, - SENSOR_STATE_STOPPED = 0, - SENSOR_STATE_STARTED = 1, - SENSOR_STATE_PAUSED = 2 -}; - -enum poll_interval_t { - POLL_100HZ_MS = 10, - POLL_50HZ_MS = 20, - POLL_25HZ_MS = 40, - POLL_20HZ_MS = 50, - POLL_10HZ_MS = 100, - POLL_5HZ_MS = 200, - POLL_1HZ_MS = 1000, - POLL_MAX_HZ_MS = POLL_1HZ_MS, -}; - typedef struct { char name[NAME_MAX]; } cmd_get_id_t; @@ -160,24 +136,6 @@ typedef struct { int client_id; } event_channel_ready_t; -typedef struct sensor_event_t { - unsigned int event_type; - sensor_id_t sensor_id; - unsigned int data_length; - sensor_data_t *data; -} sensor_event_t; - typedef void *(*cmd_func_t)(void *data, void *cb_data); -typedef std::vector event_type_vector; - -enum sensor_permission_t { - SENSOR_PERMISSION_NONE = 0, - SENSOR_PERMISSION_STANDARD = (1 << 0), - SENSOR_PERMISSION_BIO = (1 << 1), -}; - -#define BIO_SENSOR_PRIVELEGE_NAME "sensord::bio" -#define BIO_SENSOR_ACCESS_RIGHT "rw" - -#endif /* _SF_COMMON_H_ */ +#endif /* _COMMAND_COMMON_H_ */ diff --git a/src/shared/cpacket.cpp b/src/shared/cpacket.cpp index 8e680b0..6cb6e8c 100644 --- a/src/shared/cpacket.cpp +++ b/src/shared/cpacket.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include cpacket::cpacket() { diff --git a/src/shared/poller.cpp b/src/shared/poller.cpp index 2fb902b..aaa43fe 100644 --- a/src/shared/poller.cpp +++ b/src/shared/poller.cpp @@ -16,9 +16,10 @@ * limitations under the License. * */ +#include +#include #include #include -#include #define EPOLL_MAX 32 diff --git a/src/shared/sensor_common.h b/src/shared/sensor_common.h index 2edc306..abbb21c 100644 --- a/src/shared/sensor_common.h +++ b/src/shared/sensor_common.h @@ -24,8 +24,10 @@ #include #include -#ifndef DEPRECATED -#define DEPRECATED __attribute__((deprecated)) +#define CLIENT_ID_INVALID -1 + +#ifndef NAME_MAX +#define NAME_MAX 256 #endif #ifdef __cplusplus @@ -46,11 +48,6 @@ typedef int64_t sensor_id_t; typedef void *sensor_t; -typedef enum { - SENSOR_PRIVILEGE_PUBLIC, - SENSOR_PRIVILEGE_INTERNAL, -} sensor_privilege_t; - /* * To prevent naming confliction as using same enums as sensor CAPI use */ @@ -66,22 +63,26 @@ enum sensor_option_t { typedef enum sensor_option_t sensor_option_e; #endif -/* - * To prevent naming confliction as using same enums as sensor CAPI use - */ -#ifndef __SENSOR_H__ enum sensor_wakeup_t { SENSOR_WAKEUP_UNKNOWN = -1, SENSOR_WAKEUP_OFF = 0, SENSOR_WAKEUP_ON = 1, }; -typedef enum sensor_wakeup_t sensor_wakeup_e; -#endif +enum poll_interval_t { + POLL_100HZ_MS = 10, + POLL_50HZ_MS = 20, + POLL_25HZ_MS = 40, + POLL_20HZ_MS = 50, + POLL_10HZ_MS = 100, + POLL_5HZ_MS = 200, + POLL_1HZ_MS = 1000, + POLL_MAX_HZ_MS = POLL_1HZ_MS, +}; enum sensor_interval_t { - SENSOR_INTERVAL_FASTEST = 0, - SENSOR_INTERVAL_NORMAL = 200, + SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS, + SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS, }; typedef enum { @@ -91,9 +92,39 @@ typedef enum { CONDITION_LESS_THAN, } condition_op_t; +enum sensor_state_t { + SENSOR_STATE_UNKNOWN = -1, + SENSOR_STATE_STOPPED = 0, + SENSOR_STATE_STARTED = 1, + SENSOR_STATE_PAUSED = 2 +}; + +typedef enum { + SENSOR_PRIVILEGE_PUBLIC, + SENSOR_PRIVILEGE_INTERNAL, +} sensor_privilege_t; + +enum sensor_permission_t { + SENSOR_PERMISSION_NONE = 0, + SENSOR_PERMISSION_STANDARD = (1 << 0), + SENSOR_PERMISSION_BIO = (1 << 1) +}; + +typedef struct sensor_event_t { + unsigned int event_type; + sensor_id_t sensor_id; + unsigned int data_length; + sensor_data_t *data; +} sensor_event_t; + #ifdef __cplusplus } #endif +#ifdef __cplusplus +#include + +typedef std::vector event_type_vector; +#endif #endif /* __SENSOR_COMMON_H__ */ diff --git a/src/shared/sensor_info.h b/src/shared/sensor_info.h index 61a3cfb..536c6f9 100644 --- a/src/shared/sensor_info.h +++ b/src/shared/sensor_info.h @@ -21,7 +21,6 @@ #define _SENSOR_INFO_H_ #include -#include #include #include #include diff --git a/src/shared/sensor_internal.h b/src/shared/sensor_internal.h index 0a3d85a..d5b495f 100644 --- a/src/shared/sensor_internal.h +++ b/src/shared/sensor_internal.h @@ -20,10 +20,6 @@ #ifndef __SENSOR_INTERNAL_H__ #define __SENSOR_INTERNAL_H__ -#ifndef DEPRECATED -#define DEPRECATED __attribute__((deprecated)) -#endif - #ifndef API #define API __attribute__((visibility("default"))) #endif diff --git a/src/shared/sensor_internal_deprecated.h b/src/shared/sensor_internal_deprecated.h index 4a6948c..a2c05bd 100644 --- a/src/shared/sensor_internal_deprecated.h +++ b/src/shared/sensor_internal_deprecated.h @@ -79,13 +79,13 @@ typedef struct { float sensor_resolution; } sensor_data_properties_t; -int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type); +DEPRECATED int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type); -int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties); +DEPRECATED int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties); -int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties); +DEPRECATED int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties); -int sf_check_rotation(unsigned long *rotation); +DEPRECATED int sf_check_rotation(unsigned long *rotation); /** * @fn int sf_connect(sensor_type_t sensor) @@ -93,7 +93,7 @@ int sf_check_rotation(unsigned long *rotation); * @param[in] sensor_type your desired sensor type * @return if it succeed, it return handle value( >=0 ) , otherwise negative value return */ -int sf_connect(sensor_type_t sensor_type); +DEPRECATED int sf_connect(sensor_type_t sensor_type); /** * @fn int sf_disconnect(int handle) @@ -101,7 +101,7 @@ int sf_connect(sensor_type_t sensor_type); * @param[in] handle received handle value by sf_connect() * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_disconnect(int handle); +DEPRECATED int sf_disconnect(int handle); /** * @fn int sf_start(int handle , int option) @@ -110,7 +110,7 @@ int sf_disconnect(int handle); * @param[in] option With SENSOR_OPTION_DEFAULT, it stops to sense when LCD is off, and with SENSOR_OPTION_ALWAYS_ON, it continues to sense even when LCD is off * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_start(int handle , int option); +DEPRECATED int sf_start(int handle , int option); /** * @fn int sf_stop(int handle) @@ -118,7 +118,7 @@ int sf_start(int handle , int option); * @param[in] handle received handle value by sf_connect() * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_stop(int handle); +DEPRECATED int sf_stop(int handle); /** * @fn int sf_register_event(int handle , unsigned int event_type , event_conditon_t *event_condition , sensor_callback_func_t cb , void *user_data ) @@ -130,7 +130,7 @@ int sf_stop(int handle); * @param[in] user_data your option data that will be send when your define callback function called. if you don't have any option data, just use a NULL value * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data ); +DEPRECATED int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data ); /** * @fn int sf_unregister_event(int handle, unsigned int event_type) @@ -139,7 +139,7 @@ int sf_register_event(int handle , unsigned int event_type , event_condition_t * * @param[in] event_type your desired event_type that you want to unregister event * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_unregister_event(int handle, unsigned int event_type); +DEPRECATED int sf_unregister_event(int handle, unsigned int event_type); /** * @fn int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values) @@ -149,7 +149,7 @@ int sf_unregister_event(int handle, unsigned int event_type); * @param[out] values return values * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values); +DEPRECATED int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values); /** * @fn int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition) @@ -159,7 +159,7 @@ int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values); * @param[in] event_condition your desired event condition that you want to change event * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition); +DEPRECATED int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition); /** * @fn int sf_change_sensor_option(int handle, int option) @@ -169,7 +169,7 @@ int sf_change_event_condition(int handle, unsigned int event_type, event_conditi * @return if it succeed, it return zero value , otherwise negative value return */ -int sf_change_sensor_option(int handle, int option); +DEPRECATED int sf_change_sensor_option(int handle, int option); /** * @fn int sf_send_sensorhub_data(int handle, const char* buffer, int data_len) @@ -179,7 +179,7 @@ int sf_change_sensor_option(int handle, int option); * @param[in] data_len the length of data * @return if it succeed, it returns zero, otherwise negative value */ -int sf_send_sensorhub_data(int handle, const char* data, int data_len); +DEPRECATED int sf_send_sensorhub_data(int handle, const char* data, int data_len); #ifdef __cplusplus diff --git a/src/shared/sensor_logs.cpp b/src/shared/sensor_logs.cpp index 5426c0f..e98e41b 100644 --- a/src/shared/sensor_logs.cpp +++ b/src/shared/sensor_logs.cpp @@ -17,7 +17,6 @@ * */ -#include #include #include #include @@ -25,92 +24,10 @@ #include #include #include -#include -#include +#include #include "sensor_logs.h" -#ifndef EXTAPI -#define EXTAPI __attribute__((visibility("default"))) -#endif - -#define SF_SERVER_MSG_LOG_FILE "/var/log/messages" -#define FILE_LENGTH 255 - -static int sf_debug_file_fd; -static char sf_debug_file_buf[FILE_LENGTH]; - -EXTAPI void sf_log(int type , int priority , const char *tag , const char *fmt , ...) -{ - va_list ap; - va_start(ap, fmt); - - switch (type) { - case SF_LOG_PRINT_FILE: - sf_debug_file_fd = open(SF_SERVER_MSG_LOG_FILE, O_WRONLY|O_CREAT|O_APPEND, 0644); - if (sf_debug_file_fd != -1) { - vsnprintf(sf_debug_file_buf,255, fmt , ap ); - int total_bytes_written = 0; - while (total_bytes_written < (int) strlen(sf_debug_file_buf)){ - int bytes_written = write(sf_debug_file_fd, (sf_debug_file_buf + total_bytes_written), strlen(sf_debug_file_buf) - total_bytes_written); - if (bytes_written == -1) - break; - total_bytes_written = total_bytes_written + bytes_written; - } - close(sf_debug_file_fd); - } - break; - - case SF_LOG_SYSLOG: - int syslog_prio; - switch (priority) { - case SF_LOG_ERR: - syslog_prio = LOG_ERR|LOG_DAEMON; - break; - case SF_LOG_WARN: - syslog_prio = LOG_WARNING|LOG_DAEMON; - break; - - case SF_LOG_DBG: - syslog_prio = LOG_DEBUG|LOG_DAEMON; - break; - - case SF_LOG_INFO: - syslog_prio = LOG_INFO|LOG_DAEMON; - break; - - default: - syslog_prio = priority; - break; - } - - vsyslog(syslog_prio, fmt, ap); - break; - - case SF_LOG_DLOG: - if (tag) { - switch (priority) { - case SF_LOG_ERR: - SLOG_VA(LOG_ERROR, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_WARN: - SLOG_VA(LOG_WARN, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_DBG: - SLOG_VA(LOG_DEBUG, tag ? tag : "NULL", fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_INFO: - SLOG_VA(LOG_INFO, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - } - } - break; - } - - va_end(ap); -} +#define PATH_MAX 256 #if defined(_DEBUG) bool get_proc_name(pid_t pid, char *process_name) diff --git a/src/shared/sensor_logs.h b/src/shared/sensor_logs.h index 70b10fa..aa01eb7 100644 --- a/src/shared/sensor_logs.h +++ b/src/shared/sensor_logs.h @@ -20,137 +20,32 @@ #ifndef _SENSOR_LOGS_H_ #define _SENSOR_LOGS_H_ -#ifndef __cplusplus -#include -#endif /* !__cplusplus */ - -#ifdef __cplusplus -extern "C" -{ -#endif - +#include #include -#include - -#if !defined(PATH_MAX) -#define PATH_MAX 256 -#endif - -#if !defined(NAME_MAX) -#define NAME_MAX 256 -#endif - #define EVENT_TYPE_SHIFT 16 #define SENSOR_TYPE_SHIFT 32 -#define USE_DLOG_LOG - -enum sf_log_type { - SF_LOG_PRINT_FILE = 1, - SF_LOG_SYSLOG = 2, - SF_LOG_DLOG = 3, -}; - -enum sf_priority_type { - SF_LOG_ERR = 1, - SF_LOG_DBG = 2, - SF_LOG_INFO = 3, - SF_LOG_WARN = 4, -}; - -void sf_log(int type , int priority , const char *tag , const char *fmt , ...); - #define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec) -#ifndef __MODULE__ -#include -#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) -#endif - -//for new log system - dlog #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "SENSOR" -#if defined(_DEBUG) || defined(USE_FILE_DEBUG) - -#define DbgPrint(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG , " [SF_MSG_PRT][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#endif - -#if defined(USE_SYSLOG_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - - -#elif defined(_DEBUG) || defined(USE_DLOG_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#elif defined(USE_FILE_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_TEMP][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#elif defined(USE_DLOG_LOG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define DBG(...) do{} while(0) -#define DbgPrint(...) do{} while(0) - - -#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(...) - +#ifdef _DEBUG +#define DBG SLOGD #else -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(...) do{} while(0) -#define DbgPrint(...) do{} while(0) #define DBG(...) do{} while(0) -#define INFO(...) do{} while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(...) do{} while(0) -#define _I(...) do{} while(0) -#define _D(...) do{} while(0) -#define _T(...) do{} while(0) - #endif +#define ERR SLOGE +#define WARN SLOGW +#define INFO SLOGI +#define _E ERR +#define _W WARN +#define _I INFO +#define _D DBG #if defined(_DEBUG) # define warn_if(expr, fmt, arg...) do { \ @@ -216,6 +111,11 @@ void sf_log(int type , int priority , const char *tag , const char *fmt , ...); #endif +#ifdef __cplusplus +extern "C" +{ +#endif + const char* get_client_name(void); bool get_proc_name(pid_t pid, char *process_name); -- 2.7.4