Fix bugs I introduced. Now
[metze/wireshark/wip.git] / version_info.c
1 /* version_info.c
2  * Routines to report version information for stuff used by Wireshark
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #include "config.h"
26
27 #include <glib.h>
28
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <errno.h>
33
34 #ifdef HAVE_LIBZ
35 #include <zlib.h>       /* to get the libz version number */
36 #endif
37
38 #ifdef HAVE_SYS_UTSNAME_H
39 #include <sys/utsname.h>
40 #endif
41
42 #include "version_info.h"
43 #include "capture-pcap-util.h"
44 #include <wsutil/unicode-utils.h>
45
46 #include "svnversion.h"
47
48 #ifdef HAVE_WINDOWS_H
49 #include <windows.h>
50 #endif
51
52 #ifdef HAVE_OS_X_FRAMEWORKS
53 #include <CoreFoundation/CoreFoundation.h>
54 #include "cfutils.h"
55 #endif
56
57 #ifdef HAVE_LIBCAP
58 # include <sys/capability.h>
59 #endif
60
61 #ifdef SVNVERSION
62         const char *wireshark_svnversion = " (" SVNVERSION " from " SVNPATH ")";
63 #else
64         const char *wireshark_svnversion = "";
65 #endif
66
67 /*
68  * If the string doesn't end with a newline, append one.
69  * Then word-wrap it to 80 columns.
70  */
71 static void
72 end_string(GString *str)
73 {
74         size_t point;
75         char *p, *q;
76
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) {
84                         /*
85                          * Break at or before this point.
86                          */
87                         q = p + 80;
88                         while (q > p && *q != ' ')
89                                 q--;
90                         if (q != p)
91                                 *q = '\n';
92                 }
93                 p = q + 1;
94         }
95 }
96
97 /*
98  * Get various library compile-time versions and append them to
99  * the specified GString.
100  *
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.
105  */
106 void
107 get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
108                           void (*append_info)(GString *))
109 {
110         if (sizeof(str) == 4)
111                 g_string_append(str, "(32-bit) ");
112         else
113                 g_string_append(str, "(64-bit) ");
114
115         if (prepend_info)
116                 (*prepend_info)(str);
117
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
127
128         /* Libpcap */
129         g_string_append(str, ", ");
130         get_compiled_pcap_version(str);
131
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 */
144
145         /* LIBCAP */
146         g_string_append(str, ", ");
147 #ifdef HAVE_LIBCAP
148         g_string_append(str, "with POSIX capabilities");
149 #ifdef _LINUX_CAPABILITY_VERSION
150         g_string_append(str, " (Linux)");
151 #endif /* _LINUX_CAPABILITY_VERSION */
152 #else /* HAVE_LIBCAP */
153         g_string_append(str, "without POSIX capabilities");
154 #endif /* HAVE_LIBCAP */
155
156         /* LIBNL */
157         g_string_append(str, ", ");
158 #if defined(HAVE_LIBNL1)
159         g_string_append(str, "with libnl 1");
160 #elif defined(HAVE_LIBNL2)
161         g_string_append(str, "with libnl 2");
162 #elif defined(HAVE_LIBNL3)
163         g_string_append(str, "with libnl 3");
164 #else
165         g_string_append(str, "without libnl");
166 #endif
167
168         /* Additional application-dependent information */
169         if (append_info)
170                 (*append_info)(str);
171         g_string_append(str, ".");
172
173         end_string(str);
174 }
175
176 #ifdef _WIN32
177 typedef void (WINAPI *nativesi_func_ptr)(LPSYSTEM_INFO);
178 #endif
179
180 /*
181  * Handles the rather elaborate process of getting OS version information
182  * from OS X (we want the OS X version, not the Darwin version, the latter
183  * being easy to get with uname()).
184  */
185 #ifdef HAVE_OS_X_FRAMEWORKS
186
187 /*
188  * Fetch a string, as a UTF-8 C string, from a dictionary, given a key.
189  */
190 static char *
191 get_string_from_dictionary(CFPropertyListRef dict, CFStringRef key)
192 {
193         CFStringRef cfstring;
194
195         cfstring = CFDictionaryGetValue(dict, key);
196         if (cfstring == NULL)
197                 return NULL;
198         if (CFGetTypeID(cfstring) != CFStringGetTypeID()) {
199                 /* It isn't a string.  Punt. */
200                 return NULL;
201         }
202         return CFString_to_C_string(cfstring);
203 }
204
205 /*
206  * Get the OS X version information, and append it to the GString.
207  * Return TRUE if we succeed, FALSE if we fail.
208  */
209 static gboolean
210 get_os_x_version_info(GString *str)
211 {
212         static const UInt8 server_version_plist_path[] =
213             "/System/Library/CoreServices/ServerVersion.plist";
214         static const UInt8 system_version_plist_path[] =
215             "/System/Library/CoreServices/SystemVersion.plist";
216         CFURLRef version_plist_file_url;
217         CFReadStreamRef version_plist_stream;
218         CFDictionaryRef version_dict;
219         char *string;
220
221         /*
222          * On OS X, report the OS X version number as the OS, and put
223          * the Darwin information in parentheses.
224          *
225          * Alas, Gestalt() is deprecated in Mountain Lion, so the build
226          * fails if you treat deprecation warnings as fatal.  I don't
227          * know of any replacement API, so we fall back on reading
228          * /System/Library/CoreServices/ServerVersion.plist if it
229          * exists, otherwise /System/Library/CoreServices/SystemVersion.plist,
230          * and using ProductUserVisibleVersion.  We also get the build
231          * version from ProductBuildVersion and the product name from
232          * ProductName.
233          */
234         version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
235             server_version_plist_path, sizeof server_version_plist_path - 1,
236             false);
237         if (version_plist_file_url == NULL)
238                 return FALSE;
239         version_plist_stream = CFReadStreamCreateWithFile(NULL,
240             version_plist_file_url);
241         CFRelease(version_plist_file_url);
242         if (version_plist_stream == NULL)
243                 return FALSE;
244         if (!CFReadStreamOpen(version_plist_stream)) {
245                 CFRelease(version_plist_stream);
246
247                 /*
248                  * Try SystemVersion.plist.
249                  */
250                 version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
251                     system_version_plist_path, sizeof system_version_plist_path - 1,
252                     false);
253                 if (version_plist_file_url == NULL)
254                         return FALSE;
255                 version_plist_stream = CFReadStreamCreateWithFile(NULL,
256                     version_plist_file_url);
257                 CFRelease(version_plist_file_url);
258                 if (version_plist_stream == NULL)
259                         return FALSE;
260                 if (!CFReadStreamOpen(version_plist_stream)) {
261                         CFRelease(version_plist_stream);
262                         return FALSE;
263                 }
264         }
265 #ifdef HAVE_CFPROPERTYLISTCREATEWITHSTREAM
266         version_dict = CFPropertyListCreateWithStream(NULL,
267             version_plist_stream, 0, kCFPropertyListImmutable,
268             NULL, NULL);
269 #else
270         version_dict = CFPropertyListCreateFromStream(NULL,
271             version_plist_stream, 0, kCFPropertyListImmutable,
272             NULL, NULL);
273 #endif
274         if (version_dict == NULL)
275                 return FALSE;
276         if (CFGetTypeID(version_dict) != CFDictionaryGetTypeID()) {
277                 /* This is *supposed* to be a dictionary.  Punt. */
278                 CFRelease(version_dict);
279                 CFReadStreamClose(version_plist_stream);
280                 CFRelease(version_plist_stream);
281                 return FALSE;
282         }
283         /* Get the product name string. */
284         string = get_string_from_dictionary(version_dict,
285             CFSTR("ProductName"));
286         if (string == NULL) {
287                 CFRelease(version_dict);
288                 CFReadStreamClose(version_plist_stream);
289                 CFRelease(version_plist_stream);
290                 return FALSE;
291         }
292         g_string_append_printf(str, "%s", string);
293         g_free(string);
294
295         /* Get the OS version string. */
296         string = get_string_from_dictionary(version_dict,
297             CFSTR("ProductUserVisibleVersion"));
298         if (string == NULL) {
299                 CFRelease(version_dict);
300                 CFReadStreamClose(version_plist_stream);
301                 CFRelease(version_plist_stream);
302                 return FALSE;
303         }
304         g_string_append_printf(str, " %s", string);
305         g_free(string);
306
307         /* Get the build string */
308         string = get_string_from_dictionary(version_dict,
309             CFSTR("ProductBuildVersion"));
310         if (string == NULL) {
311                 CFRelease(version_dict);
312                 CFReadStreamClose(version_plist_stream);
313                 CFRelease(version_plist_stream);
314                 return FALSE;
315         }
316         g_string_append_printf(str, ", build %s", string);
317         g_free(string);
318         CFRelease(version_dict);
319         CFReadStreamClose(version_plist_stream);
320         CFRelease(version_plist_stream);
321         return TRUE;
322 }
323 #endif
324
325 /*
326  * Get the OS version, and append it to the GString
327  */
328 void get_os_version_info(GString *str)
329 {
330 #if defined(_WIN32)
331         OSVERSIONINFOEX info;
332         SYSTEM_INFO system_info;
333         nativesi_func_ptr nativesi_func;
334 #elif defined(HAVE_SYS_UTSNAME_H)
335         struct utsname name;
336 #endif
337
338 #if defined(_WIN32)
339         /*
340          * See
341          *
342          *      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
343          *
344          * for more than you ever wanted to know about determining the
345          * flavor of Windows on which you're running.  Implementing more
346          * of that is left as an exercise to the reader - who should
347          * check any copyright information about code samples on MSDN
348          * before cutting and pasting into Wireshark.
349          *
350          * They should also note that you need an OSVERSIONINFOEX structure
351          * to get some of that information, and that not only is that
352          * structure not supported on older versions of Windows, you might
353          * not even be able to compile code that *uses* that structure with
354          * older versions of the SDK.
355          */
356
357         memset(&info, '\0', sizeof info);
358         info.dwOSVersionInfoSize = sizeof info;
359         if (!GetVersionEx((OSVERSIONINFO *)&info)) {
360                 /*
361                  * XXX - get the failure reason.
362                  */
363                 g_string_append(str, "unknown Windows version");
364                 return;
365         }
366
367         memset(&system_info, '\0', sizeof system_info);
368         /* Look for and use the GetNativeSystemInfo() function if available to get the correct processor
369          * architecture even when running 32-bit Wireshark in WOW64 (x86 emulation on 64-bit Windows) */
370         nativesi_func = (nativesi_func_ptr)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo");
371         if(nativesi_func)
372                 nativesi_func(&system_info);
373         else
374                 GetSystemInfo(&system_info);
375
376         switch (info.dwPlatformId) {
377
378         case VER_PLATFORM_WIN32s:
379                 /* Shyeah, right. */
380                 g_string_append_printf(str, "Windows 3.1 with Win32s");
381                 break;
382
383         case VER_PLATFORM_WIN32_WINDOWS:
384                 /* Windows OT */
385                 switch (info.dwMajorVersion) {
386
387                 case 4:
388                         /* 3 cheers for Microsoft marketing! */
389                         switch (info.dwMinorVersion) {
390
391                         case 0:
392                                 g_string_append_printf(str, "Windows 95");
393                                 break;
394
395                         case 10:
396                                 g_string_append_printf(str, "Windows 98");
397                                 break;
398
399                         case 90:
400                                 g_string_append_printf(str, "Windows Me");
401                                 break;
402
403                         default:
404                                 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
405                                     info.dwMajorVersion, info.dwMinorVersion);
406                                 break;
407                         }
408                         break;
409
410                 default:
411                         g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
412                             info.dwMajorVersion, info.dwMinorVersion);
413                         break;
414                 }
415                 break;
416
417         case VER_PLATFORM_WIN32_NT:
418                 /* Windows NT */
419                 switch (info.dwMajorVersion) {
420
421                 case 3:
422                 case 4:
423                         g_string_append_printf(str, "Windows NT %lu.%lu",
424                             info.dwMajorVersion, info.dwMinorVersion);
425                         break;
426
427                 case 5:
428                         /* 3 cheers for Microsoft marketing! */
429                         switch (info.dwMinorVersion) {
430
431                         case 0:
432                                 g_string_append_printf(str, "Windows 2000");
433                                 break;
434
435                         case 1:
436                                 g_string_append_printf(str, "Windows XP");
437                                 break;
438
439                         case 2:
440                                 if ((info.wProductType == VER_NT_WORKSTATION) &&
441                                     (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
442                                         g_string_append_printf(str, "Windows XP Professional x64 Edition");
443                                 } else {
444                                         g_string_append_printf(str, "Windows Server 2003");
445                                         if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
446                                                 g_string_append_printf(str, " x64 Edition");
447                                 }
448                                 break;
449
450                         default:
451                                 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
452                                                        info.dwMajorVersion, info.dwMinorVersion);
453                                 break;
454                         }
455                         break;
456
457                 case 6: {
458                         gboolean is_nt_workstation;
459
460                         if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
461                                 g_string_append(str, "64-bit ");
462                         else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
463                                 g_string_append(str, "32-bit ");
464 #ifndef VER_NT_WORKSTATION
465 #define VER_NT_WORKSTATION 0x01
466                         is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
467 #else
468                         is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
469 #endif
470                         switch (info.dwMinorVersion) {
471                         case 0:
472                                 g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
473                                 break;
474                         case 1:
475                                 g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
476                                 break;
477                         default:
478                                 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
479                                                        info.dwMajorVersion, info.dwMinorVersion);
480                                 break;
481                         }
482                         break;
483                 }  /* case 6 */
484                 default:
485                         g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
486                             info.dwMajorVersion, info.dwMinorVersion);
487                         break;
488                 } /* info.dwMajorVersion */
489                 break;
490
491         default:
492                 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
493                     info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
494                 break;
495         }
496         if (info.szCSDVersion[0] != '\0')
497                 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
498         g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
499 #elif defined(HAVE_SYS_UTSNAME_H)
500         /*
501          * We have <sys/utsname.h>, so we assume we have "uname()".
502          */
503         if (uname(&name) < 0) {
504                 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
505                     g_strerror(errno));
506                 return;
507         }
508
509         if (strcmp(name.sysname, "AIX") == 0) {
510                 /*
511                  * Yay, IBM!  Thanks for doing something different
512                  * from most of the other UNIXes out there, and
513                  * making "name.version" apparently be the major
514                  * version number and "name.release" be the minor
515                  * version number.
516                  */
517                 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
518                     name.release);
519         } else {
520                 /*
521                  * XXX - get "version" on any other platforms?
522                  *
523                  * On Digital/Tru64 UNIX, it's something unknown.
524                  * On Solaris, it's some kind of build information.
525                  * On HP-UX, it appears to be some sort of subrevision
526                  * thing.
527                  * On *BSD and Darwin/OS X, it's a long string giving
528                  * a build date, config file name, etc., etc., etc..
529                  */
530 #ifdef HAVE_OS_X_FRAMEWORKS
531                 /*
532                  * On Mac OS X, report the Mac OS X version number as
533                  * the OS version if we can, and put the Darwin information
534                  * in parentheses.
535                  */
536                 if (get_os_x_version_info(str)) {
537                         /* Success - append the Darwin information. */
538                         g_string_append_printf(str, " (%s %s)", name.sysname, name.release);
539                 } else {
540                         /* Failure - just use the Darwin information. */
541                         g_string_append_printf(str, "%s %s", name.sysname, name.release);
542                 }
543 #else /* HAVE_OS_X_FRAMEWORKS */
544                 /*
545                  * XXX - on Linux, are there any APIs to get the distribution
546                  * name and version number?  I think some distributions have
547                  * that.
548                  *
549                  * At least on Linux Standard Base-compliant distributions,
550                  * there's an "lsb_release" command.  However:
551                  *
552                  *      http://forums.fedoraforum.org/showthread.php?t=220885
553                  *
554                  * seems to suggest that if you don't have the redhat-lsb
555                  * package installed, you don't have lsb_release, and that
556                  * /etc/fedora-release has the release information on
557                  * Fedora.
558                  *
559                  *      http://linux.die.net/man/1/lsb_release
560                  *
561                  * suggests that there's an /etc/distrib-release file, but
562                  * it doesn't indicate whether "distrib" is literally
563                  * "distrib" or is the name for the distribution, and
564                  * also speaks of an /etc/debian_version file.
565                  *
566                  * "lsb_release" apparently parses /etc/lsb-release, which
567                  * has shell-style assignments, assigning to, among other
568                  * values, DISTRIB_ID (distributor/distribution name),
569                  * DISTRIB_RELEASE (release number of the distribution),
570                  * DISTRIB_DESCRIPTION (*might* be name followed by version,
571                  * but the manpage for lsb_release seems to indicate that's
572                  * not guaranteed), and DISTRIB_CODENAME (code name, e.g.
573                  * "licentious" for the Ubuntu Licentious Lemur release).
574                  * the lsb_release man page also speaks of the distrib-release
575                  * file, but Debian doesn't have one, and Ubuntu 7's
576                  * lsb_release command doesn't look for one.
577                  *
578                  * I've seen references to /etc/redhat-release as well.
579                  *
580                  * At least on my Ubuntu 7 system, /etc/debian_version
581                  * doesn't contain anything interesting (just some Debian
582                  * codenames).
583                  *
584                  * See also
585                  *
586                  *      http://bugs.python.org/issue1322
587                  *
588                  *      http://www.novell.com/coolsolutions/feature/11251.html
589                  *
590                  *      http://linuxmafia.com/faq/Admin/release-files.html
591                  *
592                  * and the Lib/Platform.py file in recent Python 2.x
593                  * releases.
594                  */
595                 g_string_append_printf(str, "%s %s", name.sysname, name.release);
596 #endif /* HAVE_OS_X_FRAMEWORKS */
597         }
598 #else
599         g_string_append(str, "an unknown OS");
600 #endif
601 }
602
603
604 /*
605  * Get various library run-time versions, and the OS version, and append
606  * them to the specified GString.
607  */
608 void
609 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
610 {
611 #ifndef _WIN32
612         gchar *lang;
613 #endif
614
615         g_string_append(str, "on ");
616
617         get_os_version_info(str);
618
619 #ifndef _WIN32
620         /* Locale */
621         if ((lang = getenv ("LANG")) != NULL)
622                 g_string_append_printf(str, ", with locale %s", lang);
623         else
624                 g_string_append(str, ", without locale");
625 #endif
626
627         /* Libpcap */
628         g_string_append(str, ", ");
629         get_runtime_pcap_version(str);
630
631         /* zlib */
632 #if defined(HAVE_LIBZ) && !defined(_WIN32)
633         g_string_append_printf(str, ", with libz %s", zlibVersion());
634 #endif
635
636         /* Additional application-dependent information */
637         if (additional_info)
638                 (*additional_info)(str);
639
640         g_string_append(str, ".");
641
642         /* Compiler info */
643
644         /*
645          * See https://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
646          * information on various defined strings.
647          *
648          * GCC's __VERSION__ is a nice text string for humans to
649          * read.  The page at sourceforge.net largely describes
650          * numeric #defines that encode the version; if the compiler
651          * doesn't also offer a nice printable string, we try prettifying
652          * the number somehow.
653          */
654 #if defined(__GNUC__) && defined(__VERSION__)
655         /*
656          * Clang and llvm-gcc also define __GNUC__ and __VERSION__;
657          * distinguish between them.
658          */
659 #if defined(__clang__)
660         g_string_append_printf(str, "\n\nBuilt using clang %s.\n", __VERSION__);
661 #elif defined(__llvm__)
662         g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
663 #else /* boring old GCC */
664         g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
665 #endif /* llvm */
666 #elif defined(__HP_aCC)
667         g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
668 #elif defined(__xlC__)
669         g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
670             (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
671 #ifdef __IBMC__
672         if ((__IBMC__ % 10) != 0)
673                 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
674 #endif /* __IBMC__ */
675         g_string_append_printf(str, "\n");
676 #elif defined(__INTEL_COMPILER)
677         g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
678             __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
679         if ((__INTEL_COMPILER % 10) != 0)
680                 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
681 #ifdef __INTEL_COMPILER_BUILD_DATE
682         g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
683             __INTEL_COMPILER_BUILD_DATE / 10000,
684             (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
685             __INTEL_COMPILER_BUILD_DATE % 100);
686 #endif /* __INTEL_COMPILER_BUILD_DATE */
687         g_string_append_printf(str, "\n");
688 #elif defined(_MSC_FULL_VER)
689 # if _MSC_FULL_VER > 99999999
690         g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
691                                (_MSC_FULL_VER / 10000000) - 6,
692                                (_MSC_FULL_VER / 100000) % 100);
693 #  if (_MSC_FULL_VER % 100000) != 0
694         g_string_append_printf(str, " build %d",
695                                _MSC_FULL_VER % 100000);
696 #  endif
697 # else
698         g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
699                                (_MSC_FULL_VER / 1000000) - 6,
700                                (_MSC_FULL_VER / 10000) % 100);
701 #  if (_MSC_FULL_VER % 10000) != 0
702         g_string_append_printf(str, " build %d",
703                                _MSC_FULL_VER % 10000);
704 #  endif
705 # endif
706         g_string_append_printf(str, "\n");
707 #elif defined(_MSC_VER)
708         /* _MSC_FULL_VER not defined, but _MSC_VER defined */
709         g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
710             (_MSC_VER / 100) - 6, _MSC_VER % 100);
711 #elif defined(__SUNPRO_C)
712         g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
713             (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
714         if ((__SUNPRO_C & 0xF) != 0)
715                 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
716         g_string_append_printf(str, "\n");
717 #endif
718
719         end_string(str);
720 }
721
722 /*
723  * Get copyright information.
724  */
725 const char *
726 get_copyright_info(void)
727 {
728         return
729 "Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.\n"
730 "This is free software; see the source for copying conditions. There is NO\n"
731 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
732 }
733
734 #if defined(_WIN32)
735 /*
736  * Get the major OS version.
737  */
738 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
739 guint32
740 get_os_major_version()
741 {
742         OSVERSIONINFO info;
743         info.dwOSVersionInfoSize = sizeof info;
744         if (GetVersionEx(&info)) {
745                 return info.dwMajorVersion;
746         }
747         return 0;
748 }
749 #endif
750
751 /*
752  * Editor modelines
753  *
754  * Local Variables:
755  * c-basic-offset: 8
756  * tab-width: 8
757  * indent-tabs-mode: t
758  * End:
759  *
760  * ex: set shiftwidth=8 tabstop=8 noexpandtab:
761  * :indentSize=8:tabSize=8:noTabs=false:
762  */