--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ESPP_SERVICE_COMMON_H__
+#define __ESPP_SERVICE_COMMON_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#define GET_STRING(x) #x
+#define TO_STRING(x) GET_STRING(x)
+#define ESPP_SVC_VERSION TO_STRING(ESPP_SERVICE_VERSION)
+#define ESPP_SVC_SOCK_PATH TO_STRING(ESPP_SERVICE_SOCK_PATH)
+#else
+#define ESPP_SVC_VERSION "unknown"
+#define ESPP_SVC_SOCK_PATH "/tmp/espp_service.socket"
+#endif
+#include <stdlib.h>
+#include <glib.h>
+#include <stdbool.h>
+#ifdef USE_DLOG
+#include <dlog.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_RED "\033[31m"
+#define FONT_COLOR_GREEN "\033[32m"
+#define FONT_COLOR_YELLOW "\033[33m"
+#define FONT_COLOR_BLUE "\033[34m"
+#define FONT_COLOR_PURPLE "\033[35m"
+#define FONT_COLOR_CYAN "\033[36m"
+#define FONT_COLOR_GRAY "\033[37m"
+
+#ifdef USE_DLOG
+#define LOG_DEBUG(fmt, arg...) \
+do { \
+ LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
+} while (0)
+
+#define LOG_INFO(fmt, arg...) \
+do { \
+ LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
+} while (0)
+
+#define LOG_WARNING(fmt, arg...) \
+do { \
+ LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg); \
+} while (0)
+
+#define LOG_ERROR(fmt, arg...) \
+do { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+} while (0)
+
+#define LOG_DEBUG_ENTER() \
+do { \
+ LOGD(FONT_COLOR_PURPLE"<Enter>"FONT_COLOR_RESET); \
+} while (0)
+
+#define LOG_DEBUG_LEAVE() \
+do { \
+ LOGD(FONT_COLOR_PURPLE"<Leave>"FONT_COLOR_RESET); \
+} while (0)
+
+#else
+#define LOG_DEBUG(fmt, arg...) printf(FONT_COLOR_RESET""fmt"\n"FONT_COLOR_RESET, ##arg);
+#define LOG_INFO(fmt, arg...) printf(FONT_COLOR_GREEN""fmt"\n"FONT_COLOR_RESET, ##arg);
+#define LOG_WARNING(fmt, arg...) printf(FONT_COLOR_YELLOW""fmt"\n"FONT_COLOR_RESET, ##arg);
+#define LOG_ERROR(fmt, arg...) printf(FONT_COLOR_RED""fmt"\n"FONT_COLOR_RESET, ##arg);
+#define LOG_DEBUG_ENTER() printf(FONT_COLOR_PURPLE"<Enter>\n"FONT_COLOR_RESET);
+#define LOG_DEBUG_LEAVE() printf(FONT_COLOR_PURPLE"<Leave>\n"FONT_COLOR_RESET);
+#endif
+
+#define RET_IF(expr, fmt, arg...) \
+do { \
+ if ((expr)) { \
+ LOG_ERROR(""fmt"", ##arg); \
+ return; \
+ } \
+} while (0)
+
+#define RET_VAL_IF(expr, val, fmt, arg...) \
+do { \
+ if ((expr)) { \
+ LOG_ERROR(""fmt"", ##arg); \
+ return (val);\
+ } \
+} while (0)
+
+#define UNLIKELY(x) (__builtin_expect(!!(x),0))
+#define ASSERT(expr) \
+do {\
+ if (UNLIKELY(!(expr))) { \
+ LOG_ERROR("Assertion '%s' failed. Aborting.", #expr); \
+ abort(); \
+ } \
+} while (0)
+
+#define ESPP_SERVICE_SOCK ESPP_SVC_SOCK_PATH
+#define MAX_FUNC_LEN 32
+
+typedef struct {
+ char func[MAX_FUNC_LEN];
+} espp_service_data_from_client_s;
+
+typedef struct {
+ int ret;
+} espp_service_data_from_server_s;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ESPP_SERVICE_COMMON_H__ */
#ifndef __ESPP_SERVICE_PRIV_H__
#define __ESPP_SERVICE_PRIV_H__
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#define GET_STRING(x) #x
-#define TO_STRING(x) GET_STRING(x)
-#define ESPP_SVC_VERSION TO_STRING(ESPP_SERVICE_VERSION)
-#else
-#define ESPP_SVC_VERSION "unknown"
-#endif
-#include <stdlib.h>
-#include <glib.h>
-#include <stdbool.h>
-#ifdef USE_DLOG
-#include <dlog.h>
-#endif
+#include "../common/espp_service_common.h"
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define FONT_COLOR_RESET "\033[0m"
-#define FONT_COLOR_RED "\033[31m"
-#define FONT_COLOR_GREEN "\033[32m"
-#define FONT_COLOR_YELLOW "\033[33m"
-#define FONT_COLOR_BLUE "\033[34m"
-#define FONT_COLOR_PURPLE "\033[35m"
-#define FONT_COLOR_CYAN "\033[36m"
-#define FONT_COLOR_GRAY "\033[37m"
-
#ifdef USE_DLOG
#define LOG_TAG "ESPP_SERVICE"
-#define LOG_DEBUG(fmt, arg...) \
-do { \
- LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
-} while (0)
-
-#define LOG_INFO(fmt, arg...) \
-do { \
- LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
-} while (0)
-
-#define LOG_WARNING(fmt, arg...) \
-do { \
- LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg); \
-} while (0)
-
-#define LOG_ERROR(fmt, arg...) \
-do { \
- LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
-} while (0)
-
-#define LOG_DEBUG_ENTER() \
-do { \
- LOGD(FONT_COLOR_PURPLE"<Enter>"FONT_COLOR_RESET); \
-} while (0)
-
-#define LOG_DEBUG_LEAVE() \
-do { \
- LOGD(FONT_COLOR_PURPLE"<Leave>"FONT_COLOR_RESET); \
-} while (0)
-
-#else
-#define LOG_DEBUG(fmt, arg...) printf(FONT_COLOR_RESET""fmt"\n"FONT_COLOR_RESET, ##arg);
-#define LOG_INFO(fmt, arg...) printf(FONT_COLOR_GREEN""fmt"\n"FONT_COLOR_RESET, ##arg);
-#define LOG_WARNING(fmt, arg...) printf(FONT_COLOR_YELLOW""fmt"\n"FONT_COLOR_RESET, ##arg);
-#define LOG_ERROR(fmt, arg...) printf(FONT_COLOR_RED""fmt"\n"FONT_COLOR_RESET, ##arg);
-#define LOG_DEBUG_ENTER() printf(FONT_COLOR_PURPLE"<Enter>\n"FONT_COLOR_RESET);
-#define LOG_DEBUG_LEAVE() printf(FONT_COLOR_PURPLE"<Leave>\n"FONT_COLOR_RESET);
#endif
-#define RET_IF(expr, fmt, arg...) \
-do { \
- if ((expr)) { \
- LOG_ERROR(""fmt"", ##arg); \
- return; \
- } \
-} while (0)
-
-#define RET_VAL_IF(expr, val, fmt, arg...) \
-do { \
- if ((expr)) { \
- LOG_ERROR(""fmt"", ##arg); \
- return (val);\
- } \
-} while (0)
-
-#define UNLIKELY(x) (__builtin_expect(!!(x),0))
-#define ASSERT(expr) \
-do {\
- if (UNLIKELY(!(expr))) { \
- LOG_ERROR("Assertion '%s' failed. Aborting.", #expr); \
- abort(); \
- } \
-} while (0)
-
typedef struct {
bool start_service;
GMainLoop *mainloop;