From: Woongsuk Cho Date: Thu, 28 Jun 2018 01:03:20 +0000 (+0900) Subject: add comment for header and fix some wrong return value X-Git-Tag: accepted/tizen/unified/20180629.135931~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8125926c54715f461e951e6aae551d850a6594bc;p=platform%2Fcore%2Fdotnet%2Flauncher.git add comment for header and fix some wrong return value Change-Id: I53c885ed0f3ffbd4c95321dca57a72e92632b387 --- diff --git a/NativeLauncher/inc/dotnet_launcher_plugin.h b/NativeLauncher/inc/dotnet_launcher_plugin.h index 4e75917..21967c4 100644 --- a/NativeLauncher/inc/dotnet_launcher_plugin.h +++ b/NativeLauncher/inc/dotnet_launcher_plugin.h @@ -21,18 +21,51 @@ extern "C" { - typedef void (*plugin_initialize_ptr)(const char* mode); - typedef void (*plugin_preload_ptr)(); - typedef void (*plugin_set_app_info_ptr)( - const char* appId, - const char* managedAssemblyPath); - typedef void (*plugin_set_coreclr_info_ptr)( - void* hostHandle, - unsigned int domainId, - coreclr_create_delegate_ptr delegateFunc); - typedef char* (*plugin_get_dll_path_ptr)(); - typedef void (*plugin_before_execute_ptr)(); - typedef void (*plugin_finalize_ptr)(); + /** + * @brief initialize plugin code + * @param[in] mode mode of plugin ("default", "inhouse", etc) + */ + void plugin_initialize(const char* mode); + + /** + * @brief preload libraries. this fuction is called in the candidate process only + */ + void plugin_preload(); + + /** + * @brief set appInfo to plugin + * @param[in] appID application ID to launch + * @param[in] assemblyPath assembly path which has entry point + */ + void plugin_set_app_info(const char* appId, + const char* assemblyPath); + + /** + * @brief set coreclr info to plugin + * @param[in] hostHandle host handle of coreclr + * @param[in] domainId current domain ID + * @param[in] coreclr_create_delegate_ptr function pointer of coreclr_create_delegate + * delegate function can be used to preload managed code + */ + void plugin_set_coreclr_info(void* hostHandle, + unsigned int domainId, + coreclr_create_delegate_ptr delegateFunc); + + /** + * @brief return additional pathes to find platform assembly. + * @return ":" seperated pathes + */ + char* plugin_get_dll_path(); + + /** + * @brief function will be called before invoking managed code + */ + void plugin_before_execute(); + + /** + * @brief function will be called when application is terminated + */ + void plugin_finalize(); } #endif /* __DOTNET_LAUNCHER_PLUGIN_H__ */ diff --git a/NativeLauncher/inc/plugin_manager.h b/NativeLauncher/inc/plugin_manager.h index 94e1798..0e8cacd 100644 --- a/NativeLauncher/inc/plugin_manager.h +++ b/NativeLauncher/inc/plugin_manager.h @@ -17,12 +17,20 @@ #ifndef __PLUGIN_MANAGER_H__ #define __PLUGIN_MANAGER_H__ -#include "dotnet_launcher_plugin.h" #include "coreclr_host.h" -extern "C" -{ - +typedef void (*plugin_initialize_ptr)(const char* mode); +typedef void (*plugin_preload_ptr)(); +typedef void (*plugin_set_app_info_ptr)( + const char* appId, + const char* managedAssemblyPath); +typedef void (*plugin_set_coreclr_info_ptr)( + void* hostHandle, + unsigned int domainId, + coreclr_create_delegate_ptr delegateFunc); +typedef char* (*plugin_get_dll_path_ptr)(); +typedef void (*plugin_before_execute_ptr)(); +typedef void (*plugin_finalize_ptr)(); typedef struct PluginFunc { plugin_initialize_ptr initialize; @@ -45,6 +53,4 @@ void pluginBeforeExecute(); int initializePluginManager(const char* mode); void finalizePluginManager(); -} - #endif /* __PLUGIN_MANAGER_H__ */ diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index 534be8b..e43b63a 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -20,29 +20,91 @@ #include #include #include -#include #ifndef PATH_SEPARATOR #define PATH_SEPARATOR '/' #endif +/** + * @brief get current executable path + * return std::string path + */ std::string readSelfPath(); +/** + * @brief concat path with PATH_SEPARATOR + * @param[in] destination path + * @param[in] source path + * return std::string result path + */ std::string concatPath(const std::string& path1, const std::string& path2); + +/** + * @brief get absolute Path + * @param[in] source path + * return std::string result path + */ std::string absolutePath(const std::string& path); + +/** + * @brief get the directory of file + * @param[in] source path + * return std::string result path + */ std::string baseName(const std::string& path); + +/** + * @brief split path with ":" delimiter and put that in the vector + * @param[in] source path + * @param[out] string vector + */ void splitPath(const std::string& path, std::vector& out); -void appendPath(std::string& path1, const std::string& path2); +/** + * @brief check file is exist + * @param[in] source path + * @return bool + */ bool isFileExist(const std::string& path); -bool isManagedAssembly(const std::string& fileName); -bool isNativeImage(const std::string& fileName); +/** + * @brief check the file is managed assembly or not. + * @param[in] file path + * @return return true when the file is managed assembly. + * otherwise return false including native image case. + */ +bool isManagedAssembly(const std::string& filePath); + +/** + * @brief check the file is native image or not. + * @param[in] file path + * @return return true when the file is native image. + */ +bool isNativeImage(const std::string& filePath); +/** + * @brief find assembly files in the directories + * @param[in] directories + * @param[out] ":" seperated assembly path list + */ void assembliesInDirectory(const std::vector& directories, std::string& tpaList); +/** + * @brief function pointer for file reader + */ typedef std::function FileReader; + +/** + * @brief scan files in the given directory and run file reader function for that + * @param[in] directory + * @param[in] file reader function + * @param[in] scan depth + */ void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth); +/** + * @brief start logging thread to bypass stderr and stdout to dlog + * @return return 0 when success, otherwise return negative value. + */ int runLoggingThread(); #endif /* __UTILS_H__ */ diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index 76ac831..62f7b9c 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include "utils.h" #include "path_manager.h" @@ -236,30 +237,30 @@ int runLoggingThread() { if (setvbuf(stdout, NULL, _IOLBF, 0) < 0) { _DBG("fail to make stdout line-buffered"); - return 0; + return -1; } if (setvbuf(stderr, NULL, _IONBF, 0) < 0) { _DBG("make stderr unbuffered"); - return 0; + return -1; } /* create the pipe and redirect stdout and stderr */ if (pipe(__pfd) < 0) { _DBG("fail to create pipe for logging"); - return 0; + return -1; } // stdout if (dup2(__pfd[1], 1) == -1) { _DBG("fail to duplicate fd to stdout"); - return 0; + return -1; } // stderr if (dup2(__pfd[1], 2) == -1) { _DBG("fail to duplicate fd to stderr"); - return 0; + return -1; } close(__pfd[1]);