diff options
-rw-r--r-- | Makefile.am | 41 | ||||
-rw-r--r-- | Makefile.nmake | 23 | ||||
-rw-r--r-- | gtk/main.c | 3 | ||||
-rw-r--r-- | tethereal.c | 3 | ||||
-rw-r--r-- | util.c | 303 | ||||
-rw-r--r-- | util.h | 14 | ||||
-rw-r--r-- | version_info.c | 345 | ||||
-rw-r--r-- | version_info.h | 49 |
8 files changed, 434 insertions, 347 deletions
diff --git a/Makefile.am b/Makefile.am index 317e4bf26c..8254cef754 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.687 2004/01/10 16:34:27 obiot Exp $ +# $Id: Makefile.am,v 1.688 2004/01/11 22:17:42 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -776,7 +776,7 @@ noinst_HEADERS = \ packet-ypserv.h \ packet-ypxfr.h -DISSECTOR_HELPER_SRC = \ +DISSECTOR_SUPPORT_SRC = \ adler32.c \ adler32.h \ afn.c \ @@ -787,6 +787,8 @@ DISSECTOR_HELPER_SRC = \ asn1.h \ bridged_pids.h \ chdlctypes.h \ + column.c \ + column.h \ crc32.c \ crc32.h \ crypt-des.c \ @@ -798,6 +800,8 @@ DISSECTOR_HELPER_SRC = \ crypt-rc4.c \ crypt-rc4.h \ etypes.h \ + follow.c \ + follow.h \ format-oid.h \ g711.c \ g711.h \ @@ -814,6 +818,9 @@ DISSECTOR_HELPER_SRC = \ oui.h \ packet-dcerpc-nt.c \ ppptypes.h \ + prefs-int.h \ + prefs.c \ + prefs.h \ ptvcursor.c \ ptvcursor.h \ reassemble.c \ @@ -826,38 +833,37 @@ DISSECTOR_HELPER_SRC = \ smb.h \ t35.c \ t35.h \ + tap.c \ + tap.h \ + util.c \ + util.h \ x264_prt_id.h \ xdlc.c \ - xdlc.h + xdlc.h \ + xmlstub.c \ + xmlstub.h BUILT_SOURCES = \ x11-declarations.h \ x11-register-info.h ETHEREAL_COMMON_SRC = \ - $(DISSECTOR_HELPER_SRC) \ + $(DISSECTOR_SUPPORT_SRC) \ $(BUILT_SOURCES) \ capture_stop_conditions.c \ capture_stop_conditions.h \ cfile.c \ cfile.h \ color.h \ - column.c \ - column.h \ conditions.c \ conditions.h \ disabled_protos.c \ disabled_protos.h \ file.h \ - follow.c \ - follow.h \ pcap-util.c \ pcap-util.h \ pcap-util-int.h \ pcap-util-unix.c \ - prefs-int.h \ - prefs.c \ - prefs.h \ print.c \ print.h \ ps.c \ @@ -867,15 +873,10 @@ ETHEREAL_COMMON_SRC = \ register.h \ ringbuffer.c \ ringbuffer.h \ - tap.c \ - tap.h \ - tap_dfilter_dlg.h \ timestats.c \ timestats.h \ - util.c \ - util.h \ - xmlstub.c \ - xmlstub.h + version_info.c \ + version_info.h ethereal_SOURCES = \ $(DISSECTOR_SRC) \ @@ -895,6 +896,7 @@ ethereal_SOURCES = \ statusbar.h \ summary.c \ summary.h \ + tap_dfilter_dlg.h \ ui_util.h EXTRA_ethereal_SOURCES = \ @@ -1126,7 +1128,8 @@ randpkt: randpkt.o wiretap/libwiretap.a dftest_SOURCES = \ $(DISSECTOR_SRC) \ - $(ETHEREAL_COMMON_SRC) \ + $(DISSECTOR_SUPPORT_SRC) \ + $(BUILT_SOURCES) \ register.c \ dftest.c diff --git a/Makefile.nmake b/Makefile.nmake index fbd07677d7..0d4e15968c 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.385 2004/01/10 04:09:14 guy Exp $ +# $Id: Makefile.nmake,v 1.386 2004/01/11 22:17:42 guy Exp $ include config.nmake include <win32.mak> @@ -446,47 +446,48 @@ TETHEREAL_TAP_SRC = \ TETHEREAL_TAP_OBJECTS = $(TETHEREAL_TAP_SRC:.c=.obj) -DISSECTOR_HELPER_OBJECTS = \ +DISSECTOR_SUPPORT_OBJECTS = \ adler32.obj \ afn.obj \ asn1.obj \ + column.obj \ crc32.obj \ crypt-des.obj \ crypt-md4.obj \ crypt-md5.obj \ crypt-rc4.obj \ + follow.obj \ g711.obj \ h225-persistentdata.obj \ in_cksum.obj \ ipproto.obj \ packet-dcerpc-nt.obj \ + prefs.obj \ ptvcursor.obj \ reassemble.obj \ req_resp_hdrs.obj \ t35.obj \ - xdlc.obj + tap.obj \ + util.obj \ + xdlc.obj \ + xmlstub.obj ETHEREAL_COMMON_OBJECTS = \ - $(DISSECTOR_HELPER_OBJECTS) \ + $(DISSECTOR_SUPPORT_OBJECTS) \ capture_stop_conditions.obj \ capture-wpcap.obj \ cfile.obj \ - column.obj \ conditions.obj \ disabled_protos.obj \ - follow.obj \ getopt.obj \ pcap-util.obj \ - prefs.obj \ print.obj \ ps.obj \ range.obj \ register.obj \ ringbuffer.obj \ - tap.obj \ timestats.obj \ - util.obj \ - xmlstub.obj + version_info.c ethereal_OBJECTS = \ $(DISSECTOR_OBJECTS) \ @@ -506,7 +507,7 @@ tethereal_OBJECTS = \ dftest_OBJECTS = \ $(DISSECTOR_OBJECTS) \ - $(ETHEREAL_COMMON_OBJECTS) \ + $(DISSECTOR_SUPPORT_OBJECTS) \ dftest.obj randpkt_OBJECTS = \ diff --git a/gtk/main.c b/gtk/main.c index aef144df1b..3b080e1dd8 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.352 2004/01/10 16:27:42 ulfl Exp $ + * $Id: main.c,v 1.353 2004/01/11 22:17:43 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -118,6 +118,7 @@ #include "toolbar.h" #include "../tap.h" #include "../util.h" +#include "../version_info.h" #include "compat_macros.h" #include "find_dlg.h" #include "packet_list.h" diff --git a/tethereal.c b/tethereal.c index 9581fbe1f0..baf73ec641 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.216 2004/01/09 21:38:21 guy Exp $ + * $Id: tethereal.c,v 1.217 2004/01/11 22:17:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -82,6 +82,7 @@ #include "print.h" #include <epan/resolv.h> #include "util.h" +#include "version_info.h" #ifdef HAVE_LIBPCAP #include "pcap-util.h" #endif @@ -1,7 +1,7 @@ /* util.c * Utility routines * - * $Id: util.c,v 1.75 2003/12/21 12:19:39 ulfl Exp $ + * $Id: util.c,v 1.76 2004/01/11 22:17:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,10 +26,6 @@ # include "config.h" #endif -#ifdef HAVE_LIBPCAP -#include <pcap.h> -#endif /* HAVE_LIBPCAP */ - #include <glib.h> #include <stdlib.h> @@ -60,14 +56,6 @@ typedef int mode_t; /* for win32 */ #endif /* __MINGW32__ */ #endif /* HAVE_IO_H */ -#ifdef HAVE_LIBZ -#include <zlib.h> /* to get the libz version number */ -#endif - -#ifdef HAVE_LIBPCRE -#include <pcre.h> /* to get the libpcre version number */ -#endif /* HAVE_LIBPCRE */ - /* * This has to come after the include of <pcap.h>, as the include of * <pcap.h> might cause <winsock2.h> to be included, and if we've @@ -78,295 +66,7 @@ typedef int mode_t; /* for win32 */ #include <windows.h> #endif -#ifdef HAVE_SOME_SNMP - -#ifdef HAVE_NET_SNMP -#include <net-snmp/version.h> -#endif /* HAVE_NET_SNMP */ - -#ifdef HAVE_UCD_SNMP -#include <ucd-snmp/version.h> -#endif /* HAVE_UCD_SNMP */ - -#endif /* HAVE_SOME_SNMP */ - -#ifdef HAVE_SYS_UTSNAME_H -#include <sys/utsname.h> -#endif - #include "util.h" -#include "pcap-util.h" - -/* - * See whether the last line in the string goes past column 80; if so, - * replace the blank at the specified point with a newline. - */ -static void -do_word_wrap(GString *str, gint point) -{ - char *line_begin; - - line_begin = strrchr(str->str, '\n'); - if (line_begin == NULL) - line_begin = str->str; - else - line_begin++; - if (strlen(line_begin) > 80) { - g_assert(str->str[point] == ' '); - str->str[point] = '\n'; - } -} - -/* - * Get various library compile-time versions and append them to - * the specified GString. - */ -void -get_compiled_version_info(GString *str) -{ - gint break_point; - - g_string_append(str, "with "); - g_string_sprintfa(str, -#ifdef GLIB_MAJOR_VERSION - "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, - GLIB_MICRO_VERSION); -#else - "GLib (version unknown),"); -#endif - - g_string_append(str, " "); - break_point = str->len - 1; - get_compiled_pcap_version(str); - g_string_append(str, ","); - do_word_wrap(str, break_point); - - g_string_append(str, " "); - break_point = str->len - 1; -#ifdef HAVE_LIBZ - g_string_append(str, "with libz "); -#ifdef ZLIB_VERSION - g_string_append(str, ZLIB_VERSION); -#else /* ZLIB_VERSION */ - g_string_append(str, "(version unknown)"); -#endif /* ZLIB_VERSION */ -#else /* HAVE_LIBZ */ - g_string_append(str, "without libz"); -#endif /* HAVE_LIBZ */ - g_string_append(str, ","); - do_word_wrap(str, break_point); - - g_string_append(str, " "); - break_point = str->len - 1; -#ifdef HAVE_LIBPCRE - g_string_append(str, "with libpcre "); -#ifdef PCRE_MAJOR -#ifdef PCRE_MINOR - g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR); -#else /* PCRE_MINOR */ - g_string_sprintfa(str, "%u", PCRE_MAJOR); -#endif /* PCRE_MINOR */ -#else /* PCRE_MAJOR */ - g_string_append(str, "(version unknown)"); -#endif /* PCRE_MAJOR */ -#else /* HAVE_LIBPCRE */ - g_string_append(str, "without libpcre"); -#endif /* HAVE_LIBPCRE */ - - g_string_append(str, ","); - do_word_wrap(str, break_point); - -/* Oh, this is pretty. */ -/* Oh, ha. you think that was pretty. Try this:! --Wes */ - g_string_append(str, " "); - break_point = str->len - 1; -#ifdef HAVE_SOME_SNMP - -#ifdef HAVE_UCD_SNMP - g_string_append(str, "with UCD-SNMP "); - g_string_append(str, VersionInfo); -#endif /* HAVE_UCD_SNMP */ - -#ifdef HAVE_NET_SNMP - g_string_append(str, "with Net-SNMP "); - g_string_append(str, netsnmp_get_version()); -#endif /* HAVE_NET_SNMP */ - -#else /* no SNMP library */ - g_string_append(str, "without UCD-SNMP or Net-SNMP"); -#endif /* HAVE_SOME_SNMP */ - g_string_append(str, ","); - do_word_wrap(str, break_point); - - g_string_append(str, " "); - break_point = str->len - 1; -#ifdef HAVE_GNU_ADNS - g_string_append(str, "with ADNS"); -#else - g_string_append(str, "without ADNS"); -#endif /* HAVE_GNU_ADNS */ - - g_string_append(str, "."); - do_word_wrap(str, break_point); - -#ifndef HAVE_LIBPCRE - break_point = str->len - 1; - g_string_append(str, - "\nNOTE: this build does not support the \"matches\" operator" - "\nfor Ethereal filter syntax.\n"); - do_word_wrap(str, break_point); -#endif /* HAVE_LIBPCRE */ -} - -/* - * Get various library run-time versions, and the OS version, and append - * them to the specified GString. - */ -void -get_runtime_version_info(GString *str) -{ -#if defined(WIN32) - OSVERSIONINFO info; -#elif defined(HAVE_SYS_UTSNAME_H) - struct utsname name; -#endif - - get_runtime_pcap_version(str); - - g_string_append(str, "on "); -#if defined(WIN32) - info.dwOSVersionInfoSize = sizeof info; - if (!GetVersionEx(&info)) { - /* - * XXX - get the failure reason. - */ - g_string_append(str, "unknown Windows version"); - return; - } - switch (info.dwPlatformId) { - - case VER_PLATFORM_WIN32s: - /* Shyeah, right. */ - g_string_sprintfa(str, "Windows 3.1 with Win32s"); - break; - - case VER_PLATFORM_WIN32_WINDOWS: - /* Windows OT */ - switch (info.dwMajorVersion) { - - case 4: - /* 3 cheers for Microsoft marketing! */ - switch (info.dwMinorVersion) { - - case 0: - g_string_sprintfa(str, "Windows 95"); - break; - - case 10: - g_string_sprintfa(str, "Windows 98"); - break; - - case 90: - g_string_sprintfa(str, "Windows Me"); - break; - - default: - 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 %lu.%lu", - info.dwMajorVersion, info.dwMinorVersion); - break; - } - break; - - case VER_PLATFORM_WIN32_NT: - /* Windows NT */ - switch (info.dwMajorVersion) { - - case 3: - case 4: - g_string_sprintfa(str, "Windows NT %lu.%lu", - info.dwMajorVersion, info.dwMinorVersion); - break; - - case 5: - /* 3 cheers for Microsoft marketing! */ - switch (info.dwMinorVersion) { - - case 0: - g_string_sprintfa(str, "Windows 2000"); - break; - - case 1: - g_string_sprintfa(str, "Windows XP"); - break; - - case 2: - g_string_sprintfa(str, "Windows Server 2003"); - break; - - default: - 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 %lu.%lu", - info.dwMajorVersion, info.dwMinorVersion); - break; - } - break; - - default: - 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 %lu", info.dwBuildNumber); -#elif defined(HAVE_SYS_UTSNAME_H) - /* - * We have <sys/utsname.h>, so we assume we have "uname()". - */ - if (uname(&name) < 0) { - g_string_sprintfa(str, "unknown OS version (uname failed - %s)", - strerror(errno)); - return; - } - - if (strcmp(name.sysname, "AIX") == 0) { - /* - * Yay, IBM! Thanks for doing something different - * from most of the other UNIXes out there, and - * making "name.version" apparently be the major - * version number and "name.release" be the minor - * version number. - */ - g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version, - name.release); - } else { - /* - * XXX - get "version" on any other platforms? - * - * On Digital/Tru65 UNIX, it's something unknown. - * On Solaris, it's some kind of build information. - * On HP-UX, it appears to be some sort of subrevision - * thing. - */ - g_string_sprintfa(str, "%s %s", name.sysname, name.release); - } -#else - g_string_append(str, "an unknown OS"); -#endif -} /* * Collect command-line arguments as a string consisting of the arguments, @@ -747,4 +447,3 @@ gchar *get_conn_cfilter(void) { } return ""; } - @@ -1,7 +1,7 @@ /* util.h * Utility definitions * - * $Id: util.h,v 1.30 2003/11/18 04:16:28 gerald Exp $ + * $Id: util.h,v 1.31 2004/01/11 22:17:43 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -29,18 +29,6 @@ extern "C" { #endif /* __cplusplus */ -/* - * Get various library compile-time versions and append them to - * the specified GString. - */ -void get_compiled_version_info(GString *str); - -/* - * Get various library run-time versions, and the OS version, and append - * them to the specified GString. - */ -void get_runtime_version_info(GString *str); - int create_tempfile(char *, int, const char *); /* diff --git a/version_info.c b/version_info.c new file mode 100644 index 0000000000..6e71175fc8 --- /dev/null +++ b/version_info.c @@ -0,0 +1,345 @@ +/* version_info.c + * Routines to report version information for stuff used by Ethereal + * + * $Id: version_info.c,v 1.1 2004/01/11 22:17:43 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_LIBPCAP +#include <pcap.h> +#endif /* HAVE_LIBPCAP */ + +#include <glib.h> + +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#ifdef HAVE_LIBZ +#include <zlib.h> /* to get the libz version number */ +#endif + +#ifdef HAVE_LIBPCRE +#include <pcre.h> /* to get the libpcre version number */ +#endif /* HAVE_LIBPCRE */ + +/* + * This has to come after the include of <pcap.h>, as the include of + * <pcap.h> might cause <winsock2.h> to be included, and if we've + * already included <winsock.h> as a result of including <windows.h>, + * we get a bunch of redefinitions. + */ +#ifdef HAVE_WINDOWS_H +#include <windows.h> +#endif + +#ifdef HAVE_SOME_SNMP + +#ifdef HAVE_NET_SNMP +#include <net-snmp/version.h> +#endif /* HAVE_NET_SNMP */ + +#ifdef HAVE_UCD_SNMP +#include <ucd-snmp/version.h> +#endif /* HAVE_UCD_SNMP */ + +#endif /* HAVE_SOME_SNMP */ + +#ifdef HAVE_SYS_UTSNAME_H +#include <sys/utsname.h> +#endif + +#include "version_info.h" +#include "pcap-util.h" + +/* + * See whether the last line in the string goes past column 80; if so, + * replace the blank at the specified point with a newline. + */ +static void +do_word_wrap(GString *str, gint point) +{ + char *line_begin; + + line_begin = strrchr(str->str, '\n'); + if (line_begin == NULL) + line_begin = str->str; + else + line_begin++; + if (strlen(line_begin) > 80) { + g_assert(str->str[point] == ' '); + str->str[point] = '\n'; + } +} + +/* + * Get various library compile-time versions and append them to + * the specified GString. + */ +void +get_compiled_version_info(GString *str) +{ + gint break_point; + + g_string_append(str, "with "); + g_string_sprintfa(str, +#ifdef GLIB_MAJOR_VERSION + "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, + GLIB_MICRO_VERSION); +#else + "GLib (version unknown),"); +#endif + + g_string_append(str, " "); + break_point = str->len - 1; + get_compiled_pcap_version(str); + g_string_append(str, ","); + do_word_wrap(str, break_point); + + g_string_append(str, " "); + break_point = str->len - 1; +#ifdef HAVE_LIBZ + g_string_append(str, "with libz "); +#ifdef ZLIB_VERSION + g_string_append(str, ZLIB_VERSION); +#else /* ZLIB_VERSION */ + g_string_append(str, "(version unknown)"); +#endif /* ZLIB_VERSION */ +#else /* HAVE_LIBZ */ + g_string_append(str, "without libz"); +#endif /* HAVE_LIBZ */ + g_string_append(str, ","); + do_word_wrap(str, break_point); + + g_string_append(str, " "); + break_point = str->len - 1; +#ifdef HAVE_LIBPCRE + g_string_append(str, "with libpcre "); +#ifdef PCRE_MAJOR +#ifdef PCRE_MINOR + g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR); +#else /* PCRE_MINOR */ + g_string_sprintfa(str, "%u", PCRE_MAJOR); +#endif /* PCRE_MINOR */ +#else /* PCRE_MAJOR */ + g_string_append(str, "(version unknown)"); +#endif /* PCRE_MAJOR */ +#else /* HAVE_LIBPCRE */ + g_string_append(str, "without libpcre"); +#endif /* HAVE_LIBPCRE */ + + g_string_append(str, ","); + do_word_wrap(str, break_point); + +/* Oh, this is pretty. */ +/* Oh, ha. you think that was pretty. Try this:! --Wes */ + g_string_append(str, " "); + break_point = str->len - 1; +#ifdef HAVE_SOME_SNMP + +#ifdef HAVE_UCD_SNMP + g_string_append(str, "with UCD-SNMP "); + g_string_append(str, VersionInfo); +#endif /* HAVE_UCD_SNMP */ + +#ifdef HAVE_NET_SNMP + g_string_append(str, "with Net-SNMP "); + g_string_append(str, netsnmp_get_version()); +#endif /* HAVE_NET_SNMP */ + +#else /* no SNMP library */ + g_string_append(str, "without UCD-SNMP or Net-SNMP"); +#endif /* HAVE_SOME_SNMP */ + g_string_append(str, ","); + do_word_wrap(str, break_point); + + g_string_append(str, " "); + break_point = str->len - 1; +#ifdef HAVE_GNU_ADNS + g_string_append(str, "with ADNS"); +#else + g_string_append(str, "without ADNS"); +#endif /* HAVE_GNU_ADNS */ + + g_string_append(str, "."); + do_word_wrap(str, break_point); + +#ifndef HAVE_LIBPCRE + break_point = str->len - 1; + g_string_append(str, + "\nNOTE: this build does not support the \"matches\" operator" + "\nfor Ethereal filter syntax.\n"); + do_word_wrap(str, break_point); +#endif /* HAVE_LIBPCRE */ +} + +/* + * Get various library run-time versions, and the OS version, and append + * them to the specified GString. + */ +void +get_runtime_version_info(GString *str) +{ +#if defined(WIN32) + OSVERSIONINFO info; +#elif defined(HAVE_SYS_UTSNAME_H) + struct utsname name; +#endif + + get_runtime_pcap_version(str); + + g_string_append(str, "on "); +#if defined(WIN32) + info.dwOSVersionInfoSize = sizeof info; + if (!GetVersionEx(&info)) { + /* + * XXX - get the failure reason. + */ + g_string_append(str, "unknown Windows version"); + return; + } + switch (info.dwPlatformId) { + + case VER_PLATFORM_WIN32s: + /* Shyeah, right. */ + g_string_sprintfa(str, "Windows 3.1 with Win32s"); + break; + + case VER_PLATFORM_WIN32_WINDOWS: + /* Windows OT */ + switch (info.dwMajorVersion) { + + case 4: + /* 3 cheers for Microsoft marketing! */ + switch (info.dwMinorVersion) { + + case 0: + g_string_sprintfa(str, "Windows 95"); + break; + + case 10: + g_string_sprintfa(str, "Windows 98"); + break; + + case 90: + g_string_sprintfa(str, "Windows Me"); + break; + + default: + 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 %lu.%lu", + info.dwMajorVersion, info.dwMinorVersion); + break; + } + break; + + case VER_PLATFORM_WIN32_NT: + /* Windows NT */ + switch (info.dwMajorVersion) { + + case 3: + case 4: + g_string_sprintfa(str, "Windows NT %lu.%lu", + info.dwMajorVersion, info.dwMinorVersion); + break; + + case 5: + /* 3 cheers for Microsoft marketing! */ + switch (info.dwMinorVersion) { + + case 0: + g_string_sprintfa(str, "Windows 2000"); + break; + + case 1: + g_string_sprintfa(str, "Windows XP"); + break; + + case 2: + g_string_sprintfa(str, "Windows Server 2003"); + break; + + default: + 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 %lu.%lu", + info.dwMajorVersion, info.dwMinorVersion); + break; + } + break; + + default: + 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 %lu", info.dwBuildNumber); +#elif defined(HAVE_SYS_UTSNAME_H) + /* + * We have <sys/utsname.h>, so we assume we have "uname()". + */ + if (uname(&name) < 0) { + g_string_sprintfa(str, "unknown OS version (uname failed - %s)", + strerror(errno)); + return; + } + + if (strcmp(name.sysname, "AIX") == 0) { + /* + * Yay, IBM! Thanks for doing something different + * from most of the other UNIXes out there, and + * making "name.version" apparently be the major + * version number and "name.release" be the minor + * version number. + */ + g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version, + name.release); + } else { + /* + * XXX - get "version" on any other platforms? + * + * On Digital/Tru65 UNIX, it's something unknown. + * On Solaris, it's some kind of build information. + * On HP-UX, it appears to be some sort of subrevision + * thing. + */ + g_string_sprintfa(str, "%s %s", name.sysname, name.release); + } +#else + g_string_append(str, "an unknown OS"); +#endif +} diff --git a/version_info.h b/version_info.h new file mode 100644 index 0000000000..7b81e6b7fc --- /dev/null +++ b/version_info.h @@ -0,0 +1,49 @@ +/* version_info.h + * Declarations of outines to report version information for stuff used + * by Ethereal + * + * $Id: version_info.h,v 1.1 2004/01/11 22:17:43 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __VERSION_INFO_H__ +#define __VERSION_INFO_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Get various library compile-time versions and append them to + * the specified GString. + */ +void get_compiled_version_info(GString *str); + +/* + * Get various library run-time versions, and the OS version, and append + * them to the specified GString. + */ +void get_runtime_version_info(GString *str); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __VERSION_INFO_H__ */ |