From 292c51299c94985316049c2b2ad7727e33f8faf1 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 07:03:20 +0200 Subject: win32: add get_busybox_exec_path(), which is bb_busybox_exec_path This function will become bb_busybox_exec_path because there is no fixed installation location on Windows. --- include/libbb.h | 4 ++++ libbb/messages.c | 4 ++++ win32/mingw.c | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/include/libbb.h b/include/libbb.h index 0933f5385..11d7f27d3 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1562,7 +1562,11 @@ extern const char bb_path_group_file[]; extern const char bb_path_motd_file[]; extern const char bb_path_wtmp_file[]; extern const char bb_dev_null[]; +#if ENABLE_PLATFORM_MINGW32 +#define bb_busybox_exec_path get_busybox_exec_path() +#else extern const char bb_busybox_exec_path[]; +#endif /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, * but I want to save a few bytes here */ extern const char bb_PATH_root_path[]; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */ diff --git a/libbb/messages.c b/libbb/messages.c index 07b522bf4..ffa8d00cd 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -44,7 +44,11 @@ const char bb_path_group_file[] ALIGN1 = "/etc/group"; const char bb_path_gshadow_file[] ALIGN1 = "/etc/gshadow"; const char bb_path_motd_file[] ALIGN1 = "/etc/motd"; const char bb_dev_null[] ALIGN1 = "/dev/null"; +#if ENABLE_PLATFORM_MINGW32 +/* bb_busybox_exec_path is redefined to get_busybox_exec_path() in libbb.h */ +#else const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; +#endif const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, * but I want to save a few bytes here. Check libbb.h before changing! */ diff --git a/win32/mingw.c b/win32/mingw.c index b879bfbae..57573bf60 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -372,3 +372,12 @@ char *realpath(const char *path, char *resolved_path) /* FIXME: need normalization */ return strcpy(resolved_path, path); } + +const char *get_busybox_exec_path(void) +{ + static char path[PATH_MAX] = ""; + + if (!*path) + GetModuleFileName(NULL, path, PATH_MAX); + return path; +} -- cgit v1.2.3-55-g6feb