diff --git a/.gitignore b/.gitignore index bf7027d..04ee437 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ install_manifest.txt *.so.0 *.so.1 *~ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d82f8d..473b59d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,9 @@ SET(LIB_INSTALL_DIR ${PREFIX}/lib) PROJECT(app_common C) #AUX_SOURCE_DIRECTORY(src SOURCES) -SET(CAPI_APPFW_APP_COMMON_SOURCES src/app-common.c) -SET(CAPI_APPFW_APP_MANAGER_SOURCES src/app-manager.c) -SET(DLOG_SOURCES src/dlog.c) +SET(CAPI_APPFW_APP_COMMON_SOURCES src/app-common.c src/asprintf.c) +SET(CAPI_APPFW_APP_MANAGER_SOURCES src/app-manager.c src/asprintf.c) +SET(DLOG_SOURCES src/dlog.c src/asprintf.c) ADD_DEFINITIONS("-DSHARE_PREFIX=\"${SHARE_INSTALL_PREFIX}/aul\"") @@ -37,37 +37,63 @@ INCLUDE(FindPkgConfig) # Compiler flags INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" ) -#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -fPIC") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") -SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_SKIP_BUILD_RPATH true) -# Linker flags -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -fPIC") +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src) + +IF (UNIX) + IF (NOT APPLE) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" ) + ENDIF() + #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -fPIC") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + SET(CMAKE_C_FLAGS_RELEASE "-O2") + SET(CMAKE_SKIP_BUILD_RPATH true) + # Linker flags + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -fPIC") +ENDIF() + +IF (WIN32) + ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN) +ENDIF() + +ADD_DEFINITIONS(-DBUILDING_TIZENFX_STUB) + +INCLUDE(CheckSymbolExists) +INCLUDE(CheckIncludeFile) +INCLUDE(CheckTypeSize) + +SET(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +CHECK_SYMBOL_EXISTS(asprintf stdio.h HAVE_ASPRINTF) +CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF) +CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) +CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) +CHECK_INCLUDE_FILE(combaseapi.h HAVE_COMBASEAPI_H) +SET(CMAKE_REQUIRED_INCLUDES unistd.h sys/types.h) +CHECK_TYPE_SIZE(uid_t UID_T) +CHECK_TYPE_SIZE(gid_t GID_T) +CHECK_TYPE_SIZE(pid_t PID_T) +CONFIGURE_FILE(src/config.h.in src/config.h) # APP_COMMON add_library(capi-appfw-app-common SHARED ${CAPI_APPFW_APP_COMMON_SOURCES}) TARGET_LINK_LIBRARIES(capi-appfw-app-common ${libpkgs_LDFLAGS}) SET_TARGET_PROPERTIES(capi-appfw-app-common PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(capi-appfw-app-common PROPERTIES VERSION ${FULLVER}) -INSTALL(TARGETS capi-appfw-app-common DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) # APP_MANAGER add_library(capi-appfw-app-manager SHARED ${CAPI_APPFW_APP_MANAGER_SOURCES}) TARGET_LINK_LIBRARIES(capi-appfw-app-manager ${libpkgs_LDFLAGS}) SET_TARGET_PROPERTIES(capi-appfw-app-manager PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(capi-appfw-app-manager PROPERTIES VERSION ${FULLVER}) -INSTALL(TARGETS capi-appfw-app-manager DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) # DLOG add_library(dlog SHARED ${DLOG_SOURCES}) TARGET_LINK_LIBRARIES(dlog ${libpkgs_LDFLAGS}) SET_TARGET_PROPERTIES(dlog PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(dlog PROPERTIES VERSION ${FULLVER}) -INSTALL(TARGETS dlog DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) # pkgconfig file @@ -75,7 +101,7 @@ INSTALL(TARGETS dlog DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) #CONFIGURE_FILE(feature/preexec_list.txt.in feature/preexec_list.txt @ONLY) # Install headers, other files -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app_common.h DESTINATION include/app-common) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app_common.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/app-common) #INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) #INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) #INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) @@ -83,3 +109,40 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app_common.h DESTINATION inclu # tool #ADD_SUBDIRECTORY(tool) #ADD_SUBDIRECTORY(parser) + +IF (WIN32) + SET(BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin) + SET(LIB_DIR ${LIB_INSTALL_DIR}) + + IF (${CMAKE_BUILD_TYPE} MATCHES Debug) + SET(BIN_DIR ${BIN_DIR}/Debug) + SET(LIB_DIR ${LIB_DIR}/Debug) + ENDIF() + + # install binaries + INSTALL(TARGETS capi-appfw-app-common + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR} + RUNTIME DESTINATION ${BIN_DIR} + ) + INSTALL(TARGETS capi-appfw-app-manager + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR} + RUNTIME DESTINATION ${BIN_DIR} + ) + INSTALL(TARGETS dlog + LIBRARY DESTINATION ${LIB_DIR} + ARCHIVE DESTINATION ${LIB_DIR} + RUNTIME DESTINATION ${BIN_DIR} + ) + + IF (${CMAKE_BUILD_TYPE} MATCHES Debug) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/capi-appfw-app-common.pdb DESTINATION ${BIN_DIR} ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/capi-appfw-app-manager.pdb DESTINATION ${BIN_DIR} ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/dlog.pdb DESTINATION ${BIN_DIR} ) + ENDIF() +ELSE() + INSTALL(TARGETS capi-appfw-app-common DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) + INSTALL(TARGETS capi-appfw-app-manager DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) + INSTALL(TARGETS dlog DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) +ENDIF() diff --git a/README.md b/README.md index 00b99a4..be4b220 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,20 @@ TizenFX Stub ============ -Stubs to enable the TizenFX repository to build on Ubuntu +Stubs to enable the TizenFX repository to build on Ubuntu and Windows. + +Windows Build +------------- + + $ mkdir build + $ cd build + $ cmake -DCMAKE_INSTALL_PREFIX=%DALIENV_DIR% .. + +MacOS Build +------------- +```bash + $ mkdir -p build/tizen + $ cd build/tizen + $ cmake -DCMAKE_INSTALL_PREFIX=$DESKTOP_PREFIX ../.. + $ make -j8 install +``` diff --git a/src/app-common.c b/src/app-common.c index fe46c16..3dc7770 100644 --- a/src/app-common.c +++ b/src/app-common.c @@ -14,15 +14,17 @@ * limitations under the License. */ - +#ifdef __linux__ #include +#endif + #define _GNU_SOURCE #include #include #include -#define TIZEN_PATH_MAX PATH_MAX - +#include "tizenfx_stub_api.h" +#include "asprintf.h" typedef enum { @@ -86,9 +88,9 @@ struct app_event_info typedef struct app_event_info *app_event_info_h; -int app_get_id(char **id) +TIZENFX_STUB_API int app_get_id(char **id) { - static char id_buf[TIZEN_PATH_MAX] = {'A','p','p','\0'}; + static char id_buf[] = {'A','p','p','\0'}; if( id != NULL ) { @@ -98,9 +100,9 @@ int app_get_id(char **id) return APP_ERROR_INVALID_PARAMETER; } -int app_get_name(char **name) +TIZENFX_STUB_API int app_get_name(char **name) { - static char namebuf[TIZEN_PATH_MAX] = {'A','p','p','\0'}; + static char namebuf[] = {'A','p','p','\0'}; if( name != NULL ) { *name = strdup(namebuf); @@ -108,69 +110,69 @@ int app_get_name(char **name) return APP_ERROR_INVALID_PARAMETER; } -char* app_get_resource_path(void) +TIZENFX_STUB_API char* app_get_resource_path(void) { const char* path=getenv("DESKTOP_PREFIX"); + if (!path) + path = ""; char* out; int numChars = asprintf( &out, "%s/share/app", path ); return out; } -char* app_get_data_path(void) +TIZENFX_STUB_API char* app_get_data_path(void) { return app_get_resource_path(); } -char* app_get_cache_path(void) +TIZENFX_STUB_API char* app_get_cache_path(void) { return app_get_resource_path(); } -char* app_get_shared_data_path(void) +TIZENFX_STUB_API char* app_get_shared_data_path(void) { return app_get_resource_path(); } -char* app_get_shared_resource_path(void) +TIZENFX_STUB_API char* app_get_shared_resource_path(void) { return app_get_resource_path(); } -char* app_get_shared_trusted_path(void) +TIZENFX_STUB_API char* app_get_shared_trusted_path(void) { return app_get_resource_path(); } -char* app_get_tep_resource_path(void) +TIZENFX_STUB_API char* app_get_tep_resource_path(void) { return app_get_resource_path(); } -char* app_get_external_cache_path(void) +TIZENFX_STUB_API char* app_get_external_cache_path(void) { return app_get_resource_path(); } -char* app_get_external_data_path(void) +TIZENFX_STUB_API char* app_get_external_data_path(void) { return app_get_resource_path(); } -char* app_get_external_shared_data_path(void) +TIZENFX_STUB_API char* app_get_external_shared_data_path(void) { return app_get_resource_path(); } -int app_get_version(char** version) +TIZENFX_STUB_API int app_get_version(char** version) { *version = strdup("1.1.1"); return APP_ERROR_NONE; } -int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_memory_status_e *status) +TIZENFX_STUB_API int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_memory_status_e *status) { - int ret; - if (event_info == NULL || status == NULL) return APP_ERROR_INVALID_PARAMETER; @@ -181,10 +183,8 @@ int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_m return APP_ERROR_NONE; } -int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_battery_status_e *status) +TIZENFX_STUB_API int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_battery_status_e *status) { - int ret; - if (event_info == NULL || status == NULL) return APP_ERROR_INVALID_PARAMETER; @@ -195,7 +195,7 @@ int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_ return APP_ERROR_NONE; } -int app_event_get_language(app_event_info_h event_info, char **lang) +TIZENFX_STUB_API int app_event_get_language(app_event_info_h event_info, char **lang) { if (event_info == NULL || event_info->value == NULL || lang == NULL) return APP_ERROR_INVALID_PARAMETER; @@ -208,7 +208,7 @@ int app_event_get_language(app_event_info_h event_info, char **lang) return APP_ERROR_NONE; } -int app_event_get_region_format(app_event_info_h event_info, char **region) +TIZENFX_STUB_API int app_event_get_region_format(app_event_info_h event_info, char **region) { if (event_info == NULL || event_info->value == NULL || region == NULL) return APP_ERROR_INVALID_PARAMETER; @@ -221,13 +221,13 @@ int app_event_get_region_format(app_event_info_h event_info, char **region) return APP_ERROR_NONE; } -int app_resource_manager_get(app_resource_e type, const char *id, char **path) +TIZENFX_STUB_API int app_resource_manager_get(app_resource_e type, const char *id, char **path) { *path=strdup("/tmp/a"); return APP_ERROR_NONE; } -int app_event_get_device_orientation(app_event_info_h event_info, app_device_orientation_e *orientation) +TIZENFX_STUB_API int app_event_get_device_orientation(app_event_info_h event_info, app_device_orientation_e *orientation) { if (event_info == NULL || orientation == NULL) return APP_ERROR_INVALID_PARAMETER; diff --git a/src/app-manager.c b/src/app-manager.c index 57bae18..0dd79d2 100644 --- a/src/app-manager.c +++ b/src/app-manager.c @@ -14,13 +14,16 @@ * limitations under the License. */ +#include "config.h" #include #include #include + +#ifdef HAVE_UNISTD_H #include -#include -#include "app_manager_internal.h" +#endif +#include "app_manager_internal.h" struct app_context_s { diff --git a/src/app_context.h b/src/app_context.h index 4905ce3..c35c023 100644 --- a/src/app_context.h +++ b/src/app_context.h @@ -18,8 +18,7 @@ #ifndef __TIZEN_APPFW_APP_CONTEXT_H #define __TIZEN_APPFW_APP_CONTEXT_H -#include -#include +#include "unix_types.h" #define TIZEN_DEPRECATED_API diff --git a/src/app_manager.h b/src/app_manager.h index f4f09ae..bc7569f 100644 --- a/src/app_manager.h +++ b/src/app_manager.h @@ -17,11 +17,15 @@ #ifndef __TIZEN_APPFW_APP_MANAGER_H #define __TIZEN_APPFW_APP_MANAGER_H +#include "unix_types.h" + #include #include #include +#include "tizenfx_stub_api.h" + #ifdef __cplusplus extern "C" { #endif @@ -162,14 +166,14 @@ typedef bool (*app_manager_app_info_cb) (app_info_h app_info, void *user_data); * @see app_manager_unset_app_context_event_cb() * @see app_manager_app_context_event_cb() */ -int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data); +TIZENFX_STUB_API int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data); /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @see app_manager_app_context_event_cb() */ -void app_manager_unset_app_context_event_cb(void); +TIZENFX_STUB_API void app_manager_unset_app_context_event_cb(void); /** * @brief Retrieves all application contexts of running applications. @@ -185,7 +189,7 @@ void app_manager_unset_app_context_event_cb(void); * @see app_manager_app_context_cb() * @remarks In case of ui applications, sub apps in application groups will not be shown. */ -int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data); +TIZENFX_STUB_API int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data); /** @@ -203,7 +207,7 @@ int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *u * @post This function invokes app_manager_app_context_cb() for each application context. * @see app_manager_app_context_cb() */ -int app_manager_foreach_running_app_context(app_manager_app_context_cb callback, void *user_data); +TIZENFX_STUB_API int app_manager_foreach_running_app_context(app_manager_app_context_cb callback, void *user_data); /** @@ -220,7 +224,7 @@ int app_manager_foreach_running_app_context(app_manager_app_context_cb callback, * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application */ -int app_manager_get_app_context(const char *app_id, app_context_h *app_context); +TIZENFX_STUB_API int app_manager_get_app_context(const char *app_id, app_context_h *app_context); /** * @brief Gets the ID of the application for the given process ID. @@ -235,7 +239,7 @@ int app_manager_get_app_context(const char *app_id, app_context_h *app_context); * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_manager_get_app_id(pid_t pid, char **app_id); +TIZENFX_STUB_API int app_manager_get_app_id(pid_t pid, char **app_id); /** * @brief Checks whether the application with the given ID of the application is running. @@ -248,7 +252,7 @@ int app_manager_get_app_id(pid_t pid, char **app_id); * @retval #APP_MANAGER_ERROR_NONE Successful * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter */ -int app_manager_is_running(const char *app_id, bool *running); +TIZENFX_STUB_API int app_manager_is_running(const char *app_id, bool *running); /** * @brief Resumes the application. @@ -264,7 +268,7 @@ int app_manager_is_running(const char *app_id, bool *running); * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal resume error * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ -int app_manager_resume_app(app_context_h app_context); +TIZENFX_STUB_API int app_manager_resume_app(app_context_h app_context); /** * @brief Terminates the back ground application.\n @@ -282,7 +286,7 @@ int app_manager_resume_app(app_context_h app_context); * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Failed to send terminate request * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ -int app_manager_request_terminate_bg_app(app_context_h app_context); +TIZENFX_STUB_API int app_manager_request_terminate_bg_app(app_context_h app_context); /** * @brief Retrieves all installed applications information. @@ -296,7 +300,7 @@ int app_manager_request_terminate_bg_app(app_context_h app_context); * @post This function invokes app_manager_app_info_cb() for each application information. * @see app_manager_app_info_cb() */ -int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data); +TIZENFX_STUB_API int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data); /** * @brief Gets the application information for the given application ID. @@ -311,7 +315,7 @@ int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_da * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application */ -int app_manager_get_app_info(const char *app_id, app_info_h *app_info); +TIZENFX_STUB_API int app_manager_get_app_info(const char *app_id, app_info_h *app_info); /** * @brief Gets the absolute path to the shared data directory of the application specified @@ -333,7 +337,7 @@ int app_manager_get_app_info(const char *app_id, app_info_h *app_info); * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory * @retval #APP_MANAGER_ERROR_NOT_SUPPORTED Not supported */ -int app_manager_get_shared_data_path(const char *app_id, char **path); +TIZENFX_STUB_API int app_manager_get_shared_data_path(const char *app_id, char **path); /** * @brief Gets the absolute path to the shared resource directory of the application specified @@ -352,7 +356,7 @@ int app_manager_get_shared_data_path(const char *app_id, char **path); * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_manager_get_shared_resource_path(const char *app_id, char **path); +TIZENFX_STUB_API int app_manager_get_shared_resource_path(const char *app_id, char **path); /** * @brief Gets the absolute path to the shared trusted directory of the application specified @@ -372,7 +376,7 @@ int app_manager_get_shared_resource_path(const char *app_id, char **path); * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_manager_get_shared_trusted_path(const char *app_id, char **path); +TIZENFX_STUB_API int app_manager_get_shared_trusted_path(const char *app_id, char **path); /** * @deprecated Deprecated since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif. @@ -393,7 +397,7 @@ int app_manager_get_shared_trusted_path(const char *app_id, char **path); * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_manager_get_external_shared_data_path(const char *app_id, char **path) TIZEN_DEPRECATED_API; +TIZENFX_STUB_API int app_manager_get_external_shared_data_path(const char *app_id, char **path) TIZEN_DEPRECATED_API; /** * @brief Creates a app manager event handle. @@ -410,7 +414,7 @@ int app_manager_get_external_shared_data_path(const char *app_id, char **path) T * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see app_manager_event_destroy() */ -int app_manager_event_create(app_manager_event_h *handle); +TIZENFX_STUB_API int app_manager_event_create(app_manager_event_h *handle); /** * @brief Sets the event to handle to listen. @@ -430,7 +434,7 @@ int app_manager_event_create(app_manager_event_h *handle); * @see app_manager_event_status_type_e * @see app_manager_set_event_cb() */ -int app_manager_event_set_status(app_manager_event_h handle, int status_type); +TIZENFX_STUB_API int app_manager_event_set_status(app_manager_event_h handle, int status_type); /** * @brief Registers a callback function to be invoked when the app is event has occurred. @@ -451,7 +455,7 @@ int app_manager_event_set_status(app_manager_event_h handle, int status_type); * @see app_manager_event_cb() * @see app_manager_unset_event_cb() */ -int app_manager_set_event_cb(app_manager_event_h handle, +TIZENFX_STUB_API int app_manager_set_event_cb(app_manager_event_h handle, app_manager_event_cb callback, void *user_data); @@ -471,7 +475,7 @@ int app_manager_set_event_cb(app_manager_event_h handle, * @see app_manager_event_cb() * @see app_manager_set_event_cb() */ -int app_manager_unset_event_cb(app_manager_event_h handle); +TIZENFX_STUB_API int app_manager_unset_event_cb(app_manager_event_h handle); /** * @brief Destroys the app manager event handle. @@ -488,7 +492,7 @@ int app_manager_unset_event_cb(app_manager_event_h handle); * * @see app_manager_event_create() */ -int app_manager_event_destroy(app_manager_event_h handle); +TIZENFX_STUB_API int app_manager_event_destroy(app_manager_event_h handle); /** * @platform @@ -511,7 +515,7 @@ int app_manager_event_destroy(app_manager_event_h handle); * * @see app_manager_event_create() */ -int app_manager_set_app_icon(const char *app_id, const char *icon_path); +TIZENFX_STUB_API int app_manager_set_app_icon(const char *app_id, const char *icon_path); /** * @} diff --git a/src/asprintf.c b/src/asprintf.c new file mode 100644 index 0000000..e692e50 --- /dev/null +++ b/src/asprintf.c @@ -0,0 +1,78 @@ +#define _CRT_SECURE_NO_WARNINGS +#include "asprintf.h" + +#if defined(__GNUC__) && ! defined(_GNU_SOURCE) +#define _GNU_SOURCE /* needed for (v)asprintf, affects '#include ' */ +#endif +#include /* needed for malloc, free */ +#include /* needed for va_* */ + +/* + * vscprintf: + * MSVC implements this as _vscprintf, thus we just 'symlink' it here + * GNU-C-compatible compilers do not implement this, thus we implement it here + */ +#ifdef _MSC_VER +#define vscprintf _vscprintf +#endif + +#ifdef __GNUC__ +int vscprintf(const char *format, va_list ap) +{ + va_list ap_copy; + va_copy(ap_copy, ap); + int retval = vsnprintf(NULL, 0, format, ap_copy); + va_end(ap_copy); + return retval; +} +#endif + +/* + * asprintf, vasprintf: + * MSVC does not implement these, thus we implement them here + * GNU-C-compatible compilers implement these with the same names, thus we + * don't have to do anything + */ +#ifndef HAVE_VASPRINTF +int vasprintf(char **strp, const char *format, va_list ap) +{ + int len = vscprintf(format, ap); + if (len == -1) + return -1; + char *str = (char*)malloc((size_t) len + 1); + if (!str) + return -1; + int retval = vsnprintf(str, len + 1, format, ap); + if (retval == -1) { + free(str); + return -1; + } + *strp = str; + return retval; +} +#endif + +#ifndef HAVE_ASPRINTF +int asprintf(char **strp, const char *format, ...) +{ + va_list ap; + va_start(ap, format); + int retval = vasprintf(strp, format, ap); + va_end(ap); + return retval; +} +#endif + +#ifdef _WIN32 +char *co_strdup(const char *p) +{ + const size_t size = (strlen(p) + 1) * sizeof(*p); + char *ret = CoTaskMemAlloc(size); + + if (!ret) + return NULL; + + strcpy(ret, p); + return ret; +} +#endif diff --git a/src/asprintf.h b/src/asprintf.h new file mode 100644 index 0000000..fb6cfa4 --- /dev/null +++ b/src/asprintf.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "config.h" + +#ifdef HAVE_WINDOWS_H +#include +#endif + +#ifdef HAVE_COMBASEAPI_H +#include +#endif + +#ifndef HAVE_VASPRINTF +int vasprintf(char **strp, const char *format, va_list ap); +#endif + +#ifndef HAVE_ASPRINTF +int asprintf(char **strp, const char *format, ...); +#endif + +#ifdef _WIN32 +char *co_strdup(const char *p); + +/* Interopable functions with .NET Core */ +#define malloc CoTaskMemAlloc +#define free CoTaskMemFree +#define realloc CoTaskMemRealloc +#define strdup co_strdup +#endif diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..f7f8967 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,11 @@ +#pragma once + +#cmakedefine HAVE_UID_T +#cmakedefine HAVE_GID_T +#cmakedefine HAVE_PID_T +#cmakedefine HAVE_ASPRINTF +#cmakedefine HAVE_VASPRINTF +#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_WINDOWS_H +#cmakedefine HAVE_COMBASEAPI_H diff --git a/src/dlog.c b/src/dlog.c index c26db18..323d5fa 100644 --- a/src/dlog.c +++ b/src/dlog.c @@ -19,7 +19,7 @@ #include #include #include "dlog.h" - +#include "asprintf.h" int dlog_print( log_priority prio, const char *tag, const char *fmt, ... ) { @@ -28,7 +28,7 @@ int dlog_print( log_priority prio, const char *tag, const char *fmt, ... ) int numChars = 0; char *format = NULL; - if( asprintf(&format, "%s:\e[21m %s: %s\e[0m", prio==DLOG_INFO?"\e[1;34mINFO":prio==DLOG_WARN?"\e[1;33mWARN":prio==DLOG_ERROR?"\e[1;91mERROR":"", tag, fmt)) + if( asprintf(&format, "%s:\x1b[21m %s: %s\x1b[0m", prio==DLOG_INFO?"\x1b[1;34mINFO":prio==DLOG_WARN?"\x1b[1;33mWARN":prio==DLOG_ERROR?"\x1b[1;91mERROR":"", tag, fmt)) { numChars = vfprintf(stderr, format, arg); free(format); diff --git a/src/dlog.h b/src/dlog.h index 75b165a..df6e9ad 100644 --- a/src/dlog.h +++ b/src/dlog.h @@ -32,6 +32,7 @@ #include #include //#include "dlog-internal.h" +#include "tizenfx_stub_api.h" #ifdef __cplusplus extern "C" { @@ -134,7 +135,7 @@ int main(void) } * @endcode */ -int dlog_print(log_priority prio, const char *tag, const char *fmt, ...); +TIZENFX_STUB_API int dlog_print(log_priority prio, const char *tag, const char *fmt, ...); /** @@ -172,7 +173,7 @@ int main(void) } * @endcode */ -int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap); +TIZENFX_STUB_API int dlog_vprint(log_priority prio, const char *tag, const char *fmt, va_list ap); /** diff --git a/src/package-manager.h b/src/package-manager.h index 2ae34cf..e5a41f9 100644 --- a/src/package-manager.h +++ b/src/package-manager.h @@ -42,10 +42,11 @@ #ifndef __PKG_MANAGER_H__ #define __PKG_MANAGER_H__ +#include "unix_types.h" + #include #include #include -#include #ifdef __cplusplus extern "C" { diff --git a/src/tizen_error.h b/src/tizen_error.h index b1ba68d..82a5c0d 100644 --- a/src/tizen_error.h +++ b/src/tizen_error.h @@ -300,7 +300,9 @@ typedef enum { TIZEN_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of memory */ TIZEN_ERROR_PERMISSION_DENIED = -EACCES, /**< Permission denied */ TIZEN_ERROR_BAD_ADDRESS = -EFAULT, /**< Bad address */ +#ifdef ENOTBLK TIZEN_ERROR_BLOCK_DEVICE_REQUIRED = -ENOTBLK, /**< Block device required */ +#endif TIZEN_ERROR_RESOURCE_BUSY = -EBUSY, /**< Device or resource busy */ TIZEN_ERROR_FILE_EXISTS = -EEXIST, /**< File exists */ TIZEN_ERROR_CROSS_DEVICE_LINK = -EXDEV, /**< Cross-device link */ @@ -327,23 +329,41 @@ typedef enum { TIZEN_ERROR_DIR_NOT_EMPTY = -ENOTEMPTY, /**< Directory not empty */ TIZEN_ERROR_TOO_MANY_SYMBOLIC_LINKS = -ELOOP, /**< Too many symbolic links encountered */ TIZEN_ERROR_WOULD_BLOCK = TIZEN_ERROR_TRY_AGAIN, /**< Operation would block */ +#ifdef ELIBBAD TIZEN_ERROR_CORRUPTED_SHARED_LIB = -ELIBBAD, /**< Accessing a corrupted shared library */ +#endif +#ifdef ELIBSCN TIZEN_ERROR_LIB_SECTION_CORRUPTED = -ELIBSCN, /**< .lib section in a.out corrupted */ +#endif +#ifdef ELIBMAX TIZEN_ERROR_LINK_TOO_MANY_SHARED_LIB = -ELIBMAX, /**< Attempting to link in too many shared libraries */ +#endif +#ifdef ELIBEXEC TIZEN_ERROR_SHARED_LIB_EXEC = -ELIBEXEC, /**< Cannot exec a shared library directly */ +#endif TIZEN_ERROR_ILLEGAL_BYTE_SEQ = -EILSEQ, /**< Illegal byte sequence */ +#ifdef ERESTART TIZEN_ERROR_SYSTEM_CALL_RESTART = -ERESTART, /**< Interrupted system call should be restarted */ +#endif +#ifdef ESTRPIPE TIZEN_ERROR_STREAMS_PIPE = -ESTRPIPE, /**< Streams pipe error */ +#endif +#ifdef EUSERS TIZEN_ERROR_TOO_MANY_USERS = -EUSERS, /**< Too many users */ +#endif TIZEN_ERROR_NON_SOCKET = -ENOTSOCK, /**< Socket operation on non-socket */ TIZEN_ERROR_NO_DEST_ADDRESS = -EDESTADDRREQ, /**< Destination address required */ TIZEN_ERROR_MSG_TOO_LONG = -EMSGSIZE, /**< Message too long */ TIZEN_ERROR_PROTOCOL_WRONG_TYPE = -EPROTOTYPE, /**< Protocol wrong type for socket */ TIZEN_ERROR_PROTOCOL_NOT_AVALIABLE = -ENOPROTOOPT, /**< Protocol not available */ TIZEN_ERROR_PROTOCOL_NOT_SUPPORTED = -EPROTONOSUPPORT, /**< Protocol not supported */ +#ifdef ESOCKTNOSUPPORT TIZEN_ERROR_SOCKET_TYPE_NOT_SUPPORTED = -ESOCKTNOSUPPORT, /**< Socket type not supported */ +#endif TIZEN_ERROR_ENDPOINT_OPERATIN_NOT_SUPPORTED = -EOPNOTSUPP, /**< Operation not supported on transport endpoint */ +#ifdef EPFNOSUPPORT TIZEN_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED = -EPFNOSUPPORT, /**< Protocol family not supported */ +#endif TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = -EAFNOSUPPORT, /**< Address family not supported by protocol */ TIZEN_ERROR_ADDRES_IN_USE = -EADDRINUSE, /**< Address already in use */ TIZEN_ERROR_CANNOT_ASSIGN_ADDRESS = -EADDRNOTAVAIL, /**< Cannot assign requested address */ @@ -355,28 +375,60 @@ typedef enum { TIZEN_ERROR_BUFFER_SPACE = -ENOBUFS, /**< No buffer space available */ TIZEN_ERROR_ENDPOINT_CONNECTED = -EISCONN, /**< Transport endpoint is already connected */ TIZEN_ERROR_ENDPOINT_NOT_CONNECTED = -ENOTCONN, /**< Transport endpoint is not connected */ +#ifdef ESHUTDOWN TIZEN_ERROR_ENDPOINT_SHUTDOWN = -ESHUTDOWN, /**< Cannot send after transport endpoint shutdown */ +#endif +#ifdef ETOOMANYREFS TIZEN_ERROR_TOO_MANY_REFERENCES = -ETOOMANYREFS, /**< Too many references: cannot splice */ +#endif TIZEN_ERROR_CONNECTION_TIME_OUT = -ETIMEDOUT, /**< Connection timed out */ TIZEN_ERROR_CONNECTION_REFUSED = -ECONNREFUSED, /**< Connection refused */ +#ifdef EHOSTDOWN TIZEN_ERROR_HOST_DOWN = -EHOSTDOWN, /**< Host is down */ +#endif TIZEN_ERROR_NO_ROUTE_TO_HOST = -EHOSTUNREACH, /**< No route to host */ TIZEN_ERROR_ALREADY_IN_PROGRESS = -EALREADY, /**< Operation already in progress */ TIZEN_ERROR_NOW_IN_PROGRESS = -EINPROGRESS, /**< Operation now in progress */ +#ifdef ESTALE TIZEN_ERROR_STALE_NFS_FILE_HANDLE = -ESTALE, /**< Stale NFS file handle */ +#endif +#ifdef EUCLEAN TIZEN_ERROR_STRUCTURE_UNCLEAN = -EUCLEAN, /**< Structure needs cleaning */ +#endif +#ifdef ENOTNAM TIZEN_ERROR_NOT_XENIX_NAMED_TYPE_FILE = -ENOTNAM, /**< Not a XENIX named type file */ +#endif +#ifdef ENAVAIL TIZEN_ERROR_NO_XENIX_SEMAPHORES_AVAILABLE = -ENAVAIL, /**< No XENIX semaphores available */ +#endif +#ifdef EISNAM TIZEN_ERROR_IS_NAMED_TYPE_FILE = -EISNAM, /**< Is a named type file */ +#endif +#ifdef EREMOTEIO TIZEN_ERROR_REMOTE_IO = -EREMOTEIO, /**< Remote I/O error */ +#endif +#ifdef EDQUOT TIZEN_ERROR_QUOTA_EXCEEDED = -EDQUOT, /**< Quota exceeded */ +#endif +#ifdef ENOMEDIUM TIZEN_ERROR_NO_MEDIUM = -ENOMEDIUM, /**< No medium found */ +#endif +#ifdef EMEDIUMTYPE TIZEN_ERROR_WRONG_MEDIUM_TYPE = -EMEDIUMTYPE, /**< Wrong medium type */ +#endif TIZEN_ERROR_CANCELED = -ECANCELED, /**< Operation Canceled */ +#ifdef ENOKEY TIZEN_ERROR_KEY_NOT_AVAILABLE = -ENOKEY, /**< Required key not available */ +#endif +#ifdef EKEYEXPIRED TIZEN_ERROR_KEY_EXPIRED = -EKEYEXPIRED, /**< Key has expired */ +#endif +#ifdef EKEYREVOKED TIZEN_ERROR_KEY_REVOKED = -EKEYREVOKED, /**< Key has been revoked */ +#endif +#ifdef EKEYREJECTED TIZEN_ERROR_KEY_REJECTED = -EKEYREJECTED, /**< Key was rejected by service */ +#endif TIZEN_ERROR_OWNER_DEAD = -EOWNERDEAD, /**< Owner died (for robust mutexes) */ TIZEN_ERROR_UNKNOWN = TIZEN_ERROR_MIN_PLATFORM_ERROR, /**< Unknown error */ /* This is a place to add new errors here. diff --git a/src/tizenfx_stub_api.h b/src/tizenfx_stub_api.h new file mode 100644 index 0000000..1ee024c --- /dev/null +++ b/src/tizenfx_stub_api.h @@ -0,0 +1,15 @@ +#pragma once + +#ifdef BUILDING_TIZENFX_STUB +#ifdef _MSC_VER +#define TIZENFX_STUB_API __declspec(dllexport) +#else +#define TIZENFX_STUB_API +#endif +#else +#ifdef _MSC_VER +#define TIZENFX_STUB_API __declspec(dllimport) +#else +#define TIZENFX_STUB_API +#endif +#endif diff --git a/src/unix_types.h b/src/unix_types.h new file mode 100644 index 0000000..d1d06ca --- /dev/null +++ b/src/unix_types.h @@ -0,0 +1,15 @@ +#pragma once + +#include "config.h" + +#ifndef HAVE_UID_T +typedef int uid_t; +#endif + +#ifndef HAVE_GID_T +typedef int gid_t; +#endif + +#ifndef HAVE_PID_T +typedef int pid_t; +#endif