Put the code to get version numbers of various libraries with which

Ethereal/Tethereal was linked into a common routine, and use that in
both Ethereal and Tethereal.

Add to that routine code to get OS version information.

svn path=/trunk/; revision=7320
This commit is contained in:
Guy Harris 2003-03-08 07:00:48 +00:00
parent 55e1519797
commit 170b5028e9
5 changed files with 238 additions and 144 deletions

View File

@ -1,4 +1,4 @@
# $Id: configure.in,v 1.200 2003/03/04 03:56:31 gerald Exp $
# $Id: configure.in,v 1.201 2003/03/08 07:00:46 guy Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@ -528,7 +528,7 @@ dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h stdarg.h netdb.h)
AC_CHECK_HEADERS(sys/stat.h sys/sockio.h sys/types.h sys/socket.h)
AC_CHECK_HEADERS(sys/wait.h)
AC_CHECK_HEADERS(sys/utsname.h sys/wait.h)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(stddef.h)
AC_CHECK_HEADERS(arpa/inet.h)

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.284 2003/03/02 22:31:24 guy Exp $
* $Id: main.c,v 1.285 2003/03/08 07:00:48 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -56,26 +56,10 @@
#include <pcap.h>
#endif
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#endif
#ifdef NEED_SNPRINTF_H
# include "snprintf.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 NEED_STRERROR_H
#include "strerror.h"
#endif
@ -130,6 +114,7 @@
#include "image/clist_ascend.xpm"
#include "image/clist_descend.xpm"
#include "../tap.h"
#include "../util.h"
#include "compat_macros.h"
#ifdef WIN32
@ -1394,11 +1379,6 @@ main(int argc, char *argv[])
int opt;
extern char *optarg;
gboolean arg_error = FALSE;
#ifdef HAVE_LIBPCAP
#ifdef HAVE_PCAP_VERSION
extern char pcap_version[];
#endif /* HAVE_PCAP_VERSION */
#endif /* HAVE_LIBPCAP */
#ifdef WIN32
WSADATA wsaData;
@ -1609,54 +1589,8 @@ main(int argc, char *argv[])
"GTK+ (version unknown)");
#endif
g_string_append(comp_info_str, ", with ");
g_string_sprintfa(comp_info_str,
#ifdef GLIB_MAJOR_VERSION
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
GLIB_MICRO_VERSION);
#else
"GLib (version unknown)");
#endif
#ifdef HAVE_LIBPCAP
g_string_append(comp_info_str, ", with libpcap ");
#ifdef HAVE_PCAP_VERSION
g_string_append(comp_info_str, pcap_version);
#else /* HAVE_PCAP_VERSION */
g_string_append(comp_info_str, "(version unknown)");
#endif /* HAVE_PCAP_VERSION */
#else /* HAVE_LIBPCAP */
g_string_append(comp_info_str, ", without libpcap");
#endif /* HAVE_LIBPCAP */
#ifdef HAVE_LIBZ
g_string_append(comp_info_str, ", with libz ");
#ifdef ZLIB_VERSION
g_string_append(comp_info_str, ZLIB_VERSION);
#else /* ZLIB_VERSION */
g_string_append(comp_info_str, "(version unknown)");
#endif /* ZLIB_VERSION */
#else /* HAVE_LIBZ */
g_string_append(comp_info_str, ", without libz");
#endif /* HAVE_LIBZ */
/* Oh, this is pretty. */
/* Oh, ha. you think that was pretty. Try this:! --Wes */
#ifdef HAVE_SOME_SNMP
#ifdef HAVE_UCD_SNMP
g_string_append(comp_info_str, ", with UCD-SNMP ");
g_string_append(comp_info_str, VersionInfo);
#endif /* HAVE_UCD_SNMP */
#ifdef HAVE_NET_SNMP
g_string_append(comp_info_str, ", with Net-SNMP ");
g_string_append(comp_info_str, netsnmp_get_version());
#endif /* HAVE_NET_SNMP */
#else /* no SNMP library */
g_string_append(comp_info_str, ", without UCD-SNMP or Net-SNMP");
#endif /* HAVE_SOME_SNMP */
g_string_append(comp_info_str, ", ");
get_version_info(comp_info_str);
/* Now get our args */
while ((opt = getopt(argc, argv, optstring)) != -1) {

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.176 2003/01/01 03:51:02 guy Exp $
* $Id: tethereal.c,v 1.177 2003/03/08 07:00:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -56,26 +56,10 @@
# include <sys/stat.h>
#endif
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#endif
#ifdef NEED_SNPRINTF_H
# include "snprintf.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 NEED_STRERROR_H
#include "strerror.h"
#endif
@ -363,11 +347,6 @@ main(int argc, char *argv[])
int opt, i;
extern char *optarg;
gboolean arg_error = FALSE;
#ifdef HAVE_LIBPCAP
#ifdef HAVE_PCAP_VERSION
extern char pcap_version[];
#endif /* HAVE_PCAP_VERSION */
#endif /* HAVE_LIBPCAP */
#ifdef _WIN32
WSADATA wsaData;
@ -457,54 +436,7 @@ main(int argc, char *argv[])
/* Assemble the compile-time options */
comp_info_str = g_string_new("");
g_string_append(comp_info_str, "with ");
g_string_sprintfa(comp_info_str,
#ifdef GLIB_MAJOR_VERSION
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
GLIB_MICRO_VERSION);
#else
"GLib (version unknown)");
#endif
#ifdef HAVE_LIBPCAP
g_string_append(comp_info_str, ", with libpcap ");
#ifdef HAVE_PCAP_VERSION
g_string_append(comp_info_str, pcap_version);
#else /* HAVE_PCAP_VERSION */
g_string_append(comp_info_str, "(version unknown)");
#endif /* HAVE_PCAP_VERSION */
#else /* HAVE_LIBPCAP */
g_string_append(comp_info_str, ", without libpcap");
#endif /* HAVE_LIBPCAP */
#ifdef HAVE_LIBZ
g_string_append(comp_info_str, ", with libz ");
#ifdef ZLIB_VERSION
g_string_append(comp_info_str, ZLIB_VERSION);
#else /* ZLIB_VERSION */
g_string_append(comp_info_str, "(version unknown)");
#endif /* ZLIB_VERSION */
#else /* HAVE_LIBZ */
g_string_append(comp_info_str, ", without libz");
#endif /* HAVE_LIBZ */
/* Oh, this is pretty. */
/* Oh, ha. you think that was pretty. Try this:! --Wes */
#ifdef HAVE_SOME_SNMP
#ifdef HAVE_UCD_SNMP
g_string_append(comp_info_str, ", with UCD-SNMP ");
g_string_append(comp_info_str, VersionInfo);
#endif /* HAVE_UCD_SNMP */
#ifdef HAVE_NET_SNMP
g_string_append(comp_info_str, ", with Net-SNMP ");
g_string_append(comp_info_str, netsnmp_get_version());
#endif /* HAVE_NET_SNMP */
#else /* no SNMP library */
g_string_append(comp_info_str, ", without UCD-SNMP or Net-SNMP");
#endif /* HAVE_SOME_SNMP */
get_version_info(comp_info_str);
/* Now get our args */
while ((opt = getopt(argc, argv, "a:b:c:Df:F:hi:lnN:o:pqr:R:s:St:vw:Vxz:")) != -1) {

224
util.c
View File

@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
* $Id: util.c,v 1.57 2002/08/28 21:00:41 jmayer Exp $
* $Id: util.c,v 1.58 2003/03/08 07:00:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -54,8 +54,230 @@
typedef int mode_t; /* for win32 */
#endif
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#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"
/*
* Get various library version and the OS version and append them to
* the specified GString.
*/
void
get_version_info(GString *str)
{
#ifdef HAVE_LIBPCAP
#ifdef HAVE_PCAP_VERSION
extern char pcap_version[];
#endif /* HAVE_PCAP_VERSION */
#endif /* HAVE_LIBPCAP */
#if defined(WIN32)
OSVERSIONINFO info;
#elif defined(HAVE_SYS_UTSNAME_H)
struct utsname name;
#endif
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
#ifdef HAVE_LIBPCAP
g_string_append(str, ", with libpcap ");
#ifdef HAVE_PCAP_VERSION
g_string_append(str, pcap_version);
#else /* HAVE_PCAP_VERSION */
g_string_append(str, "(version unknown)");
#endif /* HAVE_PCAP_VERSION */
#else /* HAVE_LIBPCAP */
g_string_append(str, "without libpcap");
#endif /* HAVE_LIBPCAP */
#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 */
/* Oh, this is pretty. */
/* Oh, ha. you think that was pretty. Try this:! --Wes */
#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, ", running 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 %u.%u",
info.dwMajorVersion, info.dwMinorVersion);
break;
}
break;
default:
g_string_sprintfa(str, "Windows OT, unknown version %u.%u",
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 %u.%u",
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 %u.%u",
info.dwMajorVersion, info.dwMinorVersion);
break;
}
break;
default:
g_string_sprintfa(str, "Windows NT, unknown version %u.%u",
info.dwMajorVersion, info.dwMinorVersion);
break;
}
break;
default:
g_string_sprintfa(str, "Unknown Windows platform %u version %u.%u",
info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
break;
}
g_string_sprintfa(str, ", build %u", info.dwBuildNumber);
if (szCSDVersion[0] != '\0')
g_string_sprintfa(str, ", %s", szCSDVersion);
#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("an unknown OS");
#endif
}
/*
* Collect command-line arguments as a string consisting of the arguments,
* separated by spaces.

8
util.h
View File

@ -1,7 +1,7 @@
/* util.h
* Utility definitions
*
* $Id: util.h,v 1.26 2002/08/28 21:00:41 jmayer Exp $
* $Id: util.h,v 1.27 2003/03/08 07:00:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -29,6 +29,12 @@
extern "C" {
#endif /* __cplusplus */
/*
* Get various library version and the OS version and append them to
* the specified GString.
*/
void get_version_info(GString *str);
int create_tempfile(char *, int, const char *);
/*