diff options
author | Gerald Combs <gerald@wireshark.org> | 2003-11-02 23:12:35 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2003-11-02 23:12:35 +0000 |
commit | 031db8b9c87e9f096a377547dfbf6266958fa6cd (patch) | |
tree | b9ceb9b8cc87f48bc800f3b66eb28fb37398cb09 | |
parent | b8d155186ccf09f303c0f7196f09484bf6c9a674 (diff) | |
download | wireshark-031db8b9c87e9f096a377547dfbf6266958fa6cd.tar.gz |
From Gisle Vanem:
* Added a new function get_file_in_temp() to
epan/filesystem.c. This because of asn1.dll plugin which
had code to write to a log-file "c:\temp\ethereal.log". I feel
this patch makes this safer; I don't even have a c:\temp dir.
* Patched packet-asn1.c to use get_file_in_temp().
* Added some #undef to packet-snmp.c to silence gcc.
* Changed "%u" -> "%lu" formats in util.c
Rename get_file_in_temp() to get_tempfile_path() to match other function
names.
svn path=/trunk/; revision=8859
-rw-r--r-- | epan/filesystem.c | 25 | ||||
-rw-r--r-- | epan/filesystem.h | 11 | ||||
-rw-r--r-- | packet-snmp.c | 16 | ||||
-rw-r--r-- | plugins/asn1/packet-asn1.c | 22 | ||||
-rw-r--r-- | plugins/plugin_api_list.c | 3 | ||||
-rw-r--r-- | util.c | 16 |
6 files changed, 69 insertions, 24 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 2a98c2483b..9857cb1316 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -1,7 +1,7 @@ /* filesystem.c * Filesystem utility routines * - * $Id: filesystem.c,v 1.24 2003/09/15 19:04:59 guy Exp $ + * $Id: filesystem.c,v 1.25 2003/11/02 23:12:34 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -627,3 +627,26 @@ deletefile(const char *path) { return unlink(path) == 0; } + +/* + * Construct and return the path name of a file in the + * $TMP/%TEMP% directory. + */ +char *get_tempfile_path(const char *file) +{ + char path [PATH_MAX], *dir, *def; + +#ifdef WIN32 + dir = getenv("TEMP"); + def = "C:\\"; +#else + dir = getenv("TMP"); + def = "/tmp"; +#endif + if (!dir || (dir = get_dirname(dir)) == NULL) + return g_strdup(def); + + snprintf(path, sizeof(path), "%s%c%s", dir, G_DIR_SEPARATOR, file); + return g_strdup(path); +} + diff --git a/epan/filesystem.h b/epan/filesystem.h index a23a621684..d33d24e0c6 100644 --- a/epan/filesystem.h +++ b/epan/filesystem.h @@ -1,7 +1,7 @@ /* filesystem.h * Filesystem utility definitions * - * $Id: filesystem.h,v 1.13 2003/05/15 07:44:54 guy Exp $ + * $Id: filesystem.h,v 1.14 2003/11/02 23:12:34 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -111,6 +111,15 @@ int create_persconffile_dir(char **pf_dir_path_return); */ char *get_persconffile_path(const char *filename, gboolean for_writing); +/* + * Construct the path name of a file in $TMP/%TEMP% directory. + * Or "/tmp/<filename>" (C:\<filename>) if that fails. + * + * Return value is malloced so the caller should free it. + */ +char *get_tempfile_path(const char *filename); + + /* Delete a file */ gboolean deletefile (const char *path); #endif /* FILESYSTEM_H */ diff --git a/packet-snmp.c b/packet-snmp.c index ad13856351..b8b9b4f08d 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -10,7 +10,7 @@ * * See RFCs 2570-2576 for SNMPv3 * - * $Id: packet-snmp.c,v 1.121 2003/10/29 22:11:08 guy Exp $ + * $Id: packet-snmp.c,v 1.122 2003/11/02 23:12:31 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -182,6 +182,20 @@ static const value_string versions[] = { { 0, NULL }, }; +/* defined in net-SNMP; include/net-snmp/library/snmp.h */ +#undef SNMP_MSG_GET +#undef SNMP_MSG_SET +#undef SNMP_MSG_GETNEXT +#undef SNMP_MSG_RESPONSE +#undef SNMP_MSG_TRAP +#undef SNMP_MSG_GETBULK +#undef SNMP_MSG_INFORM +#undef SNMP_MSG_TRAP2 +#undef SNMP_MSG_REPORT +#undef SNMP_NOSUCHOBJECT +#undef SNMP_NOSUCHINSTANCE +#undef SNMP_ENDOFMIBVIEW + /* PDU types */ #define SNMP_MSG_GET 0 #define SNMP_MSG_GETNEXT 1 diff --git a/plugins/asn1/packet-asn1.c b/plugins/asn1/packet-asn1.c index 7e6bcfbed9..6e5a9e6e13 100644 --- a/plugins/asn1/packet-asn1.c +++ b/plugins/asn1/packet-asn1.c @@ -3,7 +3,7 @@ * * Copyright (c) 2003 by Matthijs Melchior <matthijs.melchior@xs4all.nl> * - * $Id: packet-asn1.c,v 1.6 2003/10/30 11:56:36 guy Exp $ + * $Id: packet-asn1.c,v 1.7 2003/11/02 23:12:35 gerald Exp $ * * A plugin for: * @@ -145,12 +145,9 @@ static gboolean asn1_message_win = FALSE; static gboolean asn1_verbose = FALSE; /* change to TRUE for logging the startup phase */ static gboolean asn1_full = FALSE; /* show full names */ static guint type_recursion_level = 1; /* eliminate 1 level of references */ -static char *asn1_logfile = 0; -#ifdef WIN32 -#define ASN1LOGFILE "C:\\temp\\ethereal.log" -#else -#define ASN1LOGFILE "/tmp/ethereal.log" -#endif +static char *asn1_logfile = NULL; + +#define ASN1LOGFILE "ethereal.log" /* PDU counter, for correlation between GUI display and log file in debug mode */ static int pcount = 0; @@ -2563,12 +2560,14 @@ static char eol[] = "\r\n"; (void) log_domain; (void) log_level; (void) user_data; /* make references */ - if (logf == 0) { + if (logf == NULL && asn1_logfile) { logf = fopen(asn1_logfile, "w"); } + if (logf) { fputs(message, logf); fputs(eol, logf); } +} void read_asn1_type_table(char *filename) @@ -3332,7 +3331,7 @@ build_pdu_tree(char *pduname) #ifdef DISSECTOR_WITH_GUI /* This cannot work in tethereal.... don't include for now */ #if GTK_MAJOR_VERSION >= 2 -#define SHOWPDU /* this needs GTK2, which is not yet on Win32 .............. */ +#define SHOWPDU /* this needs GTK2 */ #endif #endif /* DISSECTOR_WITH_GUI */ #ifdef SHOWPDU @@ -4638,8 +4637,7 @@ proto_register_asn1(void) { module_t *asn1_module; int i, j; - - asn1_logfile = g_strdup(ASN1LOGFILE); + asn1_logfile = get_tempfile_path(ASN1LOGFILE); current_pduname = g_strdup("ASN1"); asn1_pduname = g_strdup(current_pduname); @@ -4712,7 +4710,7 @@ proto_register_asn1(void) { &asn1_message_win); prefs_register_bool_preference(asn1_module, "verbose_log", "Write very verbose log", - "log to file " ASN1LOGFILE, + "log to file $TMP/" ASN1LOGFILE, &asn1_verbose); } diff --git a/plugins/plugin_api_list.c b/plugins/plugin_api_list.c index 98d9043a55..5f3627cf1f 100644 --- a/plugins/plugin_api_list.c +++ b/plugins/plugin_api_list.c @@ -1,7 +1,7 @@ /* plugin_api_list.c * Used to generate various included files for plugin API * - * $Id: plugin_api_list.c,v 1.12 2003/11/01 03:10:03 guy Exp $ + * $Id: plugin_api_list.c,v 1.13 2003/11/02 23:12:34 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -379,6 +379,7 @@ gboolean dissector_try_string(dissector_table_t, const gchar*, tvbuff_t*, packet dissector_handle_t dissector_get_string_handle(dissector_table_t, const gchar*); char *get_datafile_path(const char *filename); +char *get_tempfile_path(const char *filename); void register_heur_dissector_list(const char *name, heur_dissector_list_t *list); @@ -1,7 +1,7 @@ /* util.c * Utility routines * - * $Id: util.c,v 1.70 2003/10/31 07:57:22 guy Exp $ + * $Id: util.c,v 1.71 2003/11/02 23:12:32 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -237,14 +237,14 @@ get_runtime_version_info(GString *str) break; default: - g_string_sprintfa(str, "Windows OT, unknown version %u.%u", + g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Windows OT, unknown version %u.%u", + g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } @@ -256,7 +256,7 @@ get_runtime_version_info(GString *str) case 3: case 4: - g_string_sprintfa(str, "Windows NT %u.%u", + g_string_sprintfa(str, "Windows NT %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; @@ -277,27 +277,27 @@ get_runtime_version_info(GString *str) break; default: - g_string_sprintfa(str, "Windows NT, unknown version %u.%u", + g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Windows NT, unknown version %u.%u", + g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Unknown Windows platform %u version %u.%u", + g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu", info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion); break; } if (info.szCSDVersion[0] != '\0') g_string_sprintfa(str, " %s", info.szCSDVersion); - g_string_sprintfa(str, ", build %u", info.dwBuildNumber); + g_string_sprintfa(str, ", build %lu", info.dwBuildNumber); #elif defined(HAVE_SYS_UTSNAME_H) /* * We have <sys/utsname.h>, so we assume we have "uname()". |