Introduced 'keyword' variable that is provided by emulator itself.
Removed redundant static functions.
Change-Id: Ib007914f1e66d9da4a71aeb8cb0919aea60ff6d3
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
/* misc */
char remote_bin_path[PATH_MAX] = { 0, };
-char bin_path[PATH_MAX] = { 0, };
#ifdef SUPPORT_LEGACY_ARGS
// for compatibility
char log_path[PATH_MAX] = { 0, };
const char *get_bin_path(void)
{
+ const char *bin_path = get_variable(KEYWORD_BIN_PATH);
+ // guarantee bin_path is not NULL
+ if (!bin_path) {
+ bin_path = "";
+ }
return bin_path;
}
/* misc */
extern char remote_bin_path[];
-extern char bin_path[];
#ifdef SUPPORT_LEGACY_ARGS
extern char log_path[];
#endif
}
#endif
-static void get_host_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
-{
- get_host_proxy_os(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-}
-
-static void set_bin_path(char const *const exec_argv)
-{
- set_bin_path_os(exec_argv);
-}
-
-static void make_vm_lock(void)
-{
- make_vm_lock_os();
-}
-
-static void remove_vm_lock(void)
-{
- remove_vm_lock_os();
-}
-
static void emulator_notify_exit(Notifier *notifier, void *data)
{
- remove_vm_lock();
+ remove_vm_lock_os();
int i;
for (i = 0; i < _qemu_argc; ++i) {
clean_websocket_port(SIGKILL);
#endif
- make_vm_lock();
+ make_vm_lock_os();
maru_device_hotplug_init();
sdb_setup(get_device_serial_number() + SDB_UDP_SENSOR_INDEX);
- get_host_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+ get_host_proxy_os(http_proxy, https_proxy, ftp_proxy, socks_proxy);
gchar * const tmp_str = g_strdup_printf(" sdb_port=%d,"
" http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
_qemu_argc = 0;
_qemu_argv[_qemu_argc++] = g_strdup(argv[0]);
- set_bin_path(_qemu_argv[0]);
+ set_bin_path_os(_qemu_argv[0]);
if (!load_profile_default(conf, profile)) {
return -1;
extern int _qemu_argc;
extern char **_qemu_argv;
-static void set_bin_path(gchar * exec_argv)
-{
- set_bin_path_os(exec_argv);
-}
-
static void print_system_info(void)
{
#define DIV 1024
strcat(log_path, LOGFILE);
}
-static void remove_vm_lock(void)
-{
- remove_vm_lock_os();
-}
-
static void emulator_notify_exit(Notifier *notifier, void *data)
{
- remove_vm_lock();
+ remove_vm_lock_os();
INFO("Exit emulator...\n");
}
{
legacy_parse_options(argc, argv, &_skin_argc,
&_skin_argv, &_qemu_argc, &_qemu_argv);
- set_bin_path(_qemu_argv[0]);
+ set_bin_path_os(_qemu_argv[0]);
extract_qemu_info(_qemu_argc, _qemu_argv);
INFO("Emulator start !!!\n");
break;
}
+ // strip quotes
name = g_strdup(arg1 + i);
if(!arg2) {
value = g_strdup("");
int end_index = -1;
char *str;
- // strip ""
+ // strip quotes
int len = strlen(src);
if (src[0] == '"' && src[len - 1] == '"') {
src[len - 1] = '\0';
#include "emulator_common.h"
+#define KEYWORD_BIN_PATH "_BIN_PATH_"
+
void set_variable(const char * const arg1, const char * const arg2, bool override);
char *get_variable(const char * const name);
void reset_variables(void);
char *debug = NULL;
FILE *fp = NULL;
char *tmp = NULL;
+ const char *bin_path = get_bin_path();
if (nb_debug_options != -1) {
return; /* already initialized */
}
nb_debug_options = 0;
- if (0 == strlen(bin_path)) {
- g_strlcpy(debugchfile, "DEBUGCH", MAX_FILE_LEN);
- } else {
- g_strlcat(debugchfile, bin_path, MAX_FILE_LEN);
- g_strlcat(debugchfile, "DEBUGCH", MAX_FILE_LEN);
- }
+ g_strlcpy(debugchfile, bin_path, MAX_FILE_LEN);
+ g_strlcat(debugchfile, "DEBUGCH", MAX_FILE_LEN);
fp = fopen(debugchfile, "r");
if (fp == NULL) {
void set_bin_path_os(char const *const exec_argv)
{
- gchar *file_name = NULL;
+ char *file_name = NULL;
+ char bin_path[PATH_MAX] = { 0, };
if (!exec_argv) {
return;
}
g_strlcpy(bin_path, data, strlen(data) - strlen(file_name) + 1);
-
g_strlcat(bin_path, "/", PATH_MAX);
+
+ set_variable(KEYWORD_BIN_PATH, bin_path, true);
+
free(data);
}
#include "osutil.h"
#include "emulator.h"
#include "emul_state.h"
-#include "debug_ch.h"
#include "maru_err_table.h"
#include "sdb.h"
+#include "emulator_options.h"
#ifndef CONFIG_LINUX
#error
#include "hw/virtio/maru_virtio_evdi.h"
#endif
+#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(emulator, osutil);
static int g_shmid;
void set_bin_path_os(char const *const exec_argv)
{
- gchar link_path[PATH_MAX] = { 0, };
+ char link_path[PATH_MAX] = { 0, };
+ char bin_path[PATH_MAX] = { 0, };
char *file_name = NULL;
ssize_t len = readlink("/proc/self/exe", link_path, sizeof(link_path) - 1);
g_strlcat(bin_path, "/", PATH_MAX);
+ set_variable(KEYWORD_BIN_PATH, bin_path, true);
+
#ifdef CONFIG_SPICE
g_strlcpy(remote_bin_path, link_path, strlen(link_path) - strlen(file_name) - 2);
g_strlcat(remote_bin_path, "remote/bin/", PATH_MAX);
void set_bin_path_os(char const *const exec_argv)
{
- gchar link_path[PATH_MAX] = { 0, };
- gchar *file_name = NULL;
+ char link_path[PATH_MAX] = { 0, };
+ char bin_path[PATH_MAX] = { 0, };
+ char *file_name = NULL;
if (!GetModuleFileName(NULL, link_path, PATH_MAX)) {
return;
file_name = g_strrstr(link_path, "\\");
g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1);
-
g_strlcat(bin_path, "\\", PATH_MAX);
+
+ set_variable(KEYWORD_BIN_PATH, bin_path, true);
}
int get_number_of_processors(void)