HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / version_info.c
blobb1e9d8b4ff414e745ba9ba7771057676eff5d46a
1 /* version_info.c
2 * Routines to report version information for stuff used by Wireshark
4 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "config.h"
27 #include <glib.h>
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <errno.h>
34 #ifdef HAVE_LIBZ
35 #include <zlib.h> /* to get the libz version number */
36 #endif
38 #ifdef HAVE_SYS_UTSNAME_H
39 #include <sys/utsname.h>
40 #endif
42 #include "version_info.h"
43 #include "capture-pcap-util.h"
44 #include <wsutil/unicode-utils.h>
46 #include "svnversion.h"
48 #ifdef HAVE_WINDOWS_H
49 #include <windows.h>
50 #endif
52 #ifdef HAVE_OS_X_FRAMEWORKS
53 #include <CoreFoundation/CoreFoundation.h>
54 #include "cfutils.h"
55 #endif
57 #ifdef HAVE_LIBCAP
58 # include <sys/capability.h>
59 #endif
61 #ifdef SVNVERSION
62 const char *wireshark_svnversion = " (" SVNVERSION " from " SVNPATH ")";
63 #else
64 const char *wireshark_svnversion = "";
65 #endif
68 * If the string doesn't end with a newline, append one.
69 * Then word-wrap it to 80 columns.
71 static void
72 end_string(GString *str)
74 size_t point;
75 char *p, *q;
77 point = str->len;
78 if (point == 0 || str->str[point - 1] != '\n')
79 g_string_append(str, "\n");
80 p = str->str;
81 while (*p != '\0') {
82 q = strchr(p, '\n');
83 if (q - p > 80) {
85 * Break at or before this point.
87 q = p + 80;
88 while (q > p && *q != ' ')
89 q--;
90 if (q != p)
91 *q = '\n';
93 p = q + 1;
98 * Get various library compile-time versions and append them to
99 * the specified GString.
101 * "additional_info" is called at the end to append any additional
102 * information; this is required in order to, for example, put the
103 * Portaudio information at the end of the string, as we currently
104 * don't use Portaudio in TShark.
106 void
107 get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
108 void (*append_info)(GString *))
110 if (sizeof(str) == 4)
111 g_string_append(str, "(32-bit) ");
112 else
113 g_string_append(str, "(64-bit) ");
115 if (prepend_info)
116 (*prepend_info)(str);
118 /* GLIB */
119 g_string_append(str, "with ");
120 g_string_append_printf(str,
121 #ifdef GLIB_MAJOR_VERSION
122 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
123 GLIB_MICRO_VERSION);
124 #else
125 "GLib (version unknown)");
126 #endif
128 /* Libpcap */
129 g_string_append(str, ", ");
130 get_compiled_pcap_version(str);
132 /* LIBZ */
133 g_string_append(str, ", ");
134 #ifdef HAVE_LIBZ
135 g_string_append(str, "with libz ");
136 #ifdef ZLIB_VERSION
137 g_string_append(str, ZLIB_VERSION);
138 #else /* ZLIB_VERSION */
139 g_string_append(str, "(version unknown)");
140 #endif /* ZLIB_VERSION */
141 #else /* HAVE_LIBZ */
142 g_string_append(str, "without libz");
143 #endif /* HAVE_LIBZ */
145 #ifndef _WIN32
146 /* This is UN*X-only. */
147 /* LIBCAP */
148 g_string_append(str, ", ");
149 #ifdef HAVE_LIBCAP
150 g_string_append(str, "with POSIX capabilities");
151 #ifdef _LINUX_CAPABILITY_VERSION
152 g_string_append(str, " (Linux)");
153 #endif /* _LINUX_CAPABILITY_VERSION */
154 #else /* HAVE_LIBCAP */
155 g_string_append(str, "without POSIX capabilities");
156 #endif /* HAVE_LIBCAP */
157 #endif /* _WIN32 */
159 #ifdef __linux__
160 /* This is a Linux-specific library. */
161 /* LIBNL */
162 g_string_append(str, ", ");
163 #if defined(HAVE_LIBNL1)
164 g_string_append(str, "with libnl 1");
165 #elif defined(HAVE_LIBNL2)
166 g_string_append(str, "with libnl 2");
167 #elif defined(HAVE_LIBNL3)
168 g_string_append(str, "with libnl 3");
169 #else /* no libnl */
170 g_string_append(str, "without libnl");
171 #endif /* libnl version */
172 #endif /* __linux__ */
174 /* Additional application-dependent information */
175 if (append_info)
176 (*append_info)(str);
177 g_string_append(str, ".");
179 end_string(str);
182 #ifdef _WIN32
183 typedef void (WINAPI *nativesi_func_ptr)(LPSYSTEM_INFO);
184 #endif
187 * Handles the rather elaborate process of getting OS version information
188 * from OS X (we want the OS X version, not the Darwin version, the latter
189 * being easy to get with uname()).
191 #ifdef HAVE_OS_X_FRAMEWORKS
194 * Fetch a string, as a UTF-8 C string, from a dictionary, given a key.
196 static char *
197 get_string_from_dictionary(CFPropertyListRef dict, CFStringRef key)
199 CFStringRef cfstring;
201 cfstring = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)dict,
202 (const void *)key);
203 if (cfstring == NULL)
204 return NULL;
205 if (CFGetTypeID(cfstring) != CFStringGetTypeID()) {
206 /* It isn't a string. Punt. */
207 return NULL;
209 return CFString_to_C_string(cfstring);
213 * Get the OS X version information, and append it to the GString.
214 * Return TRUE if we succeed, FALSE if we fail.
216 static gboolean
217 get_os_x_version_info(GString *str)
219 static const UInt8 server_version_plist_path[] =
220 "/System/Library/CoreServices/ServerVersion.plist";
221 static const UInt8 system_version_plist_path[] =
222 "/System/Library/CoreServices/SystemVersion.plist";
223 CFURLRef version_plist_file_url;
224 CFReadStreamRef version_plist_stream;
225 CFDictionaryRef version_dict;
226 char *string;
229 * On OS X, report the OS X version number as the OS, and put
230 * the Darwin information in parentheses.
232 * Alas, Gestalt() is deprecated in Mountain Lion, so the build
233 * fails if you treat deprecation warnings as fatal. I don't
234 * know of any replacement API, so we fall back on reading
235 * /System/Library/CoreServices/ServerVersion.plist if it
236 * exists, otherwise /System/Library/CoreServices/SystemVersion.plist,
237 * and using ProductUserVisibleVersion. We also get the build
238 * version from ProductBuildVersion and the product name from
239 * ProductName.
241 version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
242 server_version_plist_path, sizeof server_version_plist_path - 1,
243 false);
244 if (version_plist_file_url == NULL)
245 return FALSE;
246 version_plist_stream = CFReadStreamCreateWithFile(NULL,
247 version_plist_file_url);
248 CFRelease(version_plist_file_url);
249 if (version_plist_stream == NULL)
250 return FALSE;
251 if (!CFReadStreamOpen(version_plist_stream)) {
252 CFRelease(version_plist_stream);
255 * Try SystemVersion.plist.
257 version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
258 system_version_plist_path, sizeof system_version_plist_path - 1,
259 false);
260 if (version_plist_file_url == NULL)
261 return FALSE;
262 version_plist_stream = CFReadStreamCreateWithFile(NULL,
263 version_plist_file_url);
264 CFRelease(version_plist_file_url);
265 if (version_plist_stream == NULL)
266 return FALSE;
267 if (!CFReadStreamOpen(version_plist_stream)) {
268 CFRelease(version_plist_stream);
269 return FALSE;
272 #ifdef HAVE_CFPROPERTYLISTCREATEWITHSTREAM
273 version_dict = (CFDictionaryRef)CFPropertyListCreateWithStream(NULL,
274 version_plist_stream, 0, kCFPropertyListImmutable,
275 NULL, NULL);
276 #else
277 version_dict = (CFDictionaryRef)CFPropertyListCreateFromStream(NULL,
278 version_plist_stream, 0, kCFPropertyListImmutable,
279 NULL, NULL);
280 #endif
281 if (version_dict == NULL) {
282 CFRelease(version_plist_stream);
283 return FALSE;
285 if (CFGetTypeID(version_dict) != CFDictionaryGetTypeID()) {
286 /* This is *supposed* to be a dictionary. Punt. */
287 CFRelease(version_dict);
288 CFReadStreamClose(version_plist_stream);
289 CFRelease(version_plist_stream);
290 return FALSE;
292 /* Get the product name string. */
293 string = get_string_from_dictionary(version_dict,
294 CFSTR("ProductName"));
295 if (string == NULL) {
296 CFRelease(version_dict);
297 CFReadStreamClose(version_plist_stream);
298 CFRelease(version_plist_stream);
299 return FALSE;
301 g_string_append_printf(str, "%s", string);
302 g_free(string);
304 /* Get the OS version string. */
305 string = get_string_from_dictionary(version_dict,
306 CFSTR("ProductUserVisibleVersion"));
307 if (string == NULL) {
308 CFRelease(version_dict);
309 CFReadStreamClose(version_plist_stream);
310 CFRelease(version_plist_stream);
311 return FALSE;
313 g_string_append_printf(str, " %s", string);
314 g_free(string);
316 /* Get the build string */
317 string = get_string_from_dictionary(version_dict,
318 CFSTR("ProductBuildVersion"));
319 if (string == NULL) {
320 CFRelease(version_dict);
321 CFReadStreamClose(version_plist_stream);
322 CFRelease(version_plist_stream);
323 return FALSE;
325 g_string_append_printf(str, ", build %s", string);
326 g_free(string);
327 CFRelease(version_dict);
328 CFReadStreamClose(version_plist_stream);
329 CFRelease(version_plist_stream);
330 return TRUE;
332 #endif
335 * Get the OS version, and append it to the GString
337 void get_os_version_info(GString *str)
339 #if defined(_WIN32)
340 OSVERSIONINFOEX info;
341 SYSTEM_INFO system_info;
342 nativesi_func_ptr nativesi_func;
343 #elif defined(HAVE_SYS_UTSNAME_H)
344 struct utsname name;
345 #endif
347 #if defined(_WIN32)
349 * See
351 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
353 * for more than you ever wanted to know about determining the
354 * flavor of Windows on which you're running. Implementing more
355 * of that is left as an exercise to the reader - who should
356 * check any copyright information about code samples on MSDN
357 * before cutting and pasting into Wireshark.
359 * They should also note that you need an OSVERSIONINFOEX structure
360 * to get some of that information, and that not only is that
361 * structure not supported on older versions of Windows, you might
362 * not even be able to compile code that *uses* that structure with
363 * older versions of the SDK.
366 memset(&info, '\0', sizeof info);
367 info.dwOSVersionInfoSize = sizeof info;
368 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
370 * XXX - get the failure reason.
372 g_string_append(str, "unknown Windows version");
373 return;
376 memset(&system_info, '\0', sizeof system_info);
377 /* Look for and use the GetNativeSystemInfo() function if available to get the correct processor
378 * architecture even when running 32-bit Wireshark in WOW64 (x86 emulation on 64-bit Windows) */
379 nativesi_func = (nativesi_func_ptr)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo");
380 if(nativesi_func)
381 nativesi_func(&system_info);
382 else
383 GetSystemInfo(&system_info);
385 switch (info.dwPlatformId) {
387 case VER_PLATFORM_WIN32s:
388 /* Shyeah, right. */
389 g_string_append_printf(str, "Windows 3.1 with Win32s");
390 break;
392 case VER_PLATFORM_WIN32_WINDOWS:
393 /* Windows OT */
394 switch (info.dwMajorVersion) {
396 case 4:
397 /* 3 cheers for Microsoft marketing! */
398 switch (info.dwMinorVersion) {
400 case 0:
401 g_string_append_printf(str, "Windows 95");
402 break;
404 case 10:
405 g_string_append_printf(str, "Windows 98");
406 break;
408 case 90:
409 g_string_append_printf(str, "Windows Me");
410 break;
412 default:
413 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
414 info.dwMajorVersion, info.dwMinorVersion);
415 break;
417 break;
419 default:
420 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
421 info.dwMajorVersion, info.dwMinorVersion);
422 break;
424 break;
426 case VER_PLATFORM_WIN32_NT:
427 /* Windows NT */
428 switch (info.dwMajorVersion) {
430 case 3:
431 case 4:
432 g_string_append_printf(str, "Windows NT %lu.%lu",
433 info.dwMajorVersion, info.dwMinorVersion);
434 break;
436 case 5:
437 /* 3 cheers for Microsoft marketing! */
438 switch (info.dwMinorVersion) {
440 case 0:
441 g_string_append_printf(str, "Windows 2000");
442 break;
444 case 1:
445 g_string_append_printf(str, "Windows XP");
446 break;
448 case 2:
449 if ((info.wProductType == VER_NT_WORKSTATION) &&
450 (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
451 g_string_append_printf(str, "Windows XP Professional x64 Edition");
452 } else {
453 g_string_append_printf(str, "Windows Server 2003");
454 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
455 g_string_append_printf(str, " x64 Edition");
457 break;
459 default:
460 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
461 info.dwMajorVersion, info.dwMinorVersion);
462 break;
464 break;
466 case 6: {
467 gboolean is_nt_workstation;
469 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
470 g_string_append(str, "64-bit ");
471 else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
472 g_string_append(str, "32-bit ");
473 #ifndef VER_NT_WORKSTATION
474 #define VER_NT_WORKSTATION 0x01
475 is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
476 #else
477 is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
478 #endif
479 switch (info.dwMinorVersion) {
480 case 0:
481 g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
482 break;
483 case 1:
484 g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
485 break;
486 case 2:
487 g_string_append_printf(str, is_nt_workstation ? "Windows 8" : "Windows Server 2012");
488 break;
489 case 3:
490 g_string_append_printf(str, is_nt_workstation ? "Windows 8.1" : "Windows Server 2012 R2");
491 break;
492 default:
493 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
494 info.dwMajorVersion, info.dwMinorVersion);
495 break;
497 break;
498 } /* case 6 */
499 default:
500 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
501 info.dwMajorVersion, info.dwMinorVersion);
502 break;
503 } /* info.dwMajorVersion */
504 break;
506 default:
507 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
508 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
509 break;
511 if (info.szCSDVersion[0] != '\0')
512 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
513 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
514 #elif defined(HAVE_SYS_UTSNAME_H)
516 * We have <sys/utsname.h>, so we assume we have "uname()".
518 if (uname(&name) < 0) {
519 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
520 g_strerror(errno));
521 return;
524 if (strcmp(name.sysname, "AIX") == 0) {
526 * Yay, IBM! Thanks for doing something different
527 * from most of the other UNIXes out there, and
528 * making "name.version" apparently be the major
529 * version number and "name.release" be the minor
530 * version number.
532 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
533 name.release);
534 } else {
536 * XXX - get "version" on any other platforms?
538 * On Digital/Tru64 UNIX, it's something unknown.
539 * On Solaris, it's some kind of build information.
540 * On HP-UX, it appears to be some sort of subrevision
541 * thing.
542 * On *BSD and Darwin/OS X, it's a long string giving
543 * a build date, config file name, etc., etc., etc..
545 #ifdef HAVE_OS_X_FRAMEWORKS
547 * On Mac OS X, report the Mac OS X version number as
548 * the OS version if we can, and put the Darwin information
549 * in parentheses.
551 if (get_os_x_version_info(str)) {
552 /* Success - append the Darwin information. */
553 g_string_append_printf(str, " (%s %s)", name.sysname, name.release);
554 } else {
555 /* Failure - just use the Darwin information. */
556 g_string_append_printf(str, "%s %s", name.sysname, name.release);
558 #else /* HAVE_OS_X_FRAMEWORKS */
560 * XXX - on Linux, are there any APIs to get the distribution
561 * name and version number? I think some distributions have
562 * that.
564 * At least on Linux Standard Base-compliant distributions,
565 * there's an "lsb_release" command. However:
567 * http://forums.fedoraforum.org/showthread.php?t=220885
569 * seems to suggest that if you don't have the redhat-lsb
570 * package installed, you don't have lsb_release, and that
571 * /etc/fedora-release has the release information on
572 * Fedora.
574 * http://linux.die.net/man/1/lsb_release
576 * suggests that there's an /etc/distrib-release file, but
577 * it doesn't indicate whether "distrib" is literally
578 * "distrib" or is the name for the distribution, and
579 * also speaks of an /etc/debian_version file.
581 * "lsb_release" apparently parses /etc/lsb-release, which
582 * has shell-style assignments, assigning to, among other
583 * values, DISTRIB_ID (distributor/distribution name),
584 * DISTRIB_RELEASE (release number of the distribution),
585 * DISTRIB_DESCRIPTION (*might* be name followed by version,
586 * but the manpage for lsb_release seems to indicate that's
587 * not guaranteed), and DISTRIB_CODENAME (code name, e.g.
588 * "licentious" for the Ubuntu Licentious Lemur release).
589 * the lsb_release man page also speaks of the distrib-release
590 * file, but Debian doesn't have one, and Ubuntu 7's
591 * lsb_release command doesn't look for one.
593 * I've seen references to /etc/redhat-release as well.
595 * At least on my Ubuntu 7 system, /etc/debian_version
596 * doesn't contain anything interesting (just some Debian
597 * codenames).
599 * See also
601 * http://bugs.python.org/issue1322
603 * http://www.novell.com/coolsolutions/feature/11251.html
605 * http://linuxmafia.com/faq/Admin/release-files.html
607 * and the Lib/Platform.py file in recent Python 2.x
608 * releases.
610 g_string_append_printf(str, "%s %s", name.sysname, name.release);
611 #endif /* HAVE_OS_X_FRAMEWORKS */
613 #else
614 g_string_append(str, "an unknown OS");
615 #endif
620 * Get the CPU info, and append it to the GString
623 #if defined(_MSC_VER)
624 static void
625 do_cpuid(int *CPUInfo, guint32 selector){
626 __cpuid(CPUInfo, selector);
628 #elif defined(__GNUC__)
629 #if defined(__x86_64__)
630 static inline void
631 do_cpuid(guint32 *CPUInfo, int selector)
633 __asm__ __volatile__("cpuid"
634 : "=a" (CPUInfo[0]),
635 "=b" (CPUInfo[1]),
636 "=c" (CPUInfo[2]),
637 "=d" (CPUInfo[3])
638 : "a"(selector));
640 #else /* (__i386__) */
641 /* would need a test if older proccesors have the cpuid instruction */
642 static void
643 do_cpuid(guint32 *CPUInfo, int selector _U_){
644 CPUInfo[0] = 0;
647 #endif /* defined(__x86_64__)*/
648 #else /* Other compilers */
649 static void
650 do_cpuid(guint32 *CPUInfo, int selector _U_){
651 CPUInfo[0] = 0;
653 #endif
656 * Get CPU info on platforms where the cpuid instruction can be used skip 32 bit versions for GCC
657 * http://www.intel.com/content/dam/www/public/us/en/documents/application-notes/processor-identification-cpuid-instruction-note.pdf
658 * the get_cpuid() routine will return 0 in CPUInfo[0] if cpuinfo isn't available.
661 static void get_cpu_info(GString *str _U_)
663 #if defined(_MSC_VER)
664 int CPUInfo[4];
665 #else
666 guint32 CPUInfo[4];
667 #endif
668 char CPUBrandString[0x40];
669 unsigned nExIds;
671 /* http://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.100).aspx */
673 /* Calling __cpuid with 0x80000000 as the InfoType argument*/
674 /* gets the number of valid extended IDs.*/
675 do_cpuid(CPUInfo, 0x80000000);
676 nExIds = CPUInfo[0];
678 if( nExIds<0x80000005)
679 return;
680 memset(CPUBrandString, 0, sizeof(CPUBrandString));
682 /* Interpret CPU brand string.*/
683 do_cpuid(CPUInfo, 0x80000002);
684 memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
685 do_cpuid(CPUInfo, 0x80000003);
686 memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
687 do_cpuid(CPUInfo, 0x80000004);
688 memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
690 g_string_append_printf(str, "\n%s", CPUBrandString);
694 static void get_mem_info(GString *str _U_)
696 #if defined(_WIN32)
697 MEMORYSTATUSEX statex;
699 statex.dwLength = sizeof (statex);
701 if(GlobalMemoryStatusEx (&statex))
702 g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024));
703 #endif
708 * Get various library run-time versions, and the OS version, and append
709 * them to the specified GString.
711 void
712 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
714 #ifndef _WIN32
715 gchar *lang;
716 #endif
718 g_string_append(str, "on ");
720 get_os_version_info(str);
722 #ifndef _WIN32
723 /* Locale */
724 if ((lang = getenv ("LANG")) != NULL)
725 g_string_append_printf(str, ", with locale %s", lang);
726 else
727 g_string_append(str, ", without locale");
728 #endif
730 /* Libpcap */
731 g_string_append(str, ", ");
732 get_runtime_pcap_version(str);
734 /* zlib */
735 #if defined(HAVE_LIBZ) && !defined(_WIN32)
736 g_string_append_printf(str, ", with libz %s", zlibVersion());
737 #endif
739 /* Additional application-dependent information */
740 if (additional_info)
741 (*additional_info)(str);
743 g_string_append(str, ".");
745 /* CPU Info */
746 get_cpu_info(str);
748 /* Get info about installed memory Windows only */
749 get_mem_info(str);
751 /* Compiler info */
754 * See https://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
755 * information on various defined strings.
757 * GCC's __VERSION__ is a nice text string for humans to
758 * read. The page at sourceforge.net largely describes
759 * numeric #defines that encode the version; if the compiler
760 * doesn't also offer a nice printable string, we try prettifying
761 * the number somehow.
763 #if defined(__GNUC__) && defined(__VERSION__)
765 * Clang and llvm-gcc also define __GNUC__ and __VERSION__;
766 * distinguish between them.
768 #if defined(__clang__)
769 g_string_append_printf(str, "\n\nBuilt using clang %s.\n", __VERSION__);
770 #elif defined(__llvm__)
771 g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
772 #else /* boring old GCC */
773 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
774 #endif /* llvm */
775 #elif defined(__HP_aCC)
776 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
777 #elif defined(__xlC__)
778 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
779 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
780 #ifdef __IBMC__
781 if ((__IBMC__ % 10) != 0)
782 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
783 #endif /* __IBMC__ */
784 g_string_append_printf(str, "\n");
785 #elif defined(__INTEL_COMPILER)
786 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
787 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
788 if ((__INTEL_COMPILER % 10) != 0)
789 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
790 #ifdef __INTEL_COMPILER_BUILD_DATE
791 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
792 __INTEL_COMPILER_BUILD_DATE / 10000,
793 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
794 __INTEL_COMPILER_BUILD_DATE % 100);
795 #endif /* __INTEL_COMPILER_BUILD_DATE */
796 g_string_append_printf(str, "\n");
797 #elif defined(_MSC_FULL_VER)
798 # if _MSC_FULL_VER > 99999999
799 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
800 (_MSC_FULL_VER / 10000000) - 6,
801 (_MSC_FULL_VER / 100000) % 100);
802 # if (_MSC_FULL_VER % 100000) != 0
803 g_string_append_printf(str, " build %d",
804 _MSC_FULL_VER % 100000);
805 # endif
806 # else
807 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
808 (_MSC_FULL_VER / 1000000) - 6,
809 (_MSC_FULL_VER / 10000) % 100);
810 # if (_MSC_FULL_VER % 10000) != 0
811 g_string_append_printf(str, " build %d",
812 _MSC_FULL_VER % 10000);
813 # endif
814 # endif
815 g_string_append_printf(str, "\n");
816 #elif defined(_MSC_VER)
817 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
818 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
819 (_MSC_VER / 100) - 6, _MSC_VER % 100);
820 #elif defined(__SUNPRO_C)
821 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
822 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
823 if ((__SUNPRO_C & 0xF) != 0)
824 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
825 g_string_append_printf(str, "\n");
826 #endif
828 end_string(str);
832 * Get copyright information.
834 const char *
835 get_copyright_info(void)
837 return
838 "Copyright 1998-2013 Gerald Combs <gerald@wireshark.org> and contributors.\n"
839 "This is free software; see the source for copying conditions. There is NO\n"
840 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
843 #if defined(_WIN32)
845 * Get the major OS version.
847 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
848 guint32
849 get_os_major_version()
851 OSVERSIONINFO info;
852 info.dwOSVersionInfoSize = sizeof info;
853 if (GetVersionEx(&info)) {
854 return info.dwMajorVersion;
856 return 0;
858 #endif
861 * Editor modelines
863 * Local Variables:
864 * c-basic-offset: 8
865 * tab-width: 8
866 * indent-tabs-mode: t
867 * End:
869 * ex: set shiftwidth=8 tabstop=8 noexpandtab:
870 * :indentSize=8:tabSize=8:noTabs=false: