INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/shared)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_SUBDIRECTORY(src/plugin-api/common)
ADD_SUBDIRECTORY(src/plugin-api/resourced)
ADD_SUBDIRECTORY(src/plugin-api/deviced)
src/resource-manager/resource-device.c
src/resource-manager/resource-listener-epoll.c
)
-SET(HEADERS
- src/libgdbus/libgdbus.h
- src/libgdbus/dbus-iface-system.h
- src/libsystemd/libsystemd.h
- src/libcommon/list.h
- src/libcommon/ini-parser.h
- src/libcommon/file.h
- src/libcommon/bitmap.h
- src/libcommon/common.h
- src/resource-manager/resource-manager.h
- src/resource-manager/resource-type.h
- src/resource-manager/resource-device.h
- src/resource-manager/resource-listener.h
-)
# CHECK PKG
INCLUDE(FindPkgConfig)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
# HEADER
-FOREACH(hfile ${HEADERS})
- INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
-ENDFOREACH(hfile)
+INSTALL(DIRECTORY include/libsyscommon DESTINATION include)
ADD_SUBDIRECTORY(tests)
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __SYSCOMMON_BITMAP_H__
+#define __SYSCOMMON_BITMAP_H__
+
+#include <stdbool.h>
+
+struct syscommon_bitmap;
+
+void syscommon_bitmap_set_bit(struct syscommon_bitmap *b, unsigned long nr);
+void syscommon_bitmap_clear_bit(struct syscommon_bitmap *b, unsigned long nr);
+bool syscommon_bitmap_test_bit(struct syscommon_bitmap *b, unsigned long nr);
+void syscommon_bitmap_set_all_bits(struct syscommon_bitmap *b);
+void syscommon_bitmap_clear_all_bits(struct syscommon_bitmap *b);
+int syscommon_bitmap_count_set_bit(struct syscommon_bitmap *b);
+int syscommon_bitmap_count_unset_bit(struct syscommon_bitmap *b);
+struct syscommon_bitmap* syscommon_bitmap_init_bitmap(unsigned int nbits);
+void syscommon_bitmap_deinit_bitmap(struct syscommon_bitmap *b);
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __LIBCOMMON_COMMON_H__
+#define __LIBCOMMON_COMMON_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Check if running on emulator
+ *
+ * @return true if running on emulator, otherwise false even on operation failure
+ */
+bool libsys_is_emulator(void);
+
+/**
+ * @brief Check if running on container
+ *
+ * @return true if running on container, otherwise false even on operation failure
+ */
+bool libsys_is_container(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBCOMMON_COMMON_H__ */
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __DBUS_SYSTEM_IFACE_H__
+#define __DBUS_SYSTEM_IFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Template
+ *
+#define XXX_BUS_NAME "org.tizen.system.XXX"
+#define XXX_OBJECT_PATH "/Org/Tizen/System/XXX"
+#define XXX_INTERFACE_NAME XXX_BUS_NAME
+#define XXX_PATH_YYY XXX_OBJECT_PATH"/YYY"
+#define XXX_INTERFACE_YYY XXX_INTERFACE_NAME".YYY"
+#define XXX_SIGNAL_ZZZ "ZZZ"
+#define XXX_METHOD_ZZZ "ZZZ"
+ */
+
+/*******************************************************************************
+ *
+ * DBus daemon
+ *
+ ******************************************************************************/
+#define DBUS_BUS_NAME "org.freedesktop.DBus"
+#define DBUS_OBJECT_PATH "/org/freedesktop/DBus"
+#define DBUS_INTERFACE_NAME DBUS_BUS_NAME
+#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
+
+/*******************************************************************************
+ *
+ * System daemon (systemd)
+ *
+ ******************************************************************************/
+#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1"
+#define SYSTEMD_DBUS_DEST "org.freedesktop.systemd1"
+#define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager"
+
+/*******************************************************************************
+ *
+ * Device daemon (deviced)
+ *
+ ******************************************************************************/
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+/* Core service: get/set device status operations about device */
+#define DEVICED_PATH_CORE DEVICED_OBJECT_PATH"/Core"
+#define DEVICED_INTERFACE_CORE DEVICED_INTERFACE_NAME".core"
+/* Display service: start/stop display(pm), get/set brightness operations about display */
+#define DEVICED_PATH_DISPLAY DEVICED_OBJECT_PATH"/Display"
+#define DEVICED_INTERFACE_DISPLAY DEVICED_INTERFACE_NAME".display"
+/* Pass service: start/stop pass operations about pass */
+#define DEVICED_PATH_PASS DEVICED_OBJECT_PATH"/Pass"
+#define DEVICED_INTERFACE_PASS DEVICED_INTERFACE_NAME".pass"
+/* Power service: set resetkey disable operations about power */
+#define DEVICED_PATH_POWER DEVICED_OBJECT_PATH"/Power"
+#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".Power"
+/* Power service : signals on changing power state */
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_START "PowerChangeStateToStart"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_NORMAL "PowerChangeStateToNormal"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SLEEP "PowerChangeStateToSleep"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_POWEROFF "PowerChangeStateToPowerOff"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_REBOOT "PowerChangeStateToReboot"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_EXIT "PowerChangeStateToExit"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_EARLY "PowerChangeStateToResumingEarly"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING "PowerChangeStateToResuming"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_LATE "PowerChangeStateToResumingLate"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_EARLY "PowerChangeStateToSuspendingEarly"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING "PowerChangeStateToSuspending"
+#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_LATE "PowerChangeStateToSuspendingLate"
+/* Power service : signals on changing power lock state */
+#define DEVICED_SIGNAL_POWER_LOCK_STATE_CHANGED "PowerLockStateChanged"
+/* Storage service: get storage size operatioins about storage */
+#define DEVICED_PATH_STORAGE DEVICED_OBJECT_PATH"/Storage"
+#define DEVICED_INTERFACE_STORAGE DEVICED_INTERFACE_NAME".storage"
+/* ODE service: request ode popup result operatioins about storage */
+#define DEVICED_PATH_SDE DEVICED_OBJECT_PATH"/Sde"
+#define DEVICED_INTERFACE_SDE DEVICED_INTERFACE_NAME".sde"
+#define DEVICED_PATH_ODE DEVICED_OBJECT_PATH"/Ode"
+#define DEVICED_INTERFACE_ODE DEVICED_INTERFACE_NAME".ode"
+/* Poweroff service: request power off operation or get power off status operations about Poweroff(signal) */
+#define DEVICED_PATH_POWEROFF DEVICED_OBJECT_PATH"/PowerOff"
+#define DEVICED_INTERFACE_POWEROFF DEVICED_INTERFACE_NAME".PowerOff"
+/* Led service: play/stop led operations about led */
+#define DEVICED_PATH_LED DEVICED_OBJECT_PATH"/Led"
+#define DEVICED_INTERFACE_LED DEVICED_INTERFACE_NAME".Led"
+/* Process service: operations about process */
+#define DEVICED_PATH_PROCESS DEVICED_OBJECT_PATH"/Process"
+#define DEVICED_INTERFACE_PROCESS DEVICED_INTERFACE_NAME".Process"
+/* Key service: operations about key */
+#define DEVICED_PATH_KEY DEVICED_OBJECT_PATH"/Key"
+#define DEVICED_INTERFACE_KEY DEVICED_INTERFACE_NAME".Key"
+/* USB client service: change usb connection mode */
+#define DEVICED_PATH_USB DEVICED_OBJECT_PATH"/Usb"
+#define DEVICED_INTERFACE_USB DEVICED_INTERFACE_NAME".Usb"
+/* USB start/stop service: operations about usb start/stop */
+#define DEVICED_PATH_USB_CONTROL DEVICED_OBJECT_PATH"/UsbControl"
+#define DEVICED_INTERFACE_USB_CONTROL DEVICED_INTERFACE_NAME".UsbControl"
+/* USB host service: operations about usb start/stop */
+#define DEVICED_PATH_USBHOST DEVICED_OBJECT_PATH"/Usbhost"
+#define DEVICED_INTERFACE_USBHOST DEVICED_INTERFACE_NAME".Usbhost"
+/* Sysnoti service */
+#define DEVICED_PATH_SYSNOTI DEVICED_OBJECT_PATH"/SysNoti"
+#define DEVICED_INTERFACE_SYSNOTI DEVICED_INTERFACE_NAME".SysNoti"
+/* ExtCon service */
+#define DEVICED_PATH_EXTCON DEVICED_OBJECT_PATH"/ExtCon"
+#define DEVICED_INTERFACE_EXTCON DEVICED_INTERFACE_NAME".ExtCon"
+/* Battery service */
+#define DEVICED_PATH_BATTERY DEVICED_OBJECT_PATH"/Battery"
+#define DEVICED_INTERFACE_BATTERY DEVICED_INTERFACE_NAME".Battery"
+/* Time service */
+#define DEVICED_PATH_TIME DEVICED_OBJECT_PATH"/Time"
+#define DEVICED_INTERFACE_TIME DEVICED_INTERFACE_NAME".Time"
+/* IR service */
+#define DEVICED_PATH_IR DEVICED_OBJECT_PATH"/Ir"
+#define DEVICED_INTERFACE_IR DEVICED_INTERFACE_NAME".ir"
+/* USB_HOST_TEST service */
+#define DEVICED_PATH_USB_HOST_TEST DEVICED_OBJECT_PATH"/UsbHostTest"
+#define DEVICED_INTERFACE_USB_HOST_TEST DEVICED_INTERFACE_NAME".UsbHostTest"
+
+/* HDMICEC service: status check about gpio */
+#define DEVICED_PATH_HDMICEC DEVICED_OBJECT_PATH"/HdmiCec"
+#define DEVICED_INTERFACE_HDMICEC DEVICED_INTERFACE_NAME".HdmiCec"
+
+/* Tzip service: Archive file system */
+#define DEVICED_PATH_TZIP DEVICED_OBJECT_PATH"/Tzip"
+#define DEVICED_INTERFACE_TZIP DEVICED_INTERFACE_NAME".Tzip"
+
+/* Touch service */
+#define DEVICED_PATH_TOUCH DEVICED_OBJECT_PATH"/Touch"
+#define DEVICED_INTERFACE_TOUCH DEVICED_INTERFACE_NAME".touch"
+
+/* Thermal service: operatioins about temperature */
+#define DEVICED_PATH_TEMPERATURE DEVICED_OBJECT_PATH"/Temperature"
+#define DEVICED_INTERFACE_TEMPERATURE DEVICED_INTERFACE_NAME".temperature"
+
+/* Input service: To broadcast key input values */
+#define DEVICED_PATH_INPUT DEVICED_OBJECT_PATH"/Input"
+#define DEVICED_INTERFACE_INPUT DEVICED_INTERFACE_NAME".input"
+
+/*******************************************************************************
+ *
+ * Storage daemon (storaged)
+ *
+ ******************************************************************************/
+#define STORAGED_BUS_NAME "org.tizen.system.storage"
+#define STORAGED_OBJECT_PATH "/Org/Tizen/System/Storage"
+#define STORAGED_INTERFACE_NAME STORAGED_BUS_NAME
+
+/* Block service */
+#define STORAGED_PATH_BLOCK STORAGED_OBJECT_PATH"/Block"
+#define STORAGED_PATH_BLOCK_MANAGER STORAGED_PATH_BLOCK"/Manager"
+#define STORAGED_INTERFACE_BLOCK_MANAGER STORAGED_INTERFACE_NAME".BlockManager"
+
+/* Storage service: get storage size operatioins about storage */
+#define STORAGED_PATH_STORAGE STORAGED_OBJECT_PATH"/Storage"
+#define STORAGED_INTERFACE_STORAGE STORAGED_INTERFACE_NAME".storage"
+
+/* Lowmem service: get critical low status operations about Lowmem */
+#define STORAGED_PATH_LOWMEM STORAGED_OBJECT_PATH"/Lowmem"
+#define STORAGED_INTERFACE_LOWMEM STORAGED_INTERFACE_NAME".lowmem"
+
+
+/*******************************************************************************
+ *
+ * Vibrator daemon
+ *
+ ******************************************************************************/
+#define VIBRATOR_BUS_NAME "org.tizen.system.vibrator"
+#define VIBRATOR_OBJECT_PATH "/Org/Tizen/System/Vibrator"
+#define VIBRATOR_INTERFACE_NAME VIBRATOR_BUS_NAME
+/* Core service: get/set device status operations about device */
+#define VIBRATOR_PATH_CORE VIBRATOR_OBJECT_PATH"/Core"
+#define VIBRATOR_INTERFACE_CORE VIBRATOR_INTERFACE_NAME".core"
+
+#define VIBRATOR_PATH_HAPTIC VIBRATOR_OBJECT_PATH"/Haptic"
+#define VIBRATOR_INTERFACE_HAPTIC VIBRATOR_INTERFACE_NAME".haptic"
+
+/*
+ * Resource daemon
+ */
+#define RESOURCED_BUS_NAME "org.tizen.resourced"
+#define RESOURCED_OBJECT_PATH "/Org/Tizen/ResourceD"
+#define RESOURCED_INTERFACE_NAME RESOURCED_BUS_NAME
+
+#define RESOURCED_PATH_PROCESS RESOURCED_OBJECT_PATH"/Process"
+#define RESOURCED_INTERFACE_PROCESS RESOURCED_INTERFACE_NAME".process"
+#define RESOURCED_METHOD_ACTIVE "Active"
+
+#define RESOURCED_PATH_FREEZER RESOURCED_OBJECT_PATH"/Freezer"
+#define RESOURCED_INTERFACE_FREEZER RESOURCED_INTERFACE_NAME".freezer"
+
+#define RESOURCED_PATH_SLUGGISH RESOURCED_OBJECT_PATH"/Sluggish"
+#define RESOURCED_INTERFACE_SLUGGISH RESOURCED_INTERFACE_NAME".sluggish"
+#define RESOURCED_SIGNAL_SLUGGISH "SluggishDetected"
+
+#define RESOURCED_PATH_LOGGING RESOURCED_OBJECT_PATH"/Logging"
+#define RESOURCED_INTERFACE_LOGGING RESOURCED_INTERFACE_NAME".logging"
+/*
+ * Popup launcher
+ */
+#define POPUP_BUS_NAME "org.tizen.system.popup"
+#define POPUP_OBJECT_PATH "/Org/Tizen/System/Popup"
+#define POPUP_INTERFACE_NAME POPUP_BUS_NAME
+/* LED */
+#define POPUP_PATH_LED POPUP_OBJECT_PATH"/Led"
+#define POPUP_INTERFACE_LED POPUP_INTERFACE_NAME".Led"
+/* System */
+#define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System"
+#define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System"
+/* Notification */
+#define POPUP_PATH_NOTI POPUP_OBJECT_PATH"/Noti"
+#define POPUP_INTERFACE_NOTI POPUP_INTERFACE_NAME".Noti"
+/* Power key longpress */
+#define POPUP_PATH_POWERKEY POPUP_OBJECT_PATH"/Powerkey"
+#define POPUP_INTERFACE_POWERKEY POPUP_INTERFACE_NAME".Powerkey"
+/* Low battery */
+#define POPUP_PATH_LOWBAT POPUP_OBJECT_PATH"/Lowbat"
+#define POPUP_INTERFACE_LOWBAT POPUP_INTERFACE_NAME".Lowbat"
+/* Low memory */
+#define POPUP_PATH_LOWMEM POPUP_OBJECT_PATH"/Lowmem"
+#define POPUP_INTERFACE_LOWMEM POPUP_INTERFACE_NAME".Lowmem"
+/* MMC */
+#define POPUP_PATH_MMC POPUP_OBJECT_PATH"/Mmc"
+#define POPUP_INTERFACE_MMC POPUP_INTERFACE_NAME".Mmc"
+/* USB */
+#define POPUP_PATH_USB POPUP_OBJECT_PATH"/Usb"
+#define POPUP_INTERFACE_USB POPUP_INTERFACE_NAME".Usb"
+/* USB otg */
+#define POPUP_PATH_USBOTG POPUP_OBJECT_PATH"/Usbotg"
+#define POPUP_INTERFACE_USBOTG POPUP_INTERFACE_NAME".Usbotg"
+/* USB host */
+#define POPUP_PATH_USBHOST POPUP_OBJECT_PATH"/Usbhost"
+#define POPUP_INTERFACE_USBHOST POPUP_INTERFACE_NAME".Usbhost"
+/* System */
+#define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System"
+#define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System"
+/* Overheat */
+#define POPUP_PATH_OVERHEAT POPUP_OBJECT_PATH"/Overheat"
+#define POPUP_INTERFACE_OVERHEAT POPUP_INTERFACE_NAME".Overheat"
+/* Crash */
+#define POPUP_PATH_CRASH POPUP_OBJECT_PATH"/Crash"
+#define POPUP_INTERFACE_CRASH POPUP_INTERFACE_NAME".Crash"
+/* Servant */
+#define POPUP_PATH_SERVANT POPUP_OBJECT_PATH"/Servant"
+#define POPUP_IFACE_SERVANT POPUP_INTERFACE_NAME".Servant"
+
+#define POPUP_PATH_APP POPUP_OBJECT_PATH"/Apps"
+#define POPUP_IFACE_APP POPUP_BUS_NAME".Apps"
+
+#define POPUP_METHOD_LAUNCH "PopupLaunch"
+#define POPUP_METHOD_TERMINATE "AppTerminateByPid"
+#define POPUP_KEY_CONTENT "_SYSPOPUP_CONTENT_"
+
+/*
+ * Crash daemon
+ */
+#define CRASHD_BUS_NAME "org.tizen.system.crashd"
+#define CRASHD_OBJECT_PATH "/Org/Tizen/System/CrashD"
+#define CRASHD_INTERFACE_NAME CRASHD_BUS_NAME
+
+#define CRASHD_PATH_CRASH CRASHD_OBJECT_PATH"/Crash"
+#define CRASHD_INTERFACE_CRASH CRASHD_INTERFACE_NAME".Crash"
+
+/*
+ * Device Manager Policy Popup
+ */
+#define DEVICEMANAGER_BUS_NAME "org.tizen.DevicePolicyManager"
+#define DEVICEMANAGER_OBJECT_PATH "/org/tizen/DevicePolicyManager"
+#define DEVICEMANAGER_INTERFACE_NAME DEVICEMANAGER_BUS_NAME
+
+#define DEVICEMANAGER_PATH_POPUP DEVICEMANAGER_OBJECT_PATH"/Syspopup"
+#define DEVICEMANAGER_INTERFACE_POPUP DEVICEMANAGER_INTERFACE_NAME".Syspopup"
+
+/*
+ * Pass daemon
+ */
+#define PASS_BUS_NAME "org.tizen.system.pass"
+#define PASS_OBJECT_PATH "/Org/Tizen/System/Pass"
+#define PASS_INTERFACE_NAME PASS_BUS_NAME
+
+#define PASS_PATH_PMQOS PASS_OBJECT_PATH"/Pmqos"
+#define PASS_INTERFACE_PMQOS PASS_INTERFACE_NAME".pmqos"
+
+#define PASS_METHOD_SET_SCENARIO "SetScenario"
+
+/***************************************************************/
+/* Experimental for Specific device - contact to deviced owner */
+/***************************************************************/
+
+/* Hall service: get hall status operations about hall */
+#define DEVICED_PATH_HALL DEVICED_OBJECT_PATH"/Hall"
+#define DEVICED_INTERFACE_HALL DEVICED_INTERFACE_NAME".hall"
+/* Cpu service: operations about cpu */
+#define DEVICED_PATH_CPU DEVICED_OBJECT_PATH"/Cpu"
+#define DEVICED_INTERFACE_CPU DEVICED_INTERFACE_NAME".Cpu"
+/* PmQos service: operations about pmqos */
+#define DEVICED_PATH_PMQOS DEVICED_OBJECT_PATH"/PmQos"
+#define DEVICED_INTERFACE_PMQOS DEVICED_INTERFACE_NAME".PmQos"
+/* Apps service */
+#define DEVICED_PATH_APPS DEVICED_OBJECT_PATH"/Apps"
+#define DEVICED_INTERFACE_APPS DEVICED_INTERFACE_NAME".Apps"
+/* GPIO service: status check about gpio */
+#define DEVICED_PATH_GPIO DEVICED_OBJECT_PATH"/Gpio"
+#define DEVICED_INTERFACE_GPIO DEVICED_INTERFACE_NAME".Gpio"
+/* Board service */
+#define DEVICED_PATH_BOARD DEVICED_OBJECT_PATH"/Board"
+#define DEVICED_INTERFACE_BOARD DEVICED_INTERFACE_NAME".Board"
+/* Csa service */
+#define DEVICED_PATH_CSA DEVICED_OBJECT_PATH"/Csa"
+#define DEVICED_INTERFACE_CSA DEVICED_INTERFACE_NAME".Csa"
+/* dump service */
+#define DUMP_SERVICE_BUS_NAME "org.tizen.system.dumpservice"
+#define DUMP_SERVICE_OBJECT_PATH "/Org/Tizen/System/DumpService"
+#define DUMP_SERVICE_INTERFACE_NAME DUMP_SERVICE_BUS_NAME
+/* Coord daemon */
+#define COORD_BUS_NAME "org.tizen.system.coord"
+#define COORD_OBJECT_PATH "/Org/Tizen/System/Coord"
+#define COORD_INTERFACE_NAME COORD_BUS_NAME
+#define COORD_PATH_AUTOBRIGHTNESS COORD_OBJECT_PATH"/Autobrightness"
+#define COORD_INTERFACE_AUTOBRIGHTNESS COORD_INTERFACE_NAME".autobrightness"
+
+/* LED */
+#define POPUP_PATH_LED POPUP_OBJECT_PATH"/Led"
+#define POPUP_INTERFACE_LED POPUP_INTERFACE_NAME".Led"
+/* ODE */
+#define POPUP_PATH_ODE POPUP_OBJECT_PATH"/Ode"
+#define POPUP_INTERFACE_ODE POPUP_INTERFACE_NAME".Ode"
+/* Battery */
+#define POPUP_PATH_BATTERY POPUP_OBJECT_PATH"/Battery"
+#define POPUP_INTERFACE_BATTERY POPUP_INTERFACE_NAME".Battery"
+#define POPUP_METHOD_SCREENOFF_TTS "ScreenOffTts"
+/* Overheat Timer*/
+#define POPUP_OVERHEAT_PATH POPUP_OBJECT_PATH"/Overheat"
+#define POPUP_OVERHEAT_INTERFACE POPUP_INTERFACE_NAME".Overheat"
+
+/***********************************************/
+/* End of the Experimental for Specific device */
+/***********************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __LIBCOMMON_FILE_H__
+#define __LIBCOMMON_FILE_H__
+
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Open file, read and close
+ *
+ * @param[in] file File name
+ * @param[in] len Length of buffer
+ * @param[out] buf Buffer that stores read data
+ *
+ * @return read length if read was successful else negative error value
+ */
+int sys_read_buf(char *file, char *buf, int len);
+
+/**
+ * @brief Open file, write and close
+ *
+ * @param[in] file File name
+ * @param[out] buf Buffer that stores data to write
+ *
+ * @return zero on success otherwise negative error value
+ */
+int sys_write_buf(char *file, char *buf);
+
+/**
+ * @brief Read integer from file
+ *
+ * @param[in] fname File name
+ * @param[out] val integer value that read from file
+ *
+ * @return read length if reading integer was successful else negative error value
+ */
+int sys_get_int(char *fname, int *val);
+
+/**
+ * @brief Read string from file
+ *
+ * @param[in] fname File name
+ * @param[in] len String length
+ * @param[out] str Buffer
+ *
+ * @return zero on success otherwise negative error value
+ */
+int sys_get_str(char *fname, char *str, int len);
+
+/**
+ * @brief Write integer to file
+ *
+ * @param[in] fname File name
+ * @param[in] val Integer value to write
+ *
+ * @return zero on success otherwise negative error value
+ */
+int sys_set_int(char *fname, int val);
+
+/**
+ * @brief Write string to file
+ *
+ * @param[in] fname File name
+ * @param[out] val String to write
+ *
+ * @return zero on success otherwise negative error value
+ */
+int sys_set_str(char *fname, char *val);
+
+/**
+ * @brief Parse format from /proc/cmdline
+ *
+ * @param[in] format Format string
+ * @param[out] ... Variable argument
+ *
+ * @return zero if cannot read else the number of matched and assigned items
+ */
+int libsys_parse_cmdline_scanf(const char *format, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBCOMMON_FILE_H__ */
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __INI_PARSER_H__
+#define __INI_PARSER_H__
+
+#include <glib.h>
+
+#define MATCH(a, b) (!strncmp(a, b, strlen(a)))
+#define SET_CONF(a, b) (a = (b > 0.0 ? b : a))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct parse_result {
+ char *section;
+ union {
+ // config_parse()
+ struct {
+ char *name;
+ char *value;
+ };
+
+ // config_parse_by_section()
+ GList *props;
+ };
+};
+
+struct section_property {
+ char key[128];
+ char value[128];
+};
+
+/**
+ * @brief Parse config file and call callback\n
+ * @param[in] file_name conf file.
+ * @param[in] cb cb is called when conf file is parsed line by line.
+ * @param[in] user_data user data is passed to cb.
+ * @return 0 on success, negative if failed
+ */
+int config_parse(const char *file_name, int cb(struct parse_result *result,
+ void *user_data), void *user_data);
+
+
+/**
+ * @brief Parse config file and call callback\n
+ * @param[in] file_name conf file.
+ * @param[in] cb cb is called when conf file is parsed by section
+ * @param[in] user_data user data is passed to cb.
+ * @return 0 on success, negative if failed
+ */
+int libsys_config_parse_by_section(const char *file_name, int cb(const struct parse_result *, void *), void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __DBUS_SYSTEM_H__
+#define __DBUS_SYSTEM_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-unix.h>
+#include <gio/gunixfdlist.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "dbus-iface-system.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ const unsigned char *data;
+ int size;
+} dbus_byte;
+
+
+typedef void *dbus_handle_h;
+
+typedef void *dbus_object_handle_h;
+
+typedef struct {
+ const char *member;
+ const char *signature_in;
+ const char *signature_out;
+ GVariant *(*func) (GDBusConnection *conn,
+ const gchar *sender,
+ const gchar *path,
+ const gchar *iface,
+ const gchar *name,
+ GVariant *param,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data);
+} dbus_method_s;
+
+typedef struct {
+ dbus_object_handle_h oh;
+ const char *name;
+ const dbus_method_s *methods;
+ int nr_methods;
+} dbus_interface_u;
+
+typedef struct {
+ guint pid;
+ guint uid;
+ gchar *unique_name;
+ gchar *sec_label;
+} GDBusCredentials;
+
+#define g_variant_get_safe(gvar, signature, ...) ((gvar && (g_strcmp0(signature, g_variant_get_type_string(gvar)) == 0)) ? g_variant_get(gvar, signature, __VA_ARGS__), TRUE : FALSE)
+
+#define gdbus_new_g_variant_tuple() g_variant_new_tuple(NULL, 0)
+
+typedef void (*destroy_notified)(void *data);
+
+typedef void (*dbus_pending_cb)(GVariant *var, void *user_data, GError *err);
+
+typedef struct {
+ dbus_pending_cb func;
+ void *data;
+} pending_call_data;
+
+dbus_handle_h gdbus_get_connection (GBusType bus_type,
+ gboolean priv);
+
+int gdbus_free_connection(dbus_handle_h handle);
+
+int gdbus_request_name (dbus_handle_h handle,
+ const char *bus_name,
+ GBusNameAcquiredCallback acquired_handler,
+ GBusNameLostCallback lost_handler);
+
+int gdbus_release_name (dbus_handle_h handle,
+ const char *bus_name);
+
+int gdbus_watch_name (const char *name,
+ GBusNameAppearedCallback name_appeared_handler,
+ GBusNameVanishedCallback name_vanished_handler,
+ void *user_data,
+ GDestroyNotify user_data_free_func);
+
+void gdbus_unwatch_name (guint id);
+
+char** gdbus_get_owner_list (dbus_handle_h handle,
+ const char *bus_name);
+
+void gdbus_check_name_owner (dbus_handle_h handle,
+ const char *owner_name);
+
+int gdbus_register_object (dbus_handle_h handle,
+ const char *obj_path,
+ const dbus_interface_u *iface);
+
+int gdbus_unregister_object (dbus_handle_h handle,
+ const char *obj_path);
+
+int gdbus_add_object (dbus_handle_h handle,
+ const char *obj_path,
+ const dbus_interface_u *iface_u);
+
+int gdbus_register_object_all (dbus_handle_h handle);
+
+int dbus_handle_unregister_dbus_object (dbus_handle_h handle,
+ const char *obj_path);
+
+int dbus_handle_add_dbus_object (dbus_handle_h handle,
+ const char *obj_path,
+ const dbus_interface_u *iface_u);
+
+int dbus_handle_register_dbus_object_all (dbus_handle_h handle);
+
+int gdbus_call_sync_with_reply_int (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ int *output);
+
+int gdbus_call_sync_with_reply (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ GVariant **out_reply);
+
+int gdbus_priv_call_sync_with_reply (dbus_handle_h handle,
+ const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ GVariant **out_reply);
+
+int gdbus_call_sync_with_reply_timeout (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ GVariant **out_reply,
+ int timeout);
+
+int gdbus_call_async (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param);
+
+int gdbus_call_async_with_reply (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ dbus_pending_cb cb,
+ int timeout_msec,
+ void *data);
+
+int gdbus_call_unix_fd_list_sync_with_reply (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ GVariant *param,
+ GVariant **out_reply,
+ int *in_fdlist,
+ int in_size,
+ int **out_fdlist,
+ int *out_size);
+
+int gdbus_call_pairs_sync_with_reply_int (const char *dest,
+ const char *path,
+ const char *interface,
+ const char *method,
+ int num,
+ va_list args);
+
+int gdbus_call_pairs_async (const char *dest,
+ const char *path,
+ const char *interface,
+ const char *method,
+ int num,
+ va_list args);
+
+int gdbus_call_pairs_async_with_reply (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ int num,
+ va_list args,
+ dbus_pending_cb cb,
+ int timeout_msec,
+ void *data);
+
+int gdbus_signal_emit (const char *dest,
+ const char *path,
+ const char *iface,
+ const char *name,
+ GVariant *param);
+
+int gdbus_signal_emit_sync(const char *dest,
+ const char *path,
+ const char *iface,
+ const char *name,
+ GVariant *param);
+
+guint gdbus_signal_subscribe (dbus_handle_h handle,
+ const char *path,
+ const char *iface,
+ const char *name,
+ GDBusSignalCallback cb,
+ void *data,
+ destroy_notified free_func);
+
+void gdbus_signal_unsubscribe (dbus_handle_h handle,
+ guint id);
+
+enum ctx_quit_reason {CTX_QUIT_UNKNOWN, CTX_QUIT_NORMAL, CTX_QUIT_TIMEOUT};
+
+typedef struct {
+ guint sig_id;
+ GMainContext *context;
+ GMainLoop *loop;
+ GSource *timeout_src;
+ GVariant *param;
+ enum ctx_quit_reason quit_reason;
+ void *user_data;
+} sig_ctx;
+
+guint gdbus_signal_ctx_subscribe (dbus_handle_h handle,
+ sig_ctx *ctx,
+ const char *sender,
+ const char *path,
+ const char *iface,
+ const char *name,
+ GDBusSignalCallback cb);
+
+sig_ctx *gdbus_signal_ctx_new (void);
+
+void gdbus_signal_ctx_free (sig_ctx *ctx);
+
+int gdbus_signal_ctx_wait (sig_ctx *ctx);
+
+int gdbus_signal_ctx_add_timeout (sig_ctx *ctx,
+ int timeout);
+
+int gdbus_flush_sync(dbus_handle_h handle);
+
+int gdbus_connection_get_sender_pid (GDBusConnection *conn,
+ const char * sender);
+
+int gdbus_get_sender_pid (dbus_handle_h handle,
+ const char * sender);
+
+int gdbus_get_sender_credentials (dbus_handle_h handle,
+ const char *name,
+ GDBusCredentials *creds);
+
+gint* gdbus_get_unix_fd_list (GDBusMethodInvocation *invocation,
+ int *size);
+
+GVariant *gdbus_make_simple_array (const char *sig,
+ int *param);
+
+int check_systemd_active (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __DBUS_SYSTEMD_H__
+#define __DBUS_SYSTEMD_H__
+
+#include <libsyscommon/libgdbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int systemd_start_unit_wait_started (const char *name,
+ const char *suffix,
+ int timeout_msec);
+
+int systemd_stop_unit_wait_stopped (const char *name,
+ const char *suffix,
+ int timeout_msec);
+
+int systemd_start_unit_async (const char *name,
+ const char *suffix);
+
+int systemd_stop_unit_async (const char *name,
+ const char *suffix);
+
+GVariant *systemd_get_manager_property (const char *property);
+
+
+GVariant *systemd_get_unit_property (const char *unit,
+ const char *property);
+
+GVariant *systemd_get_service_property (const char *unit,
+ const char *property);
+
+int check_system_boot_finished(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __DBUS_SYSTEMD_H__ */
+
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __LIBCOMMON_LIST_H__
+#define __LIBCOMMON_LIST_H__
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SYS_G_LIST_PREPEND(a, b) \
+ a = g_list_prepend(a, (gpointer)b)
+#define SYS_G_LIST_APPEND(a, b) \
+ a = g_list_append(a, (gpointer)b)
+#define SYS_G_LIST_REMOVE(a, b) \
+ a = g_list_remove(a, (gpointer)b)
+#define SYS_G_LIST_REMOVE_LIST(a, b) \
+ a = g_list_delete_link(a, b)
+#define SYS_G_LIST_LENGTH(a) \
+ g_list_length(a)
+#define SYS_G_LIST_NTH(a, b) \
+ g_list_nth_data(a, b)
+#define SYS_G_LIST_FIND(a, b) \
+ g_list_find(a, (gpointer)b)
+#define SYS_G_LIST_FREE_LIST(a) \
+ g_list_free(a)
+#define SYS_G_LIST_FOREACH(head, elem, node) \
+ for (elem = head, node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = elem->next, node = NULL)
+#define SYS_G_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
+ for (elem = head, elem_next = g_list_next(elem), node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = elem_next, elem_next = g_list_next(elem), node = NULL)
+#define SYS_G_LIST_REVERSE_FOREACH(head, elem, node) \
+ for (elem = g_list_last(head), node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = g_list_previous(elem), node = NULL)
+#define SYS_G_LIST_REVERSE_FOREACH_SAFE(head, elem, elem_next, node) \
+ for (elem = g_list_last(head), elem_next = g_list_previous(elem), node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = elem_next, elem_next = g_list_previous(elem), node = NULL)
+#define SYS_G_LIST_NEXT(a) \
+ g_list_next(a)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+
+#ifndef __RESOURCE_DEVICE_H__
+#define __RESOURCE_DEVICE_H__
+
+struct syscommon_resman_resource_device {
+ char *name;
+ int type;
+
+ /*
+ * Never initialize it by user of add_resource_device().
+ * It will be initialized by add_resource_device function automatically.
+ */
+ int index;
+};
+
+int syscommon_resman_get_resource_device_count(int resource_type);
+const struct syscommon_resman_resource_device *
+syscommon_resman_find_resource_device(int resource_type, int resource_index);
+int syscommon_resman_add_resource_device(struct syscommon_resman_resource_device *resource_device);
+void syscommon_resman_remove_resource_device(struct syscommon_resman_resource_device *resource_device);
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __RESOURCE_LISTENER_H__
+#define __RESOURCE_LISTENER_H__
+
+enum syscommon_resman_listener_type {
+ SYSCOMMON_RESMAN_LISTENER_TYPE_UNKNOWN,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_EPOLL,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_UEVENT,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_TIMER,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_MAX,
+};
+
+struct syscommon_resman_resource_attribute;
+
+int syscommon_resman_register_epoll_listener(int resource_id, const struct syscommon_resman_resource_attribute *attr, int fd, void *param);
+void syscommon_resman_unregister_epoll_listener(int handle_id);
+
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+#ifndef __RESOURCE_MANAGER_H__
+#define __RESOURCE_MANAGER_H__
+
+// common.h
+
+#include <stdbool.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <glib.h>
+
+#define SYSCOMMON_RESMAN_BUFF_MAX 255
+
+enum syscommon_resman_listener_type;
+
+struct syscommon_resman_resource_attribute;
+struct syscommon_resman_resource_control;
+
+struct syscommon_resman_array_value {
+ int type;
+ int length;
+ void *data;
+};
+
+struct syscommon_resman_resource_attribute_value {
+ int type;
+ void *data;
+};
+
+struct syscommon_resman_resource_attribute_ops {
+ int (*set)(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr,
+ const void *data, int count);
+ int (*get)(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr,
+ void *data);
+ /*
+ * If .is_supported ops is not implemented, use .get ops in order to
+ * check whether the resource attribute is supported or not.
+ */
+ bool (*is_supported)(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr);
+};
+
+struct syscommon_resman_resource_attribute_monitor_ops {
+ int (*get)(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr,
+ void *data);
+ /*
+ * If .is_supported ops is not implemented, use .get ops in order to
+ * check whether the resource attribute is supported or not.
+ */
+ bool (*is_supported)(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr);
+};
+
+struct syscommon_resman_resource_attribute_listener_ops {
+ int (*init)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
+ void (*exit)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
+ void (*action)(int resource_id, const struct syscommon_resman_resource_attribute *attr,
+ void *param, enum syscommon_resman_listener_type listener_type);
+};
+
+struct syscommon_resman_resource_attribute {
+ const char name[SYSCOMMON_RESMAN_BUFF_MAX];
+ const u_int64_t id;
+ const int type;
+ const u_int64_t flag;
+ const struct syscommon_resman_resource_attribute_ops ops;
+ const struct syscommon_resman_resource_attribute_monitor_ops monitor_ops;
+ const struct syscommon_resman_resource_attribute_listener_ops listener_ops;
+};
+
+struct syscommon_resman_resource_control_ops {
+ const int (*set)(int resource_id,
+ const struct syscommon_resman_resource_control *ctrl,
+ const void *data);
+ const int (*get)(int resource_id,
+ const struct syscommon_resman_resource_control *ctrl,
+ void **data);
+};
+
+struct syscommon_resman_resource_control {
+ const char name[SYSCOMMON_RESMAN_BUFF_MAX];
+ const u_int64_t id;
+ const struct syscommon_resman_resource_control_ops ops;
+};
+
+struct syscommon_resman_resource_driver_ops {
+ int (*init)(void);
+ void (*exit)(void);
+ int (*create)(int resource_id);
+ void (*delete)(int resource_id);
+ /*
+ * If prepare_update is specified, it will be called
+ * at every update_resource_attrs().
+ */
+ int (*prepare_update)(int resource_id);
+};
+
+struct syscommon_resman_resource_driver {
+ const char *name;
+ const int type;
+ const u_int64_t flag;
+ const int num_attrs;
+ const struct syscommon_resman_resource_attribute *attrs;
+ const int num_ctrls;
+ const struct syscommon_resman_resource_control *ctrls;
+ const struct syscommon_resman_resource_driver_ops ops;
+};
+
+#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(resource_driver) \
+static void __attribute__((constructor)) __syscommon_resman_module_init(void) \
+{ \
+ syscommon_resman_add_resource_driver(resource_driver); \
+} \
+static void __attribute__((destructor)) __syscommon_resman_module_exit(void) \
+{ \
+ syscommon_resman_remove_resource_driver(resource_driver); \
+}
+
+/* Add/remove resource driver and device */
+const struct syscommon_resman_resource_driver *
+syscommon_resman_find_resource_driver(int resource_type);
+void syscommon_resman_add_resource_driver(const struct syscommon_resman_resource_driver *resource_driver);
+void syscommon_resman_remove_resource_driver(const struct syscommon_resman_resource_driver *resource_driver);
+
+/* Create/delete resource instance */
+int syscommon_resman_create_resource(int *resource_id, int resource_type);
+int syscommon_resman_monitor_create_resource(int *resource_id, int resource_type);
+void syscommon_resman_delete_resource(int resource_id);
+
+/* Set flag of the resource to given flag mask */
+int syscommon_resman_set_resource_flag(int resource_id, u_int64_t flag_mask);
+
+/* Handle resource control */
+int syscommon_resman_set_resource_control(int resource_id, u_int64_t ctrl_id, const void *data);
+const char *syscommon_resman_get_resource_control_name(int resource_id, u_int64_t ctrl_id);
+
+/* Handle resource attribute */
+int syscommon_resman_monitor_update_resource_attrs(int resource_id);
+const struct syscommon_resman_resource_attribute *
+syscommon_resman_get_resource_attr(int resource_id, u_int64_t attr_id);
+struct syscommon_resman_resource_attribute_value *
+syscommon_resman_get_resource_attr_value(int resource_id, u_int64_t attr_id);
+int syscommon_resman_is_resource_attr_supported(int resource_id, u_int64_t attr_id, bool *supported);
+int syscommon_resman_monitor_is_resource_attr_supported(int resource_id, u_int64_t attr_id, bool *supported);
+
+static inline bool
+syscommon_resman_resource_attr_supported_always(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr)
+{
+ return true;
+}
+
+int syscommon_resman_monitor_get_resource_attrs_json(int resource_id, char **json_string);
+int syscommon_resman_monitor_get_resource_attr_json(int resource_id, u_int64_t attr_id, char **json_string);
+int syscommon_resman_get_resource_list_json(char **json_string);
+
+int syscommon_resman_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t *data);
+int syscommon_resman_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data);
+int syscommon_resman_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t *data);
+int syscommon_resman_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t *data);
+int syscommon_resman_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data);
+int syscommon_resman_get_resource_attr_string(int resource_id, u_int64_t attr_id, char *data);
+int syscommon_resman_get_resource_attr_array(int resource_id, u_int64_t attr_id, struct syscommon_resman_array_value **data);
+int syscommon_resman_get_resource_attr_ptr(int resource_id, u_int64_t attr_id, void **data);
+
+int syscommon_resman_monitor_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t *data);
+int syscommon_resman_monitor_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data);
+int syscommon_resman_monitor_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t *data);
+int syscommon_resman_monitor_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t *data);
+int syscommon_resman_monitor_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data);
+int syscommon_resman_monitor_get_resource_attr_string(int resource_id, u_int64_t attr_id, char *data);
+int syscommon_resman_monitor_get_resource_attr_array(int resource_id, u_int64_t attr_id, struct syscommon_resman_array_value **data);
+int syscommon_resman_monitor_get_resource_attr_ptr(int resource_id, u_int64_t attr_id, void **data);
+
+int syscommon_resman_set_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t data);
+int syscommon_resman_set_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t data);
+int syscommon_resman_set_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t data);
+int syscommon_resman_set_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t data);
+int syscommon_resman_set_resource_attr_double(int resource_id, u_int64_t attr_id, double data);
+int syscommon_resman_set_resource_attr_string(int resource_id, u_int64_t attr_id, char data);
+int syscommon_resman_set_resource_attr_array(int resource_id, u_int64_t attr_id, void *data, int count);
+int syscommon_resman_set_resource_attr_ptr(int resource_id, u_int64_t attr_id, void *data);
+
+int syscommon_resman_set_resource_attr_interest(int resource_id, u_int64_t interest_mask);
+int syscommon_resman_unset_resource_attr_interest(int resource_id, u_int64_t interest_mask);
+bool syscommon_resman_is_resource_attr_interested(int resource_id, u_int64_t interest_mask);
+const char *syscommon_resman_get_resource_attr_name(int resource_id, u_int64_t attr_id);
+
+const char *syscommon_resman_get_resource_name(int resource_id);
+void *syscommon_resman_get_resource_privdata(int resource_id);
+int syscommon_resman_get_resource_type(int resource_id);
+
+int syscommon_resman_set_resource_privdata(int resource_id, void *priv);
+
+void syscommon_resman_init_resource_drivers(void);
+void syscommon_resman_exit_resource_drivers(void);
+#endif
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+
+#ifndef __RESOURCE_TYPE_H__
+#define __RESOURCE_TYPE_H__
+
+enum syscommon_resman_data_type {
+ SYSCOMMON_RESMAN_DATA_TYPE_UNKNOWN = 0,
+ SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ SYSCOMMON_RESMAN_DATA_TYPE_INT64,
+ SYSCOMMON_RESMAN_DATA_TYPE_UINT,
+ SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
+ SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
+ SYSCOMMON_RESMAN_DATA_TYPE_STRING,
+ SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
+ SYSCOMMON_RESMAN_DATA_TYPE_PTR,
+ SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN,
+ SYSCOMMON_RESMAN_DATA_TYPE_NUM
+};
+
+#define BIT(x) (1ULL << x)
+
+/*
+ * Resource driver flags
+ * - RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE indicates the unique device which
+ * presents only one.
+ * - RESOURCE_DRIVER_FLAG_UNCOUNTABLE incidates that resource which is not
+ * bound physical h/w.
+ */
+#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE BIT(0)
+#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_UNCOUNTABLE BIT(1)
+
+/* Resource flags */
+#define SYSCOMMON_RESMAN_RESOURCE_FLAG_PRIVATE BIT(0)
+#define SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC BIT(1)
+
+/* Flags for resource_attribute */
+#define SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE BIT(0)
+#define SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC BIT(1)
+
+#endif
#include <string.h>
#include <errno.h>
-#include "bitmap.h"
+#include "libsyscommon/bitmap.h"
#include "shared/log.h"
/**
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __SYSCOMMON_BITMAP_H__
-#define __SYSCOMMON_BITMAP_H__
-
-#include <stdbool.h>
-
-struct syscommon_bitmap;
-
-void syscommon_bitmap_set_bit(struct syscommon_bitmap *b, unsigned long nr);
-void syscommon_bitmap_clear_bit(struct syscommon_bitmap *b, unsigned long nr);
-bool syscommon_bitmap_test_bit(struct syscommon_bitmap *b, unsigned long nr);
-void syscommon_bitmap_set_all_bits(struct syscommon_bitmap *b);
-void syscommon_bitmap_clear_all_bits(struct syscommon_bitmap *b);
-int syscommon_bitmap_count_set_bit(struct syscommon_bitmap *b);
-int syscommon_bitmap_count_unset_bit(struct syscommon_bitmap *b);
-struct syscommon_bitmap* syscommon_bitmap_init_bitmap(unsigned int nbits);
-void syscommon_bitmap_deinit_bitmap(struct syscommon_bitmap *b);
-
-#endif
#include <unistd.h>
#include <system_info.h>
#include "shared/log.h"
-#include "common.h"
+#include "libsyscommon/common.h"
#define FEATURE_MODEL_NAME "http://tizen.org/system/model_name"
#define FEATURE_MODEL_NAME_EMULATOR "Emulator"
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __LIBCOMMON_COMMON_H__
-#define __LIBCOMMON_COMMON_H__
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Check if running on emulator
- *
- * @return true if running on emulator, otherwise false even on operation failure
- */
-bool libsys_is_emulator(void);
-
-/**
- * @brief Check if running on container
- *
- * @return true if running on container, otherwise false even on operation failure
- */
-bool libsys_is_container(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LIBCOMMON_COMMON_H__ */
#include <unistd.h>
#include <string.h>
-#include "file.h"
+#include "libsyscommon/file.h"
#define SHARED_H_BUF_MAX 255
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __LIBCOMMON_FILE_H__
-#define __LIBCOMMON_FILE_H__
-
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Open file, read and close
- *
- * @param[in] file File name
- * @param[in] len Length of buffer
- * @param[out] buf Buffer that stores read data
- *
- * @return read length if read was successful else negative error value
- */
-int sys_read_buf(char *file, char *buf, int len);
-
-/**
- * @brief Open file, write and close
- *
- * @param[in] file File name
- * @param[out] buf Buffer that stores data to write
- *
- * @return zero on success otherwise negative error value
- */
-int sys_write_buf(char *file, char *buf);
-
-/**
- * @brief Read integer from file
- *
- * @param[in] fname File name
- * @param[out] val integer value that read from file
- *
- * @return read length if reading integer was successful else negative error value
- */
-int sys_get_int(char *fname, int *val);
-
-/**
- * @brief Read string from file
- *
- * @param[in] fname File name
- * @param[in] len String length
- * @param[out] str Buffer
- *
- * @return zero on success otherwise negative error value
- */
-int sys_get_str(char *fname, char *str, int len);
-
-/**
- * @brief Write integer to file
- *
- * @param[in] fname File name
- * @param[in] val Integer value to write
- *
- * @return zero on success otherwise negative error value
- */
-int sys_set_int(char *fname, int val);
-
-/**
- * @brief Write string to file
- *
- * @param[in] fname File name
- * @param[out] val String to write
- *
- * @return zero on success otherwise negative error value
- */
-int sys_set_str(char *fname, char *val);
-
-/**
- * @brief Parse format from /proc/cmdline
- *
- * @param[in] format Format string
- * @param[out] ... Variable argument
- *
- * @return zero if cannot read else the number of matched and assigned items
- */
-int libsys_parse_cmdline_scanf(const char *format, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LIBCOMMON_FILE_H__ */
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "ini-parser.h"
+#include "libsyscommon/ini-parser.h"
#include "shared/log.h"
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __INI_PARSER_H__
-#define __INI_PARSER_H__
-
-#include <glib.h>
-
-#define MATCH(a, b) (!strncmp(a, b, strlen(a)))
-#define SET_CONF(a, b) (a = (b > 0.0 ? b : a))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct parse_result {
- char *section;
- union {
- // config_parse()
- struct {
- char *name;
- char *value;
- };
-
- // config_parse_by_section()
- GList *props;
- };
-};
-
-struct section_property {
- char key[128];
- char value[128];
-};
-
-/**
- * @brief Parse config file and call callback\n
- * @param[in] file_name conf file.
- * @param[in] cb cb is called when conf file is parsed line by line.
- * @param[in] user_data user data is passed to cb.
- * @return 0 on success, negative if failed
- */
-int config_parse(const char *file_name, int cb(struct parse_result *result,
- void *user_data), void *user_data);
-
-
-/**
- * @brief Parse config file and call callback\n
- * @param[in] file_name conf file.
- * @param[in] cb cb is called when conf file is parsed by section
- * @param[in] user_data user data is passed to cb.
- * @return 0 on success, negative if failed
- */
-int libsys_config_parse_by_section(const char *file_name, int cb(const struct parse_result *, void *), void *user_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __LIBCOMMON_LIST_H__
-#define __LIBCOMMON_LIST_H__
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SYS_G_LIST_PREPEND(a, b) \
- a = g_list_prepend(a, (gpointer)b)
-#define SYS_G_LIST_APPEND(a, b) \
- a = g_list_append(a, (gpointer)b)
-#define SYS_G_LIST_REMOVE(a, b) \
- a = g_list_remove(a, (gpointer)b)
-#define SYS_G_LIST_REMOVE_LIST(a, b) \
- a = g_list_delete_link(a, b)
-#define SYS_G_LIST_LENGTH(a) \
- g_list_length(a)
-#define SYS_G_LIST_NTH(a, b) \
- g_list_nth_data(a, b)
-#define SYS_G_LIST_FIND(a, b) \
- g_list_find(a, (gpointer)b)
-#define SYS_G_LIST_FREE_LIST(a) \
- g_list_free(a)
-#define SYS_G_LIST_FOREACH(head, elem, node) \
- for (elem = head, node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem->next, node = NULL)
-#define SYS_G_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
- for (elem = head, elem_next = g_list_next(elem), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem_next, elem_next = g_list_next(elem), node = NULL)
-#define SYS_G_LIST_REVERSE_FOREACH(head, elem, node) \
- for (elem = g_list_last(head), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = g_list_previous(elem), node = NULL)
-#define SYS_G_LIST_REVERSE_FOREACH_SAFE(head, elem, elem_next, node) \
- for (elem = g_list_last(head), elem_next = g_list_previous(elem), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem_next, elem_next = g_list_previous(elem), node = NULL)
-#define SYS_G_LIST_NEXT(a) \
- g_list_next(a)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __DBUS_SYSTEM_IFACE_H__
-#define __DBUS_SYSTEM_IFACE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Template
- *
-#define XXX_BUS_NAME "org.tizen.system.XXX"
-#define XXX_OBJECT_PATH "/Org/Tizen/System/XXX"
-#define XXX_INTERFACE_NAME XXX_BUS_NAME
-#define XXX_PATH_YYY XXX_OBJECT_PATH"/YYY"
-#define XXX_INTERFACE_YYY XXX_INTERFACE_NAME".YYY"
-#define XXX_SIGNAL_ZZZ "ZZZ"
-#define XXX_METHOD_ZZZ "ZZZ"
- */
-
-/*******************************************************************************
- *
- * DBus daemon
- *
- ******************************************************************************/
-#define DBUS_BUS_NAME "org.freedesktop.DBus"
-#define DBUS_OBJECT_PATH "/org/freedesktop/DBus"
-#define DBUS_INTERFACE_NAME DBUS_BUS_NAME
-#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
-
-/*******************************************************************************
- *
- * System daemon (systemd)
- *
- ******************************************************************************/
-#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1"
-#define SYSTEMD_DBUS_DEST "org.freedesktop.systemd1"
-#define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager"
-
-/*******************************************************************************
- *
- * Device daemon (deviced)
- *
- ******************************************************************************/
-#define DEVICED_BUS_NAME "org.tizen.system.deviced"
-#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
-#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
-/* Core service: get/set device status operations about device */
-#define DEVICED_PATH_CORE DEVICED_OBJECT_PATH"/Core"
-#define DEVICED_INTERFACE_CORE DEVICED_INTERFACE_NAME".core"
-/* Display service: start/stop display(pm), get/set brightness operations about display */
-#define DEVICED_PATH_DISPLAY DEVICED_OBJECT_PATH"/Display"
-#define DEVICED_INTERFACE_DISPLAY DEVICED_INTERFACE_NAME".display"
-/* Pass service: start/stop pass operations about pass */
-#define DEVICED_PATH_PASS DEVICED_OBJECT_PATH"/Pass"
-#define DEVICED_INTERFACE_PASS DEVICED_INTERFACE_NAME".pass"
-/* Power service: set resetkey disable operations about power */
-#define DEVICED_PATH_POWER DEVICED_OBJECT_PATH"/Power"
-#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".Power"
-/* Power service : signals on changing power state */
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_START "PowerChangeStateToStart"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_NORMAL "PowerChangeStateToNormal"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SLEEP "PowerChangeStateToSleep"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_POWEROFF "PowerChangeStateToPowerOff"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_REBOOT "PowerChangeStateToReboot"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_EXIT "PowerChangeStateToExit"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_EARLY "PowerChangeStateToResumingEarly"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING "PowerChangeStateToResuming"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_LATE "PowerChangeStateToResumingLate"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_EARLY "PowerChangeStateToSuspendingEarly"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING "PowerChangeStateToSuspending"
-#define DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_LATE "PowerChangeStateToSuspendingLate"
-/* Power service : signals on changing power lock state */
-#define DEVICED_SIGNAL_POWER_LOCK_STATE_CHANGED "PowerLockStateChanged"
-/* Storage service: get storage size operatioins about storage */
-#define DEVICED_PATH_STORAGE DEVICED_OBJECT_PATH"/Storage"
-#define DEVICED_INTERFACE_STORAGE DEVICED_INTERFACE_NAME".storage"
-/* ODE service: request ode popup result operatioins about storage */
-#define DEVICED_PATH_SDE DEVICED_OBJECT_PATH"/Sde"
-#define DEVICED_INTERFACE_SDE DEVICED_INTERFACE_NAME".sde"
-#define DEVICED_PATH_ODE DEVICED_OBJECT_PATH"/Ode"
-#define DEVICED_INTERFACE_ODE DEVICED_INTERFACE_NAME".ode"
-/* Poweroff service: request power off operation or get power off status operations about Poweroff(signal) */
-#define DEVICED_PATH_POWEROFF DEVICED_OBJECT_PATH"/PowerOff"
-#define DEVICED_INTERFACE_POWEROFF DEVICED_INTERFACE_NAME".PowerOff"
-/* Led service: play/stop led operations about led */
-#define DEVICED_PATH_LED DEVICED_OBJECT_PATH"/Led"
-#define DEVICED_INTERFACE_LED DEVICED_INTERFACE_NAME".Led"
-/* Process service: operations about process */
-#define DEVICED_PATH_PROCESS DEVICED_OBJECT_PATH"/Process"
-#define DEVICED_INTERFACE_PROCESS DEVICED_INTERFACE_NAME".Process"
-/* Key service: operations about key */
-#define DEVICED_PATH_KEY DEVICED_OBJECT_PATH"/Key"
-#define DEVICED_INTERFACE_KEY DEVICED_INTERFACE_NAME".Key"
-/* USB client service: change usb connection mode */
-#define DEVICED_PATH_USB DEVICED_OBJECT_PATH"/Usb"
-#define DEVICED_INTERFACE_USB DEVICED_INTERFACE_NAME".Usb"
-/* USB start/stop service: operations about usb start/stop */
-#define DEVICED_PATH_USB_CONTROL DEVICED_OBJECT_PATH"/UsbControl"
-#define DEVICED_INTERFACE_USB_CONTROL DEVICED_INTERFACE_NAME".UsbControl"
-/* USB host service: operations about usb start/stop */
-#define DEVICED_PATH_USBHOST DEVICED_OBJECT_PATH"/Usbhost"
-#define DEVICED_INTERFACE_USBHOST DEVICED_INTERFACE_NAME".Usbhost"
-/* Sysnoti service */
-#define DEVICED_PATH_SYSNOTI DEVICED_OBJECT_PATH"/SysNoti"
-#define DEVICED_INTERFACE_SYSNOTI DEVICED_INTERFACE_NAME".SysNoti"
-/* ExtCon service */
-#define DEVICED_PATH_EXTCON DEVICED_OBJECT_PATH"/ExtCon"
-#define DEVICED_INTERFACE_EXTCON DEVICED_INTERFACE_NAME".ExtCon"
-/* Battery service */
-#define DEVICED_PATH_BATTERY DEVICED_OBJECT_PATH"/Battery"
-#define DEVICED_INTERFACE_BATTERY DEVICED_INTERFACE_NAME".Battery"
-/* Time service */
-#define DEVICED_PATH_TIME DEVICED_OBJECT_PATH"/Time"
-#define DEVICED_INTERFACE_TIME DEVICED_INTERFACE_NAME".Time"
-/* IR service */
-#define DEVICED_PATH_IR DEVICED_OBJECT_PATH"/Ir"
-#define DEVICED_INTERFACE_IR DEVICED_INTERFACE_NAME".ir"
-/* USB_HOST_TEST service */
-#define DEVICED_PATH_USB_HOST_TEST DEVICED_OBJECT_PATH"/UsbHostTest"
-#define DEVICED_INTERFACE_USB_HOST_TEST DEVICED_INTERFACE_NAME".UsbHostTest"
-
-/* HDMICEC service: status check about gpio */
-#define DEVICED_PATH_HDMICEC DEVICED_OBJECT_PATH"/HdmiCec"
-#define DEVICED_INTERFACE_HDMICEC DEVICED_INTERFACE_NAME".HdmiCec"
-
-/* Tzip service: Archive file system */
-#define DEVICED_PATH_TZIP DEVICED_OBJECT_PATH"/Tzip"
-#define DEVICED_INTERFACE_TZIP DEVICED_INTERFACE_NAME".Tzip"
-
-/* Touch service */
-#define DEVICED_PATH_TOUCH DEVICED_OBJECT_PATH"/Touch"
-#define DEVICED_INTERFACE_TOUCH DEVICED_INTERFACE_NAME".touch"
-
-/* Thermal service: operatioins about temperature */
-#define DEVICED_PATH_TEMPERATURE DEVICED_OBJECT_PATH"/Temperature"
-#define DEVICED_INTERFACE_TEMPERATURE DEVICED_INTERFACE_NAME".temperature"
-
-/* Input service: To broadcast key input values */
-#define DEVICED_PATH_INPUT DEVICED_OBJECT_PATH"/Input"
-#define DEVICED_INTERFACE_INPUT DEVICED_INTERFACE_NAME".input"
-
-/*******************************************************************************
- *
- * Storage daemon (storaged)
- *
- ******************************************************************************/
-#define STORAGED_BUS_NAME "org.tizen.system.storage"
-#define STORAGED_OBJECT_PATH "/Org/Tizen/System/Storage"
-#define STORAGED_INTERFACE_NAME STORAGED_BUS_NAME
-
-/* Block service */
-#define STORAGED_PATH_BLOCK STORAGED_OBJECT_PATH"/Block"
-#define STORAGED_PATH_BLOCK_MANAGER STORAGED_PATH_BLOCK"/Manager"
-#define STORAGED_INTERFACE_BLOCK_MANAGER STORAGED_INTERFACE_NAME".BlockManager"
-
-/* Storage service: get storage size operatioins about storage */
-#define STORAGED_PATH_STORAGE STORAGED_OBJECT_PATH"/Storage"
-#define STORAGED_INTERFACE_STORAGE STORAGED_INTERFACE_NAME".storage"
-
-/* Lowmem service: get critical low status operations about Lowmem */
-#define STORAGED_PATH_LOWMEM STORAGED_OBJECT_PATH"/Lowmem"
-#define STORAGED_INTERFACE_LOWMEM STORAGED_INTERFACE_NAME".lowmem"
-
-
-/*******************************************************************************
- *
- * Vibrator daemon
- *
- ******************************************************************************/
-#define VIBRATOR_BUS_NAME "org.tizen.system.vibrator"
-#define VIBRATOR_OBJECT_PATH "/Org/Tizen/System/Vibrator"
-#define VIBRATOR_INTERFACE_NAME VIBRATOR_BUS_NAME
-/* Core service: get/set device status operations about device */
-#define VIBRATOR_PATH_CORE VIBRATOR_OBJECT_PATH"/Core"
-#define VIBRATOR_INTERFACE_CORE VIBRATOR_INTERFACE_NAME".core"
-
-#define VIBRATOR_PATH_HAPTIC VIBRATOR_OBJECT_PATH"/Haptic"
-#define VIBRATOR_INTERFACE_HAPTIC VIBRATOR_INTERFACE_NAME".haptic"
-
-/*
- * Resource daemon
- */
-#define RESOURCED_BUS_NAME "org.tizen.resourced"
-#define RESOURCED_OBJECT_PATH "/Org/Tizen/ResourceD"
-#define RESOURCED_INTERFACE_NAME RESOURCED_BUS_NAME
-
-#define RESOURCED_PATH_PROCESS RESOURCED_OBJECT_PATH"/Process"
-#define RESOURCED_INTERFACE_PROCESS RESOURCED_INTERFACE_NAME".process"
-#define RESOURCED_METHOD_ACTIVE "Active"
-
-#define RESOURCED_PATH_FREEZER RESOURCED_OBJECT_PATH"/Freezer"
-#define RESOURCED_INTERFACE_FREEZER RESOURCED_INTERFACE_NAME".freezer"
-
-#define RESOURCED_PATH_SLUGGISH RESOURCED_OBJECT_PATH"/Sluggish"
-#define RESOURCED_INTERFACE_SLUGGISH RESOURCED_INTERFACE_NAME".sluggish"
-#define RESOURCED_SIGNAL_SLUGGISH "SluggishDetected"
-
-#define RESOURCED_PATH_LOGGING RESOURCED_OBJECT_PATH"/Logging"
-#define RESOURCED_INTERFACE_LOGGING RESOURCED_INTERFACE_NAME".logging"
-/*
- * Popup launcher
- */
-#define POPUP_BUS_NAME "org.tizen.system.popup"
-#define POPUP_OBJECT_PATH "/Org/Tizen/System/Popup"
-#define POPUP_INTERFACE_NAME POPUP_BUS_NAME
-/* LED */
-#define POPUP_PATH_LED POPUP_OBJECT_PATH"/Led"
-#define POPUP_INTERFACE_LED POPUP_INTERFACE_NAME".Led"
-/* System */
-#define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System"
-#define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System"
-/* Notification */
-#define POPUP_PATH_NOTI POPUP_OBJECT_PATH"/Noti"
-#define POPUP_INTERFACE_NOTI POPUP_INTERFACE_NAME".Noti"
-/* Power key longpress */
-#define POPUP_PATH_POWERKEY POPUP_OBJECT_PATH"/Powerkey"
-#define POPUP_INTERFACE_POWERKEY POPUP_INTERFACE_NAME".Powerkey"
-/* Low battery */
-#define POPUP_PATH_LOWBAT POPUP_OBJECT_PATH"/Lowbat"
-#define POPUP_INTERFACE_LOWBAT POPUP_INTERFACE_NAME".Lowbat"
-/* Low memory */
-#define POPUP_PATH_LOWMEM POPUP_OBJECT_PATH"/Lowmem"
-#define POPUP_INTERFACE_LOWMEM POPUP_INTERFACE_NAME".Lowmem"
-/* MMC */
-#define POPUP_PATH_MMC POPUP_OBJECT_PATH"/Mmc"
-#define POPUP_INTERFACE_MMC POPUP_INTERFACE_NAME".Mmc"
-/* USB */
-#define POPUP_PATH_USB POPUP_OBJECT_PATH"/Usb"
-#define POPUP_INTERFACE_USB POPUP_INTERFACE_NAME".Usb"
-/* USB otg */
-#define POPUP_PATH_USBOTG POPUP_OBJECT_PATH"/Usbotg"
-#define POPUP_INTERFACE_USBOTG POPUP_INTERFACE_NAME".Usbotg"
-/* USB host */
-#define POPUP_PATH_USBHOST POPUP_OBJECT_PATH"/Usbhost"
-#define POPUP_INTERFACE_USBHOST POPUP_INTERFACE_NAME".Usbhost"
-/* System */
-#define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System"
-#define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System"
-/* Overheat */
-#define POPUP_PATH_OVERHEAT POPUP_OBJECT_PATH"/Overheat"
-#define POPUP_INTERFACE_OVERHEAT POPUP_INTERFACE_NAME".Overheat"
-/* Crash */
-#define POPUP_PATH_CRASH POPUP_OBJECT_PATH"/Crash"
-#define POPUP_INTERFACE_CRASH POPUP_INTERFACE_NAME".Crash"
-/* Servant */
-#define POPUP_PATH_SERVANT POPUP_OBJECT_PATH"/Servant"
-#define POPUP_IFACE_SERVANT POPUP_INTERFACE_NAME".Servant"
-
-#define POPUP_PATH_APP POPUP_OBJECT_PATH"/Apps"
-#define POPUP_IFACE_APP POPUP_BUS_NAME".Apps"
-
-#define POPUP_METHOD_LAUNCH "PopupLaunch"
-#define POPUP_METHOD_TERMINATE "AppTerminateByPid"
-#define POPUP_KEY_CONTENT "_SYSPOPUP_CONTENT_"
-
-/*
- * Crash daemon
- */
-#define CRASHD_BUS_NAME "org.tizen.system.crashd"
-#define CRASHD_OBJECT_PATH "/Org/Tizen/System/CrashD"
-#define CRASHD_INTERFACE_NAME CRASHD_BUS_NAME
-
-#define CRASHD_PATH_CRASH CRASHD_OBJECT_PATH"/Crash"
-#define CRASHD_INTERFACE_CRASH CRASHD_INTERFACE_NAME".Crash"
-
-/*
- * Device Manager Policy Popup
- */
-#define DEVICEMANAGER_BUS_NAME "org.tizen.DevicePolicyManager"
-#define DEVICEMANAGER_OBJECT_PATH "/org/tizen/DevicePolicyManager"
-#define DEVICEMANAGER_INTERFACE_NAME DEVICEMANAGER_BUS_NAME
-
-#define DEVICEMANAGER_PATH_POPUP DEVICEMANAGER_OBJECT_PATH"/Syspopup"
-#define DEVICEMANAGER_INTERFACE_POPUP DEVICEMANAGER_INTERFACE_NAME".Syspopup"
-
-/*
- * Pass daemon
- */
-#define PASS_BUS_NAME "org.tizen.system.pass"
-#define PASS_OBJECT_PATH "/Org/Tizen/System/Pass"
-#define PASS_INTERFACE_NAME PASS_BUS_NAME
-
-#define PASS_PATH_PMQOS PASS_OBJECT_PATH"/Pmqos"
-#define PASS_INTERFACE_PMQOS PASS_INTERFACE_NAME".pmqos"
-
-#define PASS_METHOD_SET_SCENARIO "SetScenario"
-
-/***************************************************************/
-/* Experimental for Specific device - contact to deviced owner */
-/***************************************************************/
-
-/* Hall service: get hall status operations about hall */
-#define DEVICED_PATH_HALL DEVICED_OBJECT_PATH"/Hall"
-#define DEVICED_INTERFACE_HALL DEVICED_INTERFACE_NAME".hall"
-/* Cpu service: operations about cpu */
-#define DEVICED_PATH_CPU DEVICED_OBJECT_PATH"/Cpu"
-#define DEVICED_INTERFACE_CPU DEVICED_INTERFACE_NAME".Cpu"
-/* PmQos service: operations about pmqos */
-#define DEVICED_PATH_PMQOS DEVICED_OBJECT_PATH"/PmQos"
-#define DEVICED_INTERFACE_PMQOS DEVICED_INTERFACE_NAME".PmQos"
-/* Apps service */
-#define DEVICED_PATH_APPS DEVICED_OBJECT_PATH"/Apps"
-#define DEVICED_INTERFACE_APPS DEVICED_INTERFACE_NAME".Apps"
-/* GPIO service: status check about gpio */
-#define DEVICED_PATH_GPIO DEVICED_OBJECT_PATH"/Gpio"
-#define DEVICED_INTERFACE_GPIO DEVICED_INTERFACE_NAME".Gpio"
-/* Board service */
-#define DEVICED_PATH_BOARD DEVICED_OBJECT_PATH"/Board"
-#define DEVICED_INTERFACE_BOARD DEVICED_INTERFACE_NAME".Board"
-/* Csa service */
-#define DEVICED_PATH_CSA DEVICED_OBJECT_PATH"/Csa"
-#define DEVICED_INTERFACE_CSA DEVICED_INTERFACE_NAME".Csa"
-/* dump service */
-#define DUMP_SERVICE_BUS_NAME "org.tizen.system.dumpservice"
-#define DUMP_SERVICE_OBJECT_PATH "/Org/Tizen/System/DumpService"
-#define DUMP_SERVICE_INTERFACE_NAME DUMP_SERVICE_BUS_NAME
-/* Coord daemon */
-#define COORD_BUS_NAME "org.tizen.system.coord"
-#define COORD_OBJECT_PATH "/Org/Tizen/System/Coord"
-#define COORD_INTERFACE_NAME COORD_BUS_NAME
-#define COORD_PATH_AUTOBRIGHTNESS COORD_OBJECT_PATH"/Autobrightness"
-#define COORD_INTERFACE_AUTOBRIGHTNESS COORD_INTERFACE_NAME".autobrightness"
-
-/* LED */
-#define POPUP_PATH_LED POPUP_OBJECT_PATH"/Led"
-#define POPUP_INTERFACE_LED POPUP_INTERFACE_NAME".Led"
-/* ODE */
-#define POPUP_PATH_ODE POPUP_OBJECT_PATH"/Ode"
-#define POPUP_INTERFACE_ODE POPUP_INTERFACE_NAME".Ode"
-/* Battery */
-#define POPUP_PATH_BATTERY POPUP_OBJECT_PATH"/Battery"
-#define POPUP_INTERFACE_BATTERY POPUP_INTERFACE_NAME".Battery"
-#define POPUP_METHOD_SCREENOFF_TTS "ScreenOffTts"
-/* Overheat Timer*/
-#define POPUP_OVERHEAT_PATH POPUP_OBJECT_PATH"/Overheat"
-#define POPUP_OVERHEAT_INTERFACE POPUP_INTERFACE_NAME".Overheat"
-
-/***********************************************/
-/* End of the Experimental for Specific device */
-/***********************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include <string.h>
#include "shared/log.h"
-#include "libgdbus.h"
+#include "libsyscommon/libgdbus.h"
/* 10 seconds */
#define DBUS_REPLY_TIMEOUT (10000)
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __DBUS_SYSTEM_H__
-#define __DBUS_SYSTEM_H__
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <glib-unix.h>
-#include <gio/gunixfdlist.h>
-#include <stdarg.h>
-#include <assert.h>
-
-#include "dbus-iface-system.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- const unsigned char *data;
- int size;
-} dbus_byte;
-
-
-typedef void *dbus_handle_h;
-
-typedef void *dbus_object_handle_h;
-
-typedef struct {
- const char *member;
- const char *signature_in;
- const char *signature_out;
- GVariant *(*func) (GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- GDBusMethodInvocation *invocation,
- gpointer user_data);
-} dbus_method_s;
-
-typedef struct {
- dbus_object_handle_h oh;
- const char *name;
- const dbus_method_s *methods;
- int nr_methods;
-} dbus_interface_u;
-
-typedef struct {
- guint pid;
- guint uid;
- gchar *unique_name;
- gchar *sec_label;
-} GDBusCredentials;
-
-#define g_variant_get_safe(gvar, signature, ...) ((gvar && (g_strcmp0(signature, g_variant_get_type_string(gvar)) == 0)) ? g_variant_get(gvar, signature, __VA_ARGS__), TRUE : FALSE)
-
-#define gdbus_new_g_variant_tuple() g_variant_new_tuple(NULL, 0)
-
-typedef void (*destroy_notified)(void *data);
-
-typedef void (*dbus_pending_cb)(GVariant *var, void *user_data, GError *err);
-
-typedef struct {
- dbus_pending_cb func;
- void *data;
-} pending_call_data;
-
-dbus_handle_h gdbus_get_connection (GBusType bus_type,
- gboolean priv);
-
-int gdbus_free_connection(dbus_handle_h handle);
-
-int gdbus_request_name (dbus_handle_h handle,
- const char *bus_name,
- GBusNameAcquiredCallback acquired_handler,
- GBusNameLostCallback lost_handler);
-
-int gdbus_release_name (dbus_handle_h handle,
- const char *bus_name);
-
-int gdbus_watch_name (const char *name,
- GBusNameAppearedCallback name_appeared_handler,
- GBusNameVanishedCallback name_vanished_handler,
- void *user_data,
- GDestroyNotify user_data_free_func);
-
-void gdbus_unwatch_name (guint id);
-
-char** gdbus_get_owner_list (dbus_handle_h handle,
- const char *bus_name);
-
-void gdbus_check_name_owner (dbus_handle_h handle,
- const char *owner_name);
-
-int gdbus_register_object (dbus_handle_h handle,
- const char *obj_path,
- const dbus_interface_u *iface);
-
-int gdbus_unregister_object (dbus_handle_h handle,
- const char *obj_path);
-
-int gdbus_add_object (dbus_handle_h handle,
- const char *obj_path,
- const dbus_interface_u *iface_u);
-
-int gdbus_register_object_all (dbus_handle_h handle);
-
-int dbus_handle_unregister_dbus_object (dbus_handle_h handle,
- const char *obj_path);
-
-int dbus_handle_add_dbus_object (dbus_handle_h handle,
- const char *obj_path,
- const dbus_interface_u *iface_u);
-
-int dbus_handle_register_dbus_object_all (dbus_handle_h handle);
-
-int gdbus_call_sync_with_reply_int (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- int *output);
-
-int gdbus_call_sync_with_reply (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- GVariant **out_reply);
-
-int gdbus_priv_call_sync_with_reply (dbus_handle_h handle,
- const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- GVariant **out_reply);
-
-int gdbus_call_sync_with_reply_timeout (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- GVariant **out_reply,
- int timeout);
-
-int gdbus_call_async (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param);
-
-int gdbus_call_async_with_reply (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- dbus_pending_cb cb,
- int timeout_msec,
- void *data);
-
-int gdbus_call_unix_fd_list_sync_with_reply (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- GVariant *param,
- GVariant **out_reply,
- int *in_fdlist,
- int in_size,
- int **out_fdlist,
- int *out_size);
-
-int gdbus_call_pairs_sync_with_reply_int (const char *dest,
- const char *path,
- const char *interface,
- const char *method,
- int num,
- va_list args);
-
-int gdbus_call_pairs_async (const char *dest,
- const char *path,
- const char *interface,
- const char *method,
- int num,
- va_list args);
-
-int gdbus_call_pairs_async_with_reply (const char *dest,
- const char *path,
- const char *iface,
- const char *method,
- int num,
- va_list args,
- dbus_pending_cb cb,
- int timeout_msec,
- void *data);
-
-int gdbus_signal_emit (const char *dest,
- const char *path,
- const char *iface,
- const char *name,
- GVariant *param);
-
-int gdbus_signal_emit_sync(const char *dest,
- const char *path,
- const char *iface,
- const char *name,
- GVariant *param);
-
-guint gdbus_signal_subscribe (dbus_handle_h handle,
- const char *path,
- const char *iface,
- const char *name,
- GDBusSignalCallback cb,
- void *data,
- destroy_notified free_func);
-
-void gdbus_signal_unsubscribe (dbus_handle_h handle,
- guint id);
-
-enum ctx_quit_reason {CTX_QUIT_UNKNOWN, CTX_QUIT_NORMAL, CTX_QUIT_TIMEOUT};
-
-typedef struct {
- guint sig_id;
- GMainContext *context;
- GMainLoop *loop;
- GSource *timeout_src;
- GVariant *param;
- enum ctx_quit_reason quit_reason;
- void *user_data;
-} sig_ctx;
-
-guint gdbus_signal_ctx_subscribe (dbus_handle_h handle,
- sig_ctx *ctx,
- const char *sender,
- const char *path,
- const char *iface,
- const char *name,
- GDBusSignalCallback cb);
-
-sig_ctx *gdbus_signal_ctx_new (void);
-
-void gdbus_signal_ctx_free (sig_ctx *ctx);
-
-int gdbus_signal_ctx_wait (sig_ctx *ctx);
-
-int gdbus_signal_ctx_add_timeout (sig_ctx *ctx,
- int timeout);
-
-int gdbus_flush_sync(dbus_handle_h handle);
-
-int gdbus_connection_get_sender_pid (GDBusConnection *conn,
- const char * sender);
-
-int gdbus_get_sender_pid (dbus_handle_h handle,
- const char * sender);
-
-int gdbus_get_sender_credentials (dbus_handle_h handle,
- const char *name,
- GDBusCredentials *creds);
-
-gint* gdbus_get_unix_fd_list (GDBusMethodInvocation *invocation,
- int *size);
-
-GVariant *gdbus_make_simple_array (const char *sig,
- int *param);
-
-int check_systemd_active (void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
-#include <libgdbus/libgdbus.h>
+#include "libsyscommon/libgdbus.h"
#include "shared/log.h"
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __DBUS_SYSTEMD_H__
-#define __DBUS_SYSTEMD_H__
-
-#include <libsyscommon/libgdbus.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int systemd_start_unit_wait_started (const char *name,
- const char *suffix,
- int timeout_msec);
-
-int systemd_stop_unit_wait_stopped (const char *name,
- const char *suffix,
- int timeout_msec);
-
-int systemd_start_unit_async (const char *name,
- const char *suffix);
-
-int systemd_stop_unit_async (const char *name,
- const char *suffix);
-
-GVariant *systemd_get_manager_property (const char *property);
-
-
-GVariant *systemd_get_unit_property (const char *unit,
- const char *property);
-
-GVariant *systemd_get_service_property (const char *unit,
- const char *property);
-
-int check_system_boot_finished(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __DBUS_SYSTEMD_H__ */
-
#include <errno.h>
#include <glib.h>
-#include "resource-device.h"
+#include "libsyscommon/resource-device.h"
static GList *g_resource_device_head;
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-
-#ifndef __RESOURCE_DEVICE_H__
-#define __RESOURCE_DEVICE_H__
-
-struct syscommon_resman_resource_device {
- char *name;
- int type;
-
- /*
- * Never initialize it by user of add_resource_device().
- * It will be initialized by add_resource_device function automatically.
- */
- int index;
-};
-
-int syscommon_resman_get_resource_device_count(int resource_type);
-const struct syscommon_resman_resource_device *
-syscommon_resman_find_resource_device(int resource_type, int resource_index);
-int syscommon_resman_add_resource_device(struct syscommon_resman_resource_device *resource_device);
-void syscommon_resman_remove_resource_device(struct syscommon_resman_resource_device *resource_device);
-
-#endif
#include <sys/epoll.h>
#include <pthread.h>
-#include "resource-manager.h"
-#include "resource-listener.h"
+#include "libsyscommon/resource-manager.h"
+#include "libsyscommon/resource-listener.h"
/* listener common */
struct listener_handle {
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __RESOURCE_LISTENER_H__
-#define __RESOURCE_LISTENER_H__
-
-enum syscommon_resman_listener_type {
- SYSCOMMON_RESMAN_LISTENER_TYPE_UNKNOWN,
- SYSCOMMON_RESMAN_LISTENER_TYPE_EPOLL,
- SYSCOMMON_RESMAN_LISTENER_TYPE_UEVENT,
- SYSCOMMON_RESMAN_LISTENER_TYPE_TIMER,
- SYSCOMMON_RESMAN_LISTENER_TYPE_MAX,
-};
-
-struct syscommon_resman_resource_attribute;
-
-int syscommon_resman_register_epoll_listener(int resource_id, const struct syscommon_resman_resource_attribute *attr, int fd, void *param);
-void syscommon_resman_unregister_epoll_listener(int handle_id);
-
-#endif
#include <sys/time.h>
#include <pthread.h>
-#include "resource-manager.h"
-#include "resource-type.h"
+#include "libsyscommon/resource-manager.h"
+#include "libsyscommon/resource-type.h"
#define BIT64_INDEX(id) (63 - __builtin_clzll(id))
#define RESOURCE_ATTR_INDEX(id) BIT64_INDEX(id)
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-#ifndef __RESOURCE_MANAGER_H__
-#define __RESOURCE_MANAGER_H__
-
-// common.h
-
-#include <stdbool.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <glib.h>
-
-#define SYSCOMMON_RESMAN_BUFF_MAX 255
-
-enum syscommon_resman_listener_type;
-
-struct syscommon_resman_resource_attribute;
-struct syscommon_resman_resource_control;
-
-struct syscommon_resman_array_value {
- int type;
- int length;
- void *data;
-};
-
-struct syscommon_resman_resource_attribute_value {
- int type;
- void *data;
-};
-
-struct syscommon_resman_resource_attribute_ops {
- int (*set)(int resource_id,
- const struct syscommon_resman_resource_attribute *attr,
- const void *data, int count);
- int (*get)(int resource_id,
- const struct syscommon_resman_resource_attribute *attr,
- void *data);
- /*
- * If .is_supported ops is not implemented, use .get ops in order to
- * check whether the resource attribute is supported or not.
- */
- bool (*is_supported)(int resource_id,
- const struct syscommon_resman_resource_attribute *attr);
-};
-
-struct syscommon_resman_resource_attribute_monitor_ops {
- int (*get)(int resource_id,
- const struct syscommon_resman_resource_attribute *attr,
- void *data);
- /*
- * If .is_supported ops is not implemented, use .get ops in order to
- * check whether the resource attribute is supported or not.
- */
- bool (*is_supported)(int resource_id,
- const struct syscommon_resman_resource_attribute *attr);
-};
-
-struct syscommon_resman_resource_attribute_listener_ops {
- int (*init)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
- void (*exit)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
- void (*action)(int resource_id, const struct syscommon_resman_resource_attribute *attr,
- void *param, enum syscommon_resman_listener_type listener_type);
-};
-
-struct syscommon_resman_resource_attribute {
- const char name[SYSCOMMON_RESMAN_BUFF_MAX];
- const u_int64_t id;
- const int type;
- const u_int64_t flag;
- const struct syscommon_resman_resource_attribute_ops ops;
- const struct syscommon_resman_resource_attribute_monitor_ops monitor_ops;
- const struct syscommon_resman_resource_attribute_listener_ops listener_ops;
-};
-
-struct syscommon_resman_resource_control_ops {
- const int (*set)(int resource_id,
- const struct syscommon_resman_resource_control *ctrl,
- const void *data);
- const int (*get)(int resource_id,
- const struct syscommon_resman_resource_control *ctrl,
- void **data);
-};
-
-struct syscommon_resman_resource_control {
- const char name[SYSCOMMON_RESMAN_BUFF_MAX];
- const u_int64_t id;
- const struct syscommon_resman_resource_control_ops ops;
-};
-
-struct syscommon_resman_resource_driver_ops {
- int (*init)(void);
- void (*exit)(void);
- int (*create)(int resource_id);
- void (*delete)(int resource_id);
- /*
- * If prepare_update is specified, it will be called
- * at every update_resource_attrs().
- */
- int (*prepare_update)(int resource_id);
-};
-
-struct syscommon_resman_resource_driver {
- const char *name;
- const int type;
- const u_int64_t flag;
- const int num_attrs;
- const struct syscommon_resman_resource_attribute *attrs;
- const int num_ctrls;
- const struct syscommon_resman_resource_control *ctrls;
- const struct syscommon_resman_resource_driver_ops ops;
-};
-
-#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_REGISTER(resource_driver) \
-static void __attribute__((constructor)) __syscommon_resman_module_init(void) \
-{ \
- syscommon_resman_add_resource_driver(resource_driver); \
-} \
-static void __attribute__((destructor)) __syscommon_resman_module_exit(void) \
-{ \
- syscommon_resman_remove_resource_driver(resource_driver); \
-}
-
-/* Add/remove resource driver and device */
-const struct syscommon_resman_resource_driver *
-syscommon_resman_find_resource_driver(int resource_type);
-void syscommon_resman_add_resource_driver(const struct syscommon_resman_resource_driver *resource_driver);
-void syscommon_resman_remove_resource_driver(const struct syscommon_resman_resource_driver *resource_driver);
-
-/* Create/delete resource instance */
-int syscommon_resman_create_resource(int *resource_id, int resource_type);
-int syscommon_resman_monitor_create_resource(int *resource_id, int resource_type);
-void syscommon_resman_delete_resource(int resource_id);
-
-/* Set flag of the resource to given flag mask */
-int syscommon_resman_set_resource_flag(int resource_id, u_int64_t flag_mask);
-
-/* Handle resource control */
-int syscommon_resman_set_resource_control(int resource_id, u_int64_t ctrl_id, const void *data);
-const char *syscommon_resman_get_resource_control_name(int resource_id, u_int64_t ctrl_id);
-
-/* Handle resource attribute */
-int syscommon_resman_monitor_update_resource_attrs(int resource_id);
-const struct syscommon_resman_resource_attribute *
-syscommon_resman_get_resource_attr(int resource_id, u_int64_t attr_id);
-struct syscommon_resman_resource_attribute_value *
-syscommon_resman_get_resource_attr_value(int resource_id, u_int64_t attr_id);
-int syscommon_resman_is_resource_attr_supported(int resource_id, u_int64_t attr_id, bool *supported);
-int syscommon_resman_monitor_is_resource_attr_supported(int resource_id, u_int64_t attr_id, bool *supported);
-
-static inline bool
-syscommon_resman_resource_attr_supported_always(int resource_id,
- const struct syscommon_resman_resource_attribute *attr)
-{
- return true;
-}
-
-int syscommon_resman_monitor_get_resource_attrs_json(int resource_id, char **json_string);
-int syscommon_resman_monitor_get_resource_attr_json(int resource_id, u_int64_t attr_id, char **json_string);
-int syscommon_resman_get_resource_list_json(char **json_string);
-
-int syscommon_resman_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t *data);
-int syscommon_resman_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data);
-int syscommon_resman_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t *data);
-int syscommon_resman_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t *data);
-int syscommon_resman_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data);
-int syscommon_resman_get_resource_attr_string(int resource_id, u_int64_t attr_id, char *data);
-int syscommon_resman_get_resource_attr_array(int resource_id, u_int64_t attr_id, struct syscommon_resman_array_value **data);
-int syscommon_resman_get_resource_attr_ptr(int resource_id, u_int64_t attr_id, void **data);
-
-int syscommon_resman_monitor_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t *data);
-int syscommon_resman_monitor_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data);
-int syscommon_resman_monitor_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t *data);
-int syscommon_resman_monitor_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t *data);
-int syscommon_resman_monitor_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data);
-int syscommon_resman_monitor_get_resource_attr_string(int resource_id, u_int64_t attr_id, char *data);
-int syscommon_resman_monitor_get_resource_attr_array(int resource_id, u_int64_t attr_id, struct syscommon_resman_array_value **data);
-int syscommon_resman_monitor_get_resource_attr_ptr(int resource_id, u_int64_t attr_id, void **data);
-
-int syscommon_resman_set_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t data);
-int syscommon_resman_set_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t data);
-int syscommon_resman_set_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t data);
-int syscommon_resman_set_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t data);
-int syscommon_resman_set_resource_attr_double(int resource_id, u_int64_t attr_id, double data);
-int syscommon_resman_set_resource_attr_string(int resource_id, u_int64_t attr_id, char data);
-int syscommon_resman_set_resource_attr_array(int resource_id, u_int64_t attr_id, void *data, int count);
-int syscommon_resman_set_resource_attr_ptr(int resource_id, u_int64_t attr_id, void *data);
-
-int syscommon_resman_set_resource_attr_interest(int resource_id, u_int64_t interest_mask);
-int syscommon_resman_unset_resource_attr_interest(int resource_id, u_int64_t interest_mask);
-bool syscommon_resman_is_resource_attr_interested(int resource_id, u_int64_t interest_mask);
-const char *syscommon_resman_get_resource_attr_name(int resource_id, u_int64_t attr_id);
-
-const char *syscommon_resman_get_resource_name(int resource_id);
-void *syscommon_resman_get_resource_privdata(int resource_id);
-int syscommon_resman_get_resource_type(int resource_id);
-
-int syscommon_resman_set_resource_privdata(int resource_id, void *priv);
-
-void syscommon_resman_init_resource_drivers(void);
-void syscommon_resman_exit_resource_drivers(void);
-#endif
+++ /dev/null
-/* MIT License
- *
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is furnished
- * to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE. */
-
-
-#ifndef __RESOURCE_TYPE_H__
-#define __RESOURCE_TYPE_H__
-
-enum syscommon_resman_data_type {
- SYSCOMMON_RESMAN_DATA_TYPE_UNKNOWN = 0,
- SYSCOMMON_RESMAN_DATA_TYPE_INT,
- SYSCOMMON_RESMAN_DATA_TYPE_INT64,
- SYSCOMMON_RESMAN_DATA_TYPE_UINT,
- SYSCOMMON_RESMAN_DATA_TYPE_UINT64,
- SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE,
- SYSCOMMON_RESMAN_DATA_TYPE_STRING,
- SYSCOMMON_RESMAN_DATA_TYPE_ARRAY,
- SYSCOMMON_RESMAN_DATA_TYPE_PTR,
- SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN,
- SYSCOMMON_RESMAN_DATA_TYPE_NUM
-};
-
-#define BIT(x) (1ULL << x)
-
-/*
- * Resource driver flags
- * - RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE indicates the unique device which
- * presents only one.
- * - RESOURCE_DRIVER_FLAG_UNCOUNTABLE incidates that resource which is not
- * bound physical h/w.
- */
-#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_COUNT_ONLY_ONE BIT(0)
-#define SYSCOMMON_RESMAN_RESOURCE_DRIVER_FLAG_UNCOUNTABLE BIT(1)
-
-/* Resource flags */
-#define SYSCOMMON_RESMAN_RESOURCE_FLAG_PRIVATE BIT(0)
-#define SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC BIT(1)
-
-/* Flags for resource_attribute */
-#define SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PRIVATE BIT(0)
-#define SYSCOMMON_RESMAN_RESOURCE_ATTR_FLAG_PUBLIC BIT(1)
-
-#endif
#include <stdbool.h>
#include <glib.h>
-#include "libcommon/file.h"
-#include "libcommon/list.h"
-#include "libcommon/ini-parser.h"
-#include "libcommon/bitmap.h"
+#include "libsyscommon/file.h"
+#include "libsyscommon/list.h"
+#include "libsyscommon/ini-parser.h"
+#include "libsyscommon/bitmap.h"
#include "../test-main.h"
#include "../test-mock.h"