Strip off anything after a blank in the PacketLibraryVersion string, as

the string says "3.0 alpha3" in the final release of WinPcap 3.0, and
saying that's "3.0 alpha3" is misleading.

Don't repeatedly fetch the version string from PacketLibraryVersion;
just cache the version we got the first time.

svn path=/trunk/; revision=14081
This commit is contained in:
Guy Harris 2005-04-14 20:37:13 +00:00
parent adbc8b86b5
commit 8f71b85840
1 changed files with 32 additions and 12 deletions

View File

@ -616,24 +616,44 @@ get_runtime_pcap_version(GString *str)
* what version we have.
*/
GModule *handle; /* handle returned by dlopen */
gchar *packetVer = NULL;
static gchar *packetVer;
gchar *blankp;
if (has_wpcap) {
/* An alternative method of obtaining the version number */
if ((handle = g_module_open("Packet.dll", 0)) != NULL) {
if (g_module_symbol(handle, "PacketLibraryVersion",
(gpointer*)&packetVer) == FALSE)
packetVer = NULL;
g_module_close(handle);
}
g_string_sprintfa(str, "with ");
if (p_pcap_lib_version != NULL)
g_string_sprintfa(str, p_pcap_lib_version());
else if (packetVer != NULL)
else {
/*
* An alternative method of obtaining the version
* number, by using the PacketLibraryVersion"
* string from packet.dll.
*
* Unfortunately, in WinPcap 3.0, it returns
* "3.0 alpha3", even in the final version of
* WinPcap 3.0, so if there's a blank in the
* string, we strip it and everything after
* it from the string, so we don't misleadingly
* report that 3.0 alpha3 is being used when
* the final version is being used.
*/
if (packetVer == NULL) {
packetVer = "version unknown";
handle = g_module_open("Packet.dll", 0);
if (handle != NULL) {
if (g_module_symbol(handle,
"PacketLibraryVersion",
(gpointer*)&packetVer)) {
packetVer = g_strdup(packetVer);
blankp = strchr(packetVer, ' ');
if (blankp != NULL)
*blankp = '\0';
}
g_module_close(handle);
}
}
g_string_sprintfa(str, "WinPcap (%s)", packetVer);
else
g_string_append(str, "WinPcap (version unknown)");
}
} else
g_string_append(str, "without WinPcap");
g_string_append(str, " ");