2 * Routines to report version information for stuff used by Ethereal
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <zlib.h> /* to get the libz version number */
40 #include <pcre.h> /* to get the libpcre version number */
41 #endif /* HAVE_LIBPCRE */
46 #include <net-snmp/version.h>
47 #endif /* HAVE_NET_SNMP */
50 #include <ucd-snmp/version.h>
51 #endif /* HAVE_UCD_SNMP */
53 #endif /* HAVE_SOME_SNMP */
55 #ifdef HAVE_SYS_UTSNAME_H
56 #include <sys/utsname.h>
59 #include "version_info.h"
60 #include "capture-pcap-util.h"
62 #include "svnversion.h"
73 const char *svnversion = " (" SVNVERSION ")";
75 const char *svnversion = "";
79 * See whether the last line in the string goes past column 80; if so,
80 * replace the blank at the specified point with a newline.
83 do_word_wrap(GString *str, gint point)
87 line_begin = strrchr(str->str, '\n');
88 if (line_begin == NULL)
89 line_begin = str->str;
92 if (strlen(line_begin) > 80) {
93 g_assert(str->str[point] == ' ');
94 str->str[point] = '\n';
99 * If the string doesn't end with a newline, append one.
102 end_string(GString *str)
106 point = strlen(str->str);
107 if (point == 0 || str->str[point - 1] != '\n')
108 g_string_append(str, "\n");
112 * Get various library compile-time versions and append them to
113 * the specified GString.
116 get_compiled_version_info(GString *str)
120 g_string_append(str, "with ");
121 g_string_sprintfa(str,
122 #ifdef GLIB_MAJOR_VERSION
123 "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
126 "GLib (version unknown),");
129 g_string_append(str, " ");
130 break_point = str->len - 1;
131 get_compiled_pcap_version(str);
132 g_string_append(str, ",");
133 do_word_wrap(str, break_point);
135 g_string_append(str, " ");
136 break_point = str->len - 1;
138 g_string_append(str, "with libz ");
140 g_string_append(str, ZLIB_VERSION);
141 #else /* ZLIB_VERSION */
142 g_string_append(str, "(version unknown)");
143 #endif /* ZLIB_VERSION */
144 #else /* HAVE_LIBZ */
145 g_string_append(str, "without libz");
146 #endif /* HAVE_LIBZ */
147 g_string_append(str, ",");
148 do_word_wrap(str, break_point);
150 g_string_append(str, " ");
151 break_point = str->len - 1;
153 g_string_append(str, "with libpcre ");
156 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
157 #else /* PCRE_MINOR */
158 g_string_sprintfa(str, "%u", PCRE_MAJOR);
159 #endif /* PCRE_MINOR */
160 #else /* PCRE_MAJOR */
161 g_string_append(str, "(version unknown)");
162 #endif /* PCRE_MAJOR */
163 #else /* HAVE_LIBPCRE */
164 g_string_append(str, "without libpcre");
165 #endif /* HAVE_LIBPCRE */
167 g_string_append(str, ",");
168 do_word_wrap(str, break_point);
170 /* Oh, this is pretty. */
171 /* Oh, ha. you think that was pretty. Try this:! --Wes */
172 g_string_append(str, " ");
173 break_point = str->len - 1;
174 #ifdef HAVE_SOME_SNMP
177 g_string_append(str, "with UCD-SNMP ");
178 g_string_append(str, VersionInfo);
179 #endif /* HAVE_UCD_SNMP */
182 g_string_append(str, "with Net-SNMP ");
183 g_string_append(str, netsnmp_get_version());
184 #endif /* HAVE_NET_SNMP */
186 #else /* no SNMP library */
187 g_string_append(str, "without UCD-SNMP or Net-SNMP");
188 #endif /* HAVE_SOME_SNMP */
189 g_string_append(str, ",");
190 do_word_wrap(str, break_point);
192 g_string_append(str, " ");
193 break_point = str->len - 1;
195 g_string_append(str, "with ADNS");
197 g_string_append(str, "without ADNS");
198 #endif /* HAVE_GNU_ADNS */
199 g_string_append(str, ",");
201 g_string_append(str, " ");
202 break_point = str->len - 1;
204 g_string_append(str, "with ");
205 g_string_append(str, LUA_VERSION);
207 g_string_append(str, "without Lua");
208 #endif /* HAVE_LUA */
210 g_string_append(str, ".");
211 do_word_wrap(str, break_point);
214 break_point = str->len - 1;
216 "\nNOTE: this build doesn't support the \"matches\" operator for Ethereal filter"
218 do_word_wrap(str, break_point);
219 #endif /* HAVE_LIBPCRE */
225 * Get various library run-time versions, and the OS version, and append
226 * them to the specified GString.
229 get_runtime_version_info(GString *str)
233 #elif defined(HAVE_SYS_UTSNAME_H)
237 get_runtime_pcap_version(str);
239 g_string_append(str, "on ");
244 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
246 * for more than you ever wanted to know about determining the
247 * flavor of Windows on which you're running. Implementing more
248 * of that is left as an exercise to the reader - who should
249 * check any copyright information about code samples on MSDN
250 * before cutting and pasting into Ethereal.
252 * They should also note that you need an OSVERSIONINFOEX structure
253 * to get some of that information, and that not only is that
254 * structure not supported on older versions of Windows, you might
255 * not even be able to compile code that *uses* that structure with
256 * older versions of the SDK.
258 info.dwOSVersionInfoSize = sizeof info;
259 if (!GetVersionEx(&info)) {
261 * XXX - get the failure reason.
263 g_string_append(str, "unknown Windows version");
266 switch (info.dwPlatformId) {
268 case VER_PLATFORM_WIN32s:
270 g_string_sprintfa(str, "Windows 3.1 with Win32s");
273 case VER_PLATFORM_WIN32_WINDOWS:
275 switch (info.dwMajorVersion) {
278 /* 3 cheers for Microsoft marketing! */
279 switch (info.dwMinorVersion) {
282 g_string_sprintfa(str, "Windows 95");
286 g_string_sprintfa(str, "Windows 98");
290 g_string_sprintfa(str, "Windows Me");
294 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
295 info.dwMajorVersion, info.dwMinorVersion);
301 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
302 info.dwMajorVersion, info.dwMinorVersion);
307 case VER_PLATFORM_WIN32_NT:
309 switch (info.dwMajorVersion) {
313 g_string_sprintfa(str, "Windows NT %lu.%lu",
314 info.dwMajorVersion, info.dwMinorVersion);
318 /* 3 cheers for Microsoft marketing! */
319 switch (info.dwMinorVersion) {
322 g_string_sprintfa(str, "Windows 2000");
326 g_string_sprintfa(str, "Windows XP");
330 g_string_sprintfa(str, "Windows Server 2003");
334 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
335 info.dwMajorVersion, info.dwMinorVersion);
341 g_string_sprintfa(str, "Windows Vista");
345 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
346 info.dwMajorVersion, info.dwMinorVersion);
352 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
353 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
356 if (info.szCSDVersion[0] != '\0')
357 g_string_sprintfa(str, " %s", info.szCSDVersion);
358 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
359 #elif defined(HAVE_SYS_UTSNAME_H)
361 * We have <sys/utsname.h>, so we assume we have "uname()".
363 if (uname(&name) < 0) {
364 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
369 if (strcmp(name.sysname, "AIX") == 0) {
371 * Yay, IBM! Thanks for doing something different
372 * from most of the other UNIXes out there, and
373 * making "name.version" apparently be the major
374 * version number and "name.release" be the minor
377 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
381 * XXX - get "version" on any other platforms?
383 * On Digital/Tru65 UNIX, it's something unknown.
384 * On Solaris, it's some kind of build information.
385 * On HP-UX, it appears to be some sort of subrevision
388 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
391 g_string_append(str, "an unknown OS");
393 g_string_append(str, ".");
399 * Get copyright information.
402 get_copyright_info(void)
405 "Copyright 1998-2006 Gerald Combs <gerald@wireshark.org> and contributors.\n"
406 "This is free software; see the source for copying conditions. There is NO\n"
407 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";