help_url.c
packet_list_utils.c
iface_lists.c
+ persfilepath_opt.c
preference_utils.c
profile.c
recent.c
iface_lists.c \
help_url.c \
packet_list_utils.c \
+ persfilepath_opt.c \
preference_utils.c \
profile.c \
recent.c \
packet_list_utils.h \
iface_lists.h \
main_statusbar.h \
+ persfilepath_opt.h \
preference_utils.h \
profile.h \
progress_dlg.h \
#endif /* HAVE_LIBPORTAUDIO */
#include <wsutil/crash_info.h>
-#include <wsutil/u3.h>
-#include <wsutil/privileges.h>
+#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
+#include <wsutil/privileges.h>
+#include <wsutil/u3.h>
#include <wiretap/merge.h>
#include <epan/epan.h>
-#include <wsutil/filesystem.h>
#include <epan/epan_dissect.h>
#include <epan/timestamp.h>
#include <epan/plugins.h>
#include "ui/alert_box.h"
#include "ui/main_statusbar.h"
+#include "ui/persfilepath_opt.h"
#include "ui/preference_utils.h"
#include "ui/recent.h"
#include "ui/recent_utils.h"
set_stdin_capture(TRUE);
break;
#endif
- case 'P': /* Path settings - change these before the Preferences and alike are processed */
- status = filesystem_opt(opt, optarg);
- if(status != 0) {
+ case 'P': /* Personal file directory path settings - change these before the Preferences and alike are processed */
+ if (!persfilepath_opt(opt, optarg)) {
cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
- exit(status);
+ exit(2);
}
break;
case 'v': /* Show version and exit */
--- /dev/null
+/* persfilepath_opt.c
+ * Routines to handle command-line options to set paths for directories
+ * containing personal files (configuration, saved captures)
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * 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.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <wsutil/filesystem.h>
+
+/*
+ * process command line option that affects the paths of the directories
+ * used for personal files (configuration, saved captures)
+ */
+gboolean
+persfilepath_opt(int opt _U_, const char *optstr)
+{
+ gchar *p, *colonp;
+
+ colonp = strchr(optstr, ':');
+ if (colonp == NULL) {
+ return FALSE;
+ }
+
+ p = colonp;
+ *p++ = '\0';
+
+ /*
+ * Skip over any white space (there probably won't be any, but
+ * as we allow it in the preferences file, we might as well
+ * allow it here).
+ */
+ while (isspace((guchar)*p))
+ p++;
+ if (*p == '\0') {
+ /*
+ * Put the colon back, so if our caller uses, in an
+ * error message, the string they passed us, the message
+ * looks correct.
+ */
+ *colonp = ':';
+ return FALSE;
+ }
+
+ /* directory should be existing */
+ /* XXX - is this a requirement? */
+ if(test_for_directory(p) != EISDIR) {
+ /*
+ * Put the colon back, so if our caller uses, in an
+ * error message, the string they passed us, the message
+ * looks correct.
+ */
+ *colonp = ':';
+ return FALSE;
+ }
+
+ if (strcmp(optstr,"persconf") == 0) {
+ set_persconffile_dir(p);
+ } else if (strcmp(optstr,"persdata") == 0) {
+ set_persdatafile_dir(p);
+ } else {
+ /* XXX - might need to add the temp file path */
+ return FALSE;
+ }
+ *colonp = ':'; /* put the colon back */
+ return TRUE;
+}
--- /dev/null
+/* persfilepath_opt.h
+ * Definitions of routines to handle command-line options to set paths
+ * for directories containing personal files (configuration, saved
+ * captures)
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * 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 PERSFILEPATH_OPT_H
+#define PERSFILEPATH_OPT_H
+
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * process command line option that affects the paths of the directories
+ * used for personal files (configuration, saved captures)
+ */
+WS_DLL_PUBLIC gboolean persfilepath_opt(int opt, const char *optstr);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PERSFILEPATH_OPT_H */
#endif
#include <wsutil/crash_info.h>
-#include <wsutil/u3.h>
+#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
+#include <wsutil/privileges.h>
+#include <wsutil/u3.h>
#include <wiretap/merge.h>
#include <epan/epan.h>
-#include <wsutil/filesystem.h>
-#include <wsutil/privileges.h>
#include <epan/epan_dissect.h>
#include <epan/timestamp.h>
#include <epan/packet.h>
#include "ui/capture_globals.h"
#include "ui/iface_lists.h"
#include "ui/main_statusbar.h"
+#include "ui/persfilepath_opt.h"
#include "ui/recent.h"
#include "ui/simple_dialog.h"
#include "ui/ui_util.h"
#endif
e_prefs *prefs_p;
GLogLevelFlags log_flags;
- int status;
#ifdef _WIN32
create_app_running_mutex();
set_stdin_capture(TRUE);
break;
#endif
- case 'P': /* Path settings - change these before the Preferences and alike are processed */
- status = filesystem_opt(opt, optarg);
- if(status != 0) {
+ case 'P': /* Personal file directory path settings - change these before the Preferences and alike are processed */
+ if (!persfilepath_opt(opt, optarg)) {
cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg);
- exit(status);
+ exit(2);
}
break;
case 'v': /* Show version and exit */
return persconffile_dir;
}
+void
+set_persconffile_dir(const char *p)
+{
+ g_free(persconffile_dir);
+ persconffile_dir = g_strdup(p);
+}
+
const char *
get_profiles_dir(void)
{
/* the "My Captures" sub-directory is created (if it doesn't
exist) by u3util.exe when the U3 Wireshark is first run */
- szPath = g_strdup_printf("%s%s", u3devicedocumentpath, U3_MY_CAPTURES);
-
- persdatafile_dir = szPath;
- return szPath;
+ persdatafile_dir = g_strdup_printf("%s%s", u3devicedocumentpath, U3_MY_CAPTURES);
+ return persdatafile_dir
} else {
/*
* Hint: SHGetFolderPath is not available on MSVC 6 - without
* Platform SDK
*/
- bRet = SHGetSpecialFolderPath(NULL, tszPath, CSIDL_PERSONAL,
- FALSE);
- if(bRet == TRUE) {
- szPath = utf_16to8(tszPath);
- persdatafile_dir = szPath;
- return szPath;
+ if (SHGetSpecialFolderPath(NULL, tszPath, CSIDL_PERSONAL, FALSE)) {
+ persdatafile_dir = g_utf16_to_utf8(tszPath, -1, NULL, NULL, NULL);
+ return persdatafile_dir;
} else {
return "";
}
#endif
}
+void
+set_persdatafile_dir(const char *p)
+{
+ g_free(persdatafile_dir);
+ persdatafile_dir = g_strdup(p);
+}
+
#ifdef _WIN32
/*
* Returns the user's home directory on Win32.
return path;
}
-/*
- * process command line option belonging to the filesystem settings
- * (move this e.g. to main.c and have set_persconffile_dir() instead in this file?)
- */
-int
-filesystem_opt(int opt _U_, const char *optstr)
-{
- gchar *p, *colonp;
-
- colonp = strchr(optstr, ':');
- if (colonp == NULL) {
- return 1;
- }
-
- p = colonp;
- *p++ = '\0';
-
- /*
- * Skip over any white space (there probably won't be any, but
- * as we allow it in the preferences file, we might as well
- * allow it here).
- */
- while (isspace((guchar)*p))
- p++;
- if (*p == '\0') {
- /*
- * Put the colon back, so if our caller uses, in an
- * error message, the string they passed us, the message
- * looks correct.
- */
- *colonp = ':';
- return 1;
- }
-
- /* directory should be existing */
- /* XXX - is this a requirement? */
- if(test_for_directory(p) != EISDIR) {
- /*
- * Put the colon back, so if our caller uses, in an
- * error message, the string they passed us, the message
- * looks correct.
- */
- *colonp = ':';
- return 1;
- }
-
- if (strcmp(optstr,"persconf") == 0) {
- persconffile_dir = p;
- } else if (strcmp(optstr,"persdata") == 0) {
- persdatafile_dir = p;
- /* XXX - might need to add the temp file path */
- } else {
- return 1;
- }
- *colonp = ':'; /* put the colon back */
- return 0;
-}
-
/*
* Construct the path name of a global configuration file, given the
* file name.
*/
WS_DLL_PUBLIC char *get_persconffile_path(const char *filename, gboolean from_profile);
+/*
+ * Set the path of the personal configuration file directory.
+ */
+WS_DLL_PUBLIC void set_persconffile_dir(const char *p);
+
/*
* Get the (default) directory in which personal data is stored.
*
WS_DLL_PUBLIC const char *get_persdatafile_dir(void);
/*
- * process command line option belonging to the filesystem settings
+ * Set the path of the directory in which personal data is stored.
*/
-WS_DLL_PUBLIC int filesystem_opt(int opt, const char *optstr);
+WS_DLL_PUBLIC void set_persdatafile_dir(const char *p);
/*
* Return an error message for UNIX-style errno indications on open or