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