From Martin Mathieson:
[obnox/wireshark/wip.git] / version_info.c
index 77ea62a544edc5a9874c145b015d6f75649c3c59..b9cfde4552945877a0ce6bf0daeb4134e71137af 100644 (file)
 # include "config.h"
 #endif
 
-#ifdef HAVE_LIBPCAP
-#include <pcap.h>
-#endif /* HAVE_LIBPCAP */
-
 #include <glib.h>
 
 #include <stdlib.h>
 #include <pcre.h>      /* to get the libpcre version number */
 #endif /* HAVE_LIBPCRE */
 
-/*
- * This has to come after the include of <pcap.h>, as the include of
- * <pcap.h> might cause <winsock2.h> to be included, and if we've
- * already included <winsock.h> as a result of including <windows.h>,
- * we get a bunch of redefinitions.
- */
-#ifdef HAVE_WINDOWS_H
-#include <windows.h>
-#endif
-
 #ifdef HAVE_SOME_SNMP
 
 #ifdef HAVE_NET_SNMP
 #endif
 
 #include "version_info.h"
-#include "pcap-util.h"
+#include "capture-pcap-util.h"
+
+#include "svnversion.h"
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#ifdef HAVE_LUA
+#include <lua.h>
+#endif
+
+#ifdef SVNVERSION
+       const char *svnversion = " (" SVNVERSION ")";
+#else
+       const char *svnversion = "";
+#endif
 
 /*
  * See whether the last line in the string goes past column 80; if so,
@@ -93,6 +95,19 @@ do_word_wrap(GString *str, gint point)
        }
 }      
 
+/*
+ * If the string doesn't end with a newline, append one.
+ */
+static void
+end_string(GString *str)
+{
+       size_t point;
+
+       point = strlen(str->str);
+       if (point == 0 || str->str[point - 1] != '\n')
+               g_string_append(str, "\n");
+}      
+
 /*
  * Get various library compile-time versions and append them to
  * the specified GString.
@@ -181,6 +196,16 @@ get_compiled_version_info(GString *str)
 #else
        g_string_append(str, "without ADNS");
 #endif /* HAVE_GNU_ADNS */
+       g_string_append(str, ",");
+
+       g_string_append(str, " ");
+       break_point = str->len - 1;
+#ifdef HAVE_LUA
+       g_string_append(str, "with ");
+       g_string_append(str, LUA_VERSION);
+#else
+       g_string_append(str, "without Lua");
+#endif /* HAVE_LUA */
 
        g_string_append(str, ".");
        do_word_wrap(str, break_point);
@@ -188,10 +213,12 @@ get_compiled_version_info(GString *str)
 #ifndef HAVE_LIBPCRE
        break_point = str->len - 1;
        g_string_append(str,
-                       "\nNOTE: this build does not support the \"matches\" operator for Ethereal filter"
+                       "\nNOTE: this build doesn't support the \"matches\" operator for Ethereal filter"
                        "\nsyntax.");
        do_word_wrap(str, break_point);
 #endif /* HAVE_LIBPCRE */
+
+       end_string(str);
 }
 
 /*
@@ -211,6 +238,23 @@ get_runtime_version_info(GString *str)
 
        g_string_append(str, "on ");
 #if defined(_WIN32)
+       /*
+        * See
+        *
+        *      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
+        *
+        * for more than you ever wanted to know about determining the
+        * flavor of Windows on which you're running.  Implementing more
+        * of that is left as an exercise to the reader - who should
+        * check any copyright information about code samples on MSDN
+        * before cutting and pasting into Ethereal.
+        *
+        * They should also note that you need an OSVERSIONINFOEX structure
+        * to get some of that information, and that not only is that
+        * structure not supported on older versions of Windows, you might
+        * not even be able to compile code that *uses* that structure with
+        * older versions of the SDK.
+        */
        info.dwOSVersionInfoSize = sizeof info;
        if (!GetVersionEx(&info)) {
                /*
@@ -293,6 +337,10 @@ get_runtime_version_info(GString *str)
                        }
                        break;
 
+               case 6:
+                       g_string_sprintfa(str, "Windows Vista");
+                       break;
+
                default:
                        g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
                            info.dwMajorVersion, info.dwMinorVersion);
@@ -343,4 +391,18 @@ get_runtime_version_info(GString *str)
        g_string_append(str, "an unknown OS");
 #endif
        g_string_append(str, ".");
+
+       end_string(str);
+}
+
+/*
+ * Get copyright information.
+ */
+const char *
+get_copyright_info(void)
+{
+       return
+"Copyright 1998-2006 Gerald Combs <gerald@ethereal.com> and contributors.\n"
+"This is free software; see the source for copying conditions. There is NO\n"
+"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
 }