2 * Routines to report version information for stuff used by Wireshark
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <zlib.h> /* to get the libz version number */
34 #include "version_info.h"
35 #include "capture-pcap-util.h"
36 #include <wsutil/os_version_info.h>
37 #include <wsutil/compiler_info.h>
38 #include <wsutil/cpu_info.h>
47 # include <sys/capability.h>
51 const char *wireshark_gitversion = " (" GITVERSION " from " GITBRANCH ")";
53 const char *wireshark_gitversion = "";
57 * If the string doesn't end with a newline, append one.
58 * Then word-wrap it to 80 columns.
61 end_string(GString *str)
67 if (point == 0 || str->str[point - 1] != '\n')
68 g_string_append(str, "\n");
74 * Break at or before this point.
77 while (q > p && *q != ' ')
87 * Get various library compile-time versions and append them to
88 * the specified GString.
90 * "additional_info" is called at the end to append any additional
91 * information; this is required in order to, for example, put the
92 * Portaudio information at the end of the string, as we currently
93 * don't use Portaudio in TShark.
96 get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
97 void (*append_info)(GString *))
100 g_string_append(str, "(32-bit) ");
102 g_string_append(str, "(64-bit) ");
105 (*prepend_info)(str);
108 g_string_append(str, "with ");
109 g_string_append_printf(str,
110 #ifdef GLIB_MAJOR_VERSION
111 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
114 "GLib (version unknown)");
118 g_string_append(str, ", ");
119 get_compiled_pcap_version(str);
122 g_string_append(str, ", ");
124 g_string_append(str, "with libz ");
126 g_string_append(str, ZLIB_VERSION);
127 #else /* ZLIB_VERSION */
128 g_string_append(str, "(version unknown)");
129 #endif /* ZLIB_VERSION */
130 #else /* HAVE_LIBZ */
131 g_string_append(str, "without libz");
132 #endif /* HAVE_LIBZ */
135 /* This is UN*X-only. */
137 g_string_append(str, ", ");
139 g_string_append(str, "with POSIX capabilities");
140 #ifdef _LINUX_CAPABILITY_VERSION
141 g_string_append(str, " (Linux)");
142 #endif /* _LINUX_CAPABILITY_VERSION */
143 #else /* HAVE_LIBCAP */
144 g_string_append(str, "without POSIX capabilities");
145 #endif /* HAVE_LIBCAP */
149 /* This is a Linux-specific library. */
151 g_string_append(str, ", ");
152 #if defined(HAVE_LIBNL1)
153 g_string_append(str, "with libnl 1");
154 #elif defined(HAVE_LIBNL2)
155 g_string_append(str, "with libnl 2");
156 #elif defined(HAVE_LIBNL3)
157 g_string_append(str, "with libnl 3");
159 g_string_append(str, "without libnl");
160 #endif /* libnl version */
161 #endif /* __linux__ */
163 /* Additional application-dependent information */
166 g_string_append(str, ".");
171 static void get_mem_info(GString *str _U_)
174 MEMORYSTATUSEX statex;
176 statex.dwLength = sizeof (statex);
178 if(GlobalMemoryStatusEx (&statex))
179 g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024));
185 * Get various library run-time versions, and the OS version, and append
186 * them to the specified GString.
189 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
195 g_string_append(str, "on ");
197 get_os_version_info(str);
201 if ((lang = getenv ("LANG")) != NULL)
202 g_string_append_printf(str, ", with locale %s", lang);
204 g_string_append(str, ", without locale");
208 g_string_append(str, ", ");
209 get_runtime_pcap_version(str);
212 #if defined(HAVE_LIBZ) && !defined(_WIN32)
213 g_string_append_printf(str, ", with libz %s", zlibVersion());
216 /* Additional application-dependent information */
218 (*additional_info)(str);
220 g_string_append(str, ".");
225 /* Get info about installed memory Windows only */
229 get_compiler_info(str);
236 * Get the major OS version.
238 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
240 get_os_major_version()
243 info.dwOSVersionInfoSize = sizeof info;
244 if (GetVersionEx(&info)) {
245 return info.dwMajorVersion;
257 * indent-tabs-mode: t
260 * ex: set shiftwidth=8 tabstop=8 noexpandtab:
261 * :indentSize=8:tabSize=8:noTabs=false: