From 6ed543dbe6115170be335b42c6ba01c42568c6e8 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 11 Mar 2016 09:15:12 -0800 Subject: Remove the last remnants of U3 support. Change-Id: Ide4c177e67a77c5f9495b3b4c0f817f40e6dde30 Reviewed-on: https://code.wireshark.org/review/14425 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- wsutil/CMakeLists.txt | 1 - wsutil/Makefile.common | 4 +- wsutil/filesystem.c | 87 +++++---------------- wsutil/u3.c | 206 ------------------------------------------------- wsutil/u3.h | 46 ----------- 5 files changed, 22 insertions(+), 322 deletions(-) delete mode 100644 wsutil/u3.c delete mode 100644 wsutil/u3.h (limited to 'wsutil') diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 4a4d047c35..178e58914f 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -73,7 +73,6 @@ set(WSUTIL_FILES tempfile.c time_util.c type_util.c - u3.c unicode-utils.c ws_mempbrk.c ws_version_info.c diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common index 38256f5228..137cdf0916 100644 --- a/wsutil/Makefile.common +++ b/wsutil/Makefile.common @@ -70,9 +70,8 @@ LIBWSUTIL_COMMON_SRC = \ tempfile.c \ time_util.c \ type_util.c \ - ws_mempbrk.c \ - u3.c \ unicode-utils.c \ + ws_mempbrk.c \ ws_version_info.c # Header files that don't declare replacement functions for functions @@ -125,7 +124,6 @@ libwsutil_nonrepl_INCLUDES = \ tempfile.h \ time_util.h \ type_util.h \ - u3.h \ unicode-utils.h \ utf8_entities.h \ ws_cpuid.h \ diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index ab86d8a794..8869cec10b 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -69,8 +69,6 @@ #define PROFILES_DIR "profiles" #define PLUGINS_DIR_NAME "plugins" -#define U3_MY_CAPTURES "\\My Captures" - char *persconffile_dir = NULL; char *persdatafile_dir = NULL; char *persconfprofile = NULL; @@ -832,9 +830,6 @@ get_progfile_dir(void) const char * get_datafile_dir(void) { -#ifdef _WIN32 - char *u3deviceexecpath; -#endif static const char *datafile_dir = NULL; if (datafile_dir != NULL) @@ -842,39 +837,27 @@ get_datafile_dir(void) #ifdef _WIN32 /* - * See if we are running in a U3 environment. + * Do we have the pathname of the program? If so, assume we're + * running an installed version of the program. If we fail, + * we don't change "datafile_dir", and thus end up using the + * default. + * + * XXX - does NSIS put the installation directory into + * "\HKEY_LOCAL_MACHINE\SOFTWARE\Wireshark\InstallDir"? + * If so, perhaps we should read that from the registry, + * instead. */ - u3deviceexecpath = getenv_utf8("U3_DEVICE_EXEC_PATH"); - - if (u3deviceexecpath != NULL) { + if (progfile_dir != NULL) { /* - * We are; use the U3 device executable path. + * Yes, we do; use that. */ - datafile_dir = u3deviceexecpath; + datafile_dir = progfile_dir; } else { /* - * Do we have the pathname of the program? If so, assume we're - * running an installed version of the program. If we fail, - * we don't change "datafile_dir", and thus end up using the - * default. - * - * XXX - does NSIS put the installation directory into - * "\HKEY_LOCAL_MACHINE\SOFTWARE\Wireshark\InstallDir"? - * If so, perhaps we should read that from the registry, - * instead. + * No, we don't. + * Fall back on the default installation directory. */ - if (progfile_dir != NULL) { - /* - * Yes, we do; use that. - */ - datafile_dir = progfile_dir; - } else { - /* - * No, we don't. - * Fall back on the default installation directory. - */ - datafile_dir = "C:\\Program Files\\Wireshark\\"; - } + datafile_dir = "C:\\Program Files\\Wireshark\\"; } #else @@ -1271,18 +1254,6 @@ get_persconffile_dir_no_profile(void) return persconffile_dir; } - /* - * See if we are running in a U3 environment. - */ - env = getenv_utf8("U3_APP_DATA_PATH"); - if (env != NULL) { - /* - * We are; use the U3 application data path. - */ - persconffile_dir = g_strdup(env); - return persconffile_dir; - } - /* * Use %APPDATA% or %USERPROFILE%, so that configuration * files are stored in the user profile, rather than in @@ -1680,9 +1651,7 @@ copy_persconffile_profile(const char *toname, const char *fromname, gboolean fro /* * Get the (default) directory in which personal data is stored. * - * On Win32, this is the "My Documents" folder in the personal profile, - * except that, if we're running from a U3 device, this is the - * "$U3_DEVICE_DOCUMENT_PATH\My Captures" folder. + * On Win32, this is the "My Documents" folder in the personal profile. * On UNIX this is simply the current directory. */ /* XXX - should this and the get_home_dir() be merged? */ @@ -1690,7 +1659,6 @@ extern const char * get_persdatafile_dir(void) { #ifdef _WIN32 - char *u3devicedocumentpath; TCHAR tszPath[MAX_PATH]; /* Return the cached value, if available */ @@ -1698,27 +1666,14 @@ get_persdatafile_dir(void) return persdatafile_dir; /* - * See if we are running in a U3 environment. + * Hint: SHGetFolderPath is not available on MSVC 6 - without + * Platform SDK */ - u3devicedocumentpath = getenv_utf8("U3_DEVICE_DOCUMENT_PATH"); - - if (u3devicedocumentpath != NULL) { - /* the "My Captures" sub-directory is created (if it doesn't - exist) by u3util.exe when the U3 Wireshark is first run */ - - persdatafile_dir = g_strdup_printf("%s%s", u3devicedocumentpath, U3_MY_CAPTURES); + if (SHGetSpecialFolderPath(NULL, tszPath, CSIDL_PERSONAL, FALSE)) { + persdatafile_dir = g_utf16_to_utf8(tszPath, -1, NULL, NULL, NULL); return persdatafile_dir; } else { - /* - * Hint: SHGetFolderPath is not available on MSVC 6 - without - * Platform SDK - */ - if (SHGetSpecialFolderPath(NULL, tszPath, CSIDL_PERSONAL, FALSE)) { - persdatafile_dir = g_utf16_to_utf8(tszPath, -1, NULL, NULL, NULL); - return persdatafile_dir; - } else { - return ""; - } + return ""; } #else return ""; diff --git a/wsutil/u3.c b/wsutil/u3.c deleted file mode 100644 index 04c1c28878..0000000000 --- a/wsutil/u3.c +++ /dev/null @@ -1,206 +0,0 @@ -/* u3.c - * u3 2006 Graeme Lunt - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * Indentation logic: 2-space - */ - - -#include "config.h" - -#include -#include - -#ifdef HAVE_UNISTD_H -#include /* getpid */ -#endif - -#ifdef _WIN32 -#include /* getpid */ -#endif - -#include - -#include "u3.h" - - -#define U3_DEVICE_PATH_VAR "$U3_DEVICE_PATH" - -static char *pid_file = NULL; -static char *u3devicepath = (char*)-1; -static gchar *newpath = NULL; - -static const char *u3_change_path(const char *path, const char *old, const char *new_u3devicepath); - -gboolean u3_active(void) -{ - - return ( -#ifdef _WIN32 - getenv_utf8 -#else - getenv -#endif - ("U3_HOST_EXEC_PATH") != NULL); - -} - -void u3_runtime_info(GString *str) -{ - - char *u3devicepath_lcl = NULL; - char *u3deviceproduct = NULL; - - if((u3deviceproduct = -#ifdef _WIN32 - getenv_utf8 -#else - getenv -#endif - ("U3_DEVICE_PRODUCT")) != NULL) { - g_string_append(str, " from the "); - g_string_append(str, u3deviceproduct); - } else { - g_string_append(str, " from a "); - } - - g_string_append(str, " U3 device"); - - if((u3devicepath_lcl = -#ifdef _WIN32 - getenv_utf8 -#else - getenv -#endif - ("U3_DEVICE_PATH")) != NULL) { - g_string_append(str, " in drive "); - g_string_append(str, u3devicepath_lcl); - } - -} - -void u3_register_pid(void) -{ - int pid; - int pid_fd; - char *u3hostexecpath; - int pf_size; - - if((u3hostexecpath = -#ifdef _WIN32 - getenv_utf8 -#else - getenv -#endif - ("U3_HOST_EXEC_PATH")) != NULL) { - - pid = getpid(); - - pf_size = (int) strlen(u3hostexecpath) + 32; - pid_file = (char *)g_malloc(pf_size); - - g_snprintf(pid_file, pf_size, "%s\\%d.pid", u3hostexecpath, pid); - - pid_fd = ws_open(pid_file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); - - if(pid_fd != -1) - ws_close(pid_fd); - else { - g_free(pid_file); - pid_file = NULL; - } - } -} - - -void u3_deregister_pid(void) -{ - if(pid_file) { - /* we don't care if we succeed or fail - u3utils may have deleted the file */ - ws_unlink(pid_file); - - g_free(pid_file); - - pid_file = NULL; - - } -} - -const char *u3_expand_device_path(const char *path) -{ - return u3_change_path(path, U3_DEVICE_PATH_VAR, NULL); -} - - -const char *u3_contract_device_path(char *path) -{ - return u3_change_path(path, NULL, U3_DEVICE_PATH_VAR); -} - -static const char *u3_change_path(const char *path, const char *old, const char *new_u3devicepath) -{ - - if(u3devicepath == (char*)-1) { - /* cache the device path */ - u3devicepath = -#ifdef _WIN32 - getenv_utf8 -#else - getenv -#endif - ("U3_DEVICE_PATH"); - } - - if(new_u3devicepath == NULL) - new_u3devicepath = u3devicepath; - if(old == NULL) - old = u3devicepath; - - if(newpath != NULL) { - g_free(newpath); - newpath = NULL; - } - - if((path != NULL) && (u3devicepath != NULL) && (strncmp(path, old, strlen(old)) == 0)) { - - newpath = g_strconcat(new_u3devicepath, path + strlen(old), NULL); - - return newpath; - - } - - return path; - -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/wsutil/u3.h b/wsutil/u3.h deleted file mode 100644 index 12111b6df0..0000000000 --- a/wsutil/u3.h +++ /dev/null @@ -1,46 +0,0 @@ -/* u3.h - * u3 2006 Graeme Lunt - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __U3_H__ -#define __U3_H__ - -#include "ws_symbol_export.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -WS_DLL_PUBLIC gboolean u3_active(void); - -WS_DLL_PUBLIC void u3_runtime_info(GString *str); - -WS_DLL_PUBLIC void u3_register_pid(void); -WS_DLL_PUBLIC void u3_deregister_pid(void); - -WS_DLL_PUBLIC const char *u3_expand_device_path(const char *path); -WS_DLL_PUBLIC const char *u3_contract_device_path(char *path); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __U3_H__ */ -- cgit v1.2.3