diff options
-rw-r--r-- | epan/filesystem.c | 36 | ||||
-rw-r--r-- | epan/filesystem.h | 27 | ||||
-rw-r--r-- | epan/libwireshark.def | 1 | ||||
-rw-r--r-- | wsutil/file_util.c | 48 | ||||
-rw-r--r-- | wsutil/file_util.h | 6 | ||||
-rw-r--r-- | wsutil/libwsutil.def | 1 | ||||
-rw-r--r-- | wsutil/unicode-utils.c | 12 |
7 files changed, 70 insertions, 61 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 59be94627b..a662c796c4 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -882,42 +882,6 @@ get_systemfile_dir(void) #define PF_DIR ".wireshark" #endif -#ifdef _WIN32 -/* utf8 version of getenv, needed to get win32 filename paths */ -char *getenv_utf8(const char *varname) -{ - char *envvar; - wchar_t *envvarw; - wchar_t *varnamew; - - envvar = getenv(varname); - - /* since GLib 2.6 we need an utf8 version of the filename */ -#if GLIB_CHECK_VERSION(2,6,0) - /* using the wide char version of getenv should work under all circumstances */ - - /* convert given varname to utf16, needed by _wgetenv */ - varnamew = g_utf8_to_utf16(varname, -1, NULL, NULL, NULL); - if (varnamew == NULL) { - return envvar; - } - - /* use wide char version of getenv */ - envvarw = _wgetenv(varnamew); - g_free(varnamew); - if (envvarw == NULL) { - return envvar; - } - - /* convert value to utf8 */ - envvar = g_utf16_to_utf8(envvarw, -1, NULL, NULL, NULL); - /* XXX - memleak */ -#endif - - return envvar; -} -#endif - void set_profile_name(const gchar *profilename) { diff --git a/epan/filesystem.h b/epan/filesystem.h index 165159218f..065fe2fbce 100644 --- a/epan/filesystem.h +++ b/epan/filesystem.h @@ -82,7 +82,7 @@ extern const char *get_datafile_dir(void); */ extern char *get_datafile_path(const char *filename); -/* +/* * Get the personal plugin dir. */ extern char *get_plugins_pers_dir(void); @@ -96,7 +96,7 @@ extern char *get_plugins_pers_dir(void); extern const char *get_systemfile_dir(void); /* - * Set the configuration profile name to be used for storing + * Set the configuration profile name to be used for storing * personal configuration files. */ extern void set_profile_name(const gchar *profilename); @@ -128,34 +128,34 @@ extern void profile_store_persconffiles(gboolean store); */ extern gboolean profile_exists(const gchar *profilename); -/* +/* * Create a directory for the given configuration profile. * If we attempted to create it, and failed, return -1 and * set "*pf_dir_path_return" to the pathname of the directory we failed * to create (it's g_mallocated, so our caller should free it); otherwise, * return 0. */ -extern int create_persconffile_profile(const char *profilename, +extern int create_persconffile_profile(const char *profilename, char **pf_dir_path_return); -/* +/* * Delete the directory for the given configuration profile. * If we attempted to delete it, and failed, return -1 and * set "*pf_dir_path_return" to the pathname of the directory we failed * to delete (it's g_mallocated, so our caller should free it); otherwise, * return 0. */ -extern int delete_persconffile_profile(const char *profilename, +extern int delete_persconffile_profile(const char *profilename, char **pf_dir_path_return); -/* +/* * Rename the directory for the given confinguration profile. */ extern int rename_persconffile_profile(const char *fromname, const char *toname, - char **pf_from_dir_path_return, + char **pf_from_dir_path_return, char **pf_to_dir_path_return); -/* +/* * Copy files in one profile to the other. */ extern int copy_persconffile_profile(const char *toname, const char *fromname, @@ -205,7 +205,7 @@ extern const char *get_persdatafile_dir(void); */ extern char *get_tempfile_path(const char *filename); -/* +/* * process command line option belonging to the filesystem settings */ extern int filesystem_opt(int opt, const char *optstr); @@ -292,13 +292,6 @@ extern gboolean files_identical(const char *fname1, const char *fname2); extern gboolean copy_file_binary_mode(const char *from_filename, const char *to_filename); -#ifdef _WIN32 -/* - * utf8 version of getenv, needed to get win32 filename paths - */ -extern char *getenv_utf8(const char *varname); -#endif - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 2baf52fe20..ec7e3f120f 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -564,7 +564,6 @@ get_tcp_port get_tempfile_path get_udp_port get_wspython_dir -getenv_utf8 golay_decode golay_encode golay_errors diff --git a/wsutil/file_util.c b/wsutil/file_util.c index f901c99b8b..6968bdd236 100644 --- a/wsutil/file_util.c +++ b/wsutil/file_util.c @@ -446,7 +446,8 @@ ws_stdio_freopen (const gchar *filename, /* DLL loading */ static gboolean -init_dll_load_paths() { +init_dll_load_paths() +{ TCHAR path_w[MAX_PATH]; if (program_path && system_path) @@ -480,7 +481,8 @@ init_dll_load_paths() { } gboolean -ws_init_dll_search_path() { +ws_init_dll_search_path() +{ gboolean dll_dir_set = FALSE; wchar_t *program_path_w; @@ -508,7 +510,8 @@ ws_init_dll_search_path() { */ void * -ws_load_library(gchar *library_name) { +ws_load_library(gchar *library_name) +{ gchar *full_path; wchar_t *full_path_w; HMODULE dll_h; @@ -546,7 +549,8 @@ ws_load_library(gchar *library_name) { } GModule * -ws_module_open(gchar *module_name, GModuleFlags flags) { +ws_module_open(gchar *module_name, GModuleFlags flags) +{ gchar *full_path; GModule *mod; @@ -577,3 +581,39 @@ ws_module_open(gchar *module_name, GModuleFlags flags) { return NULL; } + +/* utf8 version of getenv, needed to get win32 filename paths */ +char * +getenv_utf8(const char *varname) +{ + char *envvar; + wchar_t *envvarw; + wchar_t *varnamew; + + envvar = getenv(varname); + + /* since GLib 2.6 we need an utf8 version of the filename */ +#if GLIB_CHECK_VERSION(2,6,0) + /* using the wide char version of getenv should work under all circumstances */ + + /* convert given varname to utf16, needed by _wgetenv */ + varnamew = g_utf8_to_utf16(varname, -1, NULL, NULL, NULL); + if (varnamew == NULL) { + return envvar; + } + + /* use wide char version of getenv */ + envvarw = _wgetenv(varnamew); + g_free(varnamew); + if (envvarw == NULL) { + return envvar; + } + + /* convert value to utf8 */ + envvar = g_utf16_to_utf8(envvarw, -1, NULL, NULL, NULL); + /* XXX - memleak */ +#endif + + return envvar; +} + diff --git a/wsutil/file_util.h b/wsutil/file_util.h index 798cea9261..4225fe5933 100644 --- a/wsutil/file_util.h +++ b/wsutil/file_util.h @@ -123,6 +123,12 @@ void *ws_load_library(gchar *library_name); * @return A handle to the DLL if found, NULL on failure. */ GModule *ws_module_open(gchar *module_name, GModuleFlags flags); + +/* + * utf8 version of getenv, needed to get win32 filename paths + */ +extern char *getenv_utf8(const char *varname); + #else /* _WIN32 */ #define ws_read read #define ws_write write diff --git a/wsutil/libwsutil.def b/wsutil/libwsutil.def index a0d4ed1b47..a2c3e26a5e 100644 --- a/wsutil/libwsutil.def +++ b/wsutil/libwsutil.def @@ -10,6 +10,7 @@ EXPORTS ; file_util.c +getenv_utf8 ws_stdio_fopen ws_stdio_freopen ws_stdio_mkdir diff --git a/wsutil/unicode-utils.c b/wsutil/unicode-utils.c index f011d46292..80541a5784 100644 --- a/wsutil/unicode-utils.c +++ b/wsutil/unicode-utils.c @@ -47,7 +47,9 @@ */ /* Convert from UTF-8 to UTF-16. */ -wchar_t * utf_8to16(const char *utf8str) { +wchar_t * +utf_8to16(const char *utf8str) +{ static wchar_t *utf16buf[3]; static int utf16buf_len[3]; static int idx; @@ -84,7 +86,9 @@ wchar_t * utf_8to16(const char *utf8str) { return utf16buf[idx]; } -void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...) { +void +utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...) +{ va_list ap; gchar* dst; @@ -98,7 +102,9 @@ void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, .. } /* Convert from UTF-16 to UTF-8. */ -gchar * utf_16to8(const wchar_t *utf16str) { +gchar * +utf_16to8(const wchar_t *utf16str) +{ static gchar *utf8buf[3]; static int utf8buf_len[3]; static int idx; |