2004-01-11 22:17:43 +00:00
|
|
|
/* version_info.c
|
2006-05-22 08:14:01 +00:00
|
|
|
* Routines to report version information for stuff used by Wireshark
|
2004-01-11 22:17:43 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-01-11 22:17:43 +00:00
|
|
|
* 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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-01-11 22:17:43 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:29:52 +00:00
|
|
|
#include "config.h"
|
2004-01-11 22:17:43 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBZ
|
|
|
|
#include <zlib.h> /* to get the libz version number */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "version_info.h"
|
2005-12-06 00:07:13 +00:00
|
|
|
#include "capture-pcap-util.h"
|
2014-06-21 18:01:19 +00:00
|
|
|
#include <wsutil/os_version_info.h>
|
2014-06-21 19:34:26 +00:00
|
|
|
#include <wsutil/compiler_info.h>
|
2014-06-21 20:20:18 +00:00
|
|
|
#include <wsutil/cpu_info.h>
|
2004-01-11 22:17:43 +00:00
|
|
|
|
2014-02-07 19:14:52 +00:00
|
|
|
#include "version.h"
|
2005-08-16 06:45:17 +00:00
|
|
|
|
2006-02-17 02:18:48 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2008-03-04 23:57:55 +00:00
|
|
|
#ifdef HAVE_LIBCAP
|
|
|
|
# include <sys/capability.h>
|
|
|
|
#endif
|
|
|
|
|
2014-02-07 19:14:52 +00:00
|
|
|
#ifdef GITVERSION
|
|
|
|
const char *wireshark_gitversion = " (" GITVERSION " from " GITBRANCH ")";
|
2005-08-16 06:45:17 +00:00
|
|
|
#else
|
2014-02-07 19:14:52 +00:00
|
|
|
const char *wireshark_gitversion = "";
|
2005-08-16 06:45:17 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-21 08:59:52 +00:00
|
|
|
/*
|
|
|
|
* If the string doesn't end with a newline, append one.
|
2006-10-20 09:06:24 +00:00
|
|
|
* Then word-wrap it to 80 columns.
|
2005-12-21 08:59:52 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
end_string(GString *str)
|
|
|
|
{
|
|
|
|
size_t point;
|
2006-10-20 09:06:24 +00:00
|
|
|
char *p, *q;
|
2005-12-21 08:59:52 +00:00
|
|
|
|
2010-08-31 18:28:59 +00:00
|
|
|
point = str->len;
|
2005-12-21 08:59:52 +00:00
|
|
|
if (point == 0 || str->str[point - 1] != '\n')
|
|
|
|
g_string_append(str, "\n");
|
2006-10-20 09:06:24 +00:00
|
|
|
p = str->str;
|
|
|
|
while (*p != '\0') {
|
|
|
|
q = strchr(p, '\n');
|
|
|
|
if (q - p > 80) {
|
|
|
|
/*
|
|
|
|
* Break at or before this point.
|
|
|
|
*/
|
|
|
|
q = p + 80;
|
|
|
|
while (q > p && *q != ' ')
|
|
|
|
q--;
|
|
|
|
if (q != p)
|
|
|
|
*q = '\n';
|
|
|
|
}
|
|
|
|
p = q + 1;
|
|
|
|
}
|
2006-08-17 23:35:45 +00:00
|
|
|
}
|
2005-12-21 08:59:52 +00:00
|
|
|
|
2004-01-11 22:17:43 +00:00
|
|
|
/*
|
|
|
|
* Get various library compile-time versions and append them to
|
|
|
|
* the specified GString.
|
2006-10-19 18:43:12 +00:00
|
|
|
*
|
|
|
|
* "additional_info" is called at the end to append any additional
|
|
|
|
* information; this is required in order to, for example, put the
|
|
|
|
* Portaudio information at the end of the string, as we currently
|
|
|
|
* don't use Portaudio in TShark.
|
2004-01-11 22:17:43 +00:00
|
|
|
*/
|
|
|
|
void
|
2011-01-16 23:04:33 +00:00
|
|
|
get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
|
2010-10-21 07:13:43 +00:00
|
|
|
void (*append_info)(GString *))
|
2004-01-11 22:17:43 +00:00
|
|
|
{
|
2010-04-24 02:04:14 +00:00
|
|
|
if (sizeof(str) == 4)
|
|
|
|
g_string_append(str, "(32-bit) ");
|
|
|
|
else
|
|
|
|
g_string_append(str, "(64-bit) ");
|
|
|
|
|
2010-10-21 07:13:43 +00:00
|
|
|
if (prepend_info)
|
|
|
|
(*prepend_info)(str);
|
|
|
|
|
2011-01-16 23:04:33 +00:00
|
|
|
/* GLIB */
|
2004-01-11 22:17:43 +00:00
|
|
|
g_string_append(str, "with ");
|
2008-05-07 05:26:40 +00:00
|
|
|
g_string_append_printf(str,
|
2004-01-11 22:17:43 +00:00
|
|
|
#ifdef GLIB_MAJOR_VERSION
|
2006-10-20 09:06:24 +00:00
|
|
|
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
|
2004-01-11 22:17:43 +00:00
|
|
|
GLIB_MICRO_VERSION);
|
|
|
|
#else
|
2006-10-20 09:06:24 +00:00
|
|
|
"GLib (version unknown)");
|
2004-01-11 22:17:43 +00:00
|
|
|
#endif
|
|
|
|
|
2006-10-20 09:06:24 +00:00
|
|
|
/* Libpcap */
|
|
|
|
g_string_append(str, ", ");
|
2004-01-11 22:17:43 +00:00
|
|
|
get_compiled_pcap_version(str);
|
|
|
|
|
2011-01-16 23:04:33 +00:00
|
|
|
/* LIBZ */
|
2006-10-20 09:06:24 +00:00
|
|
|
g_string_append(str, ", ");
|
2004-01-11 22:17:43 +00:00
|
|
|
#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 */
|
2006-10-19 21:17:23 +00:00
|
|
|
|
2013-11-02 01:12:30 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
/* This is UN*X-only. */
|
2011-01-16 23:04:33 +00:00
|
|
|
/* LIBCAP */
|
2008-03-05 09:59:15 +00:00
|
|
|
g_string_append(str, ", ");
|
2008-03-04 23:57:55 +00:00
|
|
|
#ifdef HAVE_LIBCAP
|
|
|
|
g_string_append(str, "with POSIX capabilities");
|
|
|
|
#ifdef _LINUX_CAPABILITY_VERSION
|
|
|
|
g_string_append(str, " (Linux)");
|
|
|
|
#endif /* _LINUX_CAPABILITY_VERSION */
|
|
|
|
#else /* HAVE_LIBCAP */
|
|
|
|
g_string_append(str, "without POSIX capabilities");
|
|
|
|
#endif /* HAVE_LIBCAP */
|
2013-11-02 01:12:30 +00:00
|
|
|
#endif /* _WIN32 */
|
2008-03-04 23:57:55 +00:00
|
|
|
|
2013-11-02 01:12:30 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
/* This is a Linux-specific library. */
|
2012-07-05 19:10:47 +00:00
|
|
|
/* LIBNL */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#if defined(HAVE_LIBNL1)
|
|
|
|
g_string_append(str, "with libnl 1");
|
|
|
|
#elif defined(HAVE_LIBNL2)
|
|
|
|
g_string_append(str, "with libnl 2");
|
|
|
|
#elif defined(HAVE_LIBNL3)
|
|
|
|
g_string_append(str, "with libnl 3");
|
2013-11-02 01:12:30 +00:00
|
|
|
#else /* no libnl */
|
2012-07-05 19:10:47 +00:00
|
|
|
g_string_append(str, "without libnl");
|
2013-11-02 01:12:30 +00:00
|
|
|
#endif /* libnl version */
|
|
|
|
#endif /* __linux__ */
|
2012-07-05 19:10:47 +00:00
|
|
|
|
2006-10-19 21:17:23 +00:00
|
|
|
/* Additional application-dependent information */
|
2010-10-21 07:13:43 +00:00
|
|
|
if (append_info)
|
|
|
|
(*append_info)(str);
|
2006-10-20 09:06:24 +00:00
|
|
|
g_string_append(str, ".");
|
2006-10-19 21:17:23 +00:00
|
|
|
|
|
|
|
end_string(str);
|
|
|
|
}
|
|
|
|
|
2013-03-21 21:58:47 +00:00
|
|
|
static void get_mem_info(GString *str _U_)
|
2013-02-08 14:51:49 +00:00
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
MEMORYSTATUSEX statex;
|
|
|
|
|
2013-02-04 15:29:43 +00:00
|
|
|
statex.dwLength = sizeof (statex);
|
2014-02-07 19:14:52 +00:00
|
|
|
|
2013-02-04 15:29:43 +00:00
|
|
|
if(GlobalMemoryStatusEx (&statex))
|
|
|
|
g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-20 21:17:43 +00:00
|
|
|
/*
|
|
|
|
* Get various library run-time versions, and the OS version, and append
|
|
|
|
* them to the specified GString.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
get_runtime_version_info(GString *str, void (*additional_info)(GString *))
|
|
|
|
{
|
|
|
|
#ifndef _WIN32
|
|
|
|
gchar *lang;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_string_append(str, "on ");
|
|
|
|
|
|
|
|
get_os_version_info(str);
|
2006-09-22 23:08:06 +00:00
|
|
|
|
2011-06-29 08:05:53 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
/* Locale */
|
|
|
|
if ((lang = getenv ("LANG")) != NULL)
|
|
|
|
g_string_append_printf(str, ", with locale %s", lang);
|
|
|
|
else
|
|
|
|
g_string_append(str, ", without locale");
|
|
|
|
#endif
|
|
|
|
|
2006-10-20 09:06:24 +00:00
|
|
|
/* Libpcap */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
get_runtime_pcap_version(str);
|
|
|
|
|
2011-01-16 23:04:33 +00:00
|
|
|
/* zlib */
|
2010-04-19 06:39:45 +00:00
|
|
|
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
2011-01-16 23:04:33 +00:00
|
|
|
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
2010-04-17 10:22:38 +00:00
|
|
|
#endif
|
|
|
|
|
2006-10-19 22:43:38 +00:00
|
|
|
/* Additional application-dependent information */
|
2006-10-20 09:06:24 +00:00
|
|
|
if (additional_info)
|
2006-10-19 22:43:38 +00:00
|
|
|
(*additional_info)(str);
|
2006-09-22 23:08:06 +00:00
|
|
|
|
2006-10-20 09:06:24 +00:00
|
|
|
g_string_append(str, ".");
|
2005-12-21 08:59:52 +00:00
|
|
|
|
2013-02-04 15:29:43 +00:00
|
|
|
/* CPU Info */
|
|
|
|
get_cpu_info(str);
|
|
|
|
|
2013-02-08 14:51:49 +00:00
|
|
|
/* Get info about installed memory Windows only */
|
|
|
|
get_mem_info(str);
|
|
|
|
|
2006-10-17 22:43:40 +00:00
|
|
|
/* Compiler info */
|
2014-06-21 19:34:26 +00:00
|
|
|
get_compiler_info(str);
|
2006-10-19 20:37:41 +00:00
|
|
|
|
2005-12-21 08:59:52 +00:00
|
|
|
end_string(str);
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:18:17 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
/*
|
|
|
|
* Get the major OS version.
|
|
|
|
*/
|
|
|
|
/* XXX - Should this return the minor version as well, e.g. 0x00050002? */
|
|
|
|
guint32
|
|
|
|
get_os_major_version()
|
|
|
|
{
|
|
|
|
OSVERSIONINFO info;
|
|
|
|
info.dwOSVersionInfoSize = sizeof info;
|
|
|
|
if (GetVersionEx(&info)) {
|
|
|
|
return info.dwMajorVersion;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
2008-09-02 11:17:03 +00:00
|
|
|
* indent-tabs-mode: t
|
2007-09-15 00:18:17 +00:00
|
|
|
* End:
|
|
|
|
*
|
2011-09-21 17:49:11 +00:00
|
|
|
* ex: set shiftwidth=8 tabstop=8 noexpandtab:
|
2007-09-15 00:18:17 +00:00
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|