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__ */
#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;
int initializePluginManager(const char* mode);
void finalizePluginManager();
-}
-
#endif /* __PLUGIN_MANAGER_H__ */
#include <string>
#include <vector>
#include <functional>
-#include <map>
#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<std::string>& 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<std::string>& directories, std::string& tpaList);
+/**
+ * @brief function pointer for file reader
+ */
typedef std::function<void (const std::string&, const char*)> 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__ */
#include <vector>
#include <iterator>
#include <sstream>
+#include <map>
#include "utils.h"
#include "path_manager.h"
{
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]);