Move the version_info.c stuff to wsutil/ws_version_info.c.

Change-Id: I3a5c7e219974bfb924819b43b4d445eaf00e5bde
Reviewed-on: https://code.wireshark.org/review/6153
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-12-30 19:36:26 -08:00
parent 4eeb440b70
commit c1f30471ca
24 changed files with 148 additions and 279 deletions

View File

@ -996,7 +996,6 @@ set(SHARK_COMMON_SRC
cfile.c
frame_tvbuff.c
sync_pipe_write.c
version_info.c
)
# sources for external capture interfaces
@ -1471,7 +1470,6 @@ if(BUILD_text2pcap)
set(text2pcap_CLEAN_FILES
text2pcap.c
pcapio.c
version_info.c
)
set(text2pcap_FILES
${text2pcap_CLEAN_FILES}
@ -1494,7 +1492,6 @@ if(BUILD_mergecap)
)
set(mergecap_FILES
mergecap.c
version_info.c
image/mergecap.rc
)
add_executable(mergecap ${mergecap_FILES})
@ -1511,7 +1508,6 @@ if(BUILD_reordercap)
)
set(reordercap_FILES
reordercap.c
version_info.c
image/reordercap.rc
)
add_executable(reordercap ${reordercap_FILES})
@ -1530,7 +1526,6 @@ if(BUILD_capinfos)
)
set(capinfos_FILES
capinfos.c
version_info.c
image/capinfos.rc
)
add_executable(capinfos ${capinfos_FILES})
@ -1548,7 +1543,6 @@ if(BUILD_captype)
)
set(captype_FILES
captype.c
version_info.c
image/captype.rc
)
add_executable(captype ${captype_FILES})
@ -1565,7 +1559,6 @@ if(BUILD_editcap)
)
set(editcap_FILES
editcap.c
version_info.c
image/editcap.rc
)
add_executable(editcap ${editcap_FILES})
@ -1597,7 +1590,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
pcapio.c
ringbuffer.c
sync_pipe_write.c
version_info.c
image/dumpcap.rc
)
add_executable(dumpcap ${dumpcap_FILES})

View File

@ -44,7 +44,6 @@ SHARK_COMMON_SRC = \
cfile.c \
frame_tvbuff.c \
sync_pipe_write.c \
version_info.c \
extcap.c \
extcap_parser.c
@ -58,7 +57,6 @@ SHARK_COMMON_INCLUDES = \
fileset.h \
frame_tvbuff.h \
register.h \
version_info.h \
ws_symbol_export.h
# wireshark specifics
@ -101,8 +99,7 @@ rawshark_SOURCES = \
text2pcap_SOURCES = \
pcapio.c \
text2pcap.c \
text2pcap-scanner.l \
version_info.c
text2pcap-scanner.l
text2pcap_INCLUDES = \
pcapio.h \
@ -110,28 +107,23 @@ text2pcap_INCLUDES = \
# mergecap specifics
mergecap_SOURCES = \
mergecap.c \
version_info.c
mergecap.c
# editcap specifics
editcap_SOURCES = \
editcap.c \
version_info.c
editcap.c
# reordercap specifics
reordercap_SOURCES = \
reordercap.c \
version_info.c
reordercap.c
# capinfos specifics
capinfos_SOURCES = \
capinfos.c \
version_info.c
capinfos.c
# captype specifics
captype_SOURCES = \
captype.c \
version_info.c
captype.c
# dftest specifics
dftest_SOURCES = \
@ -149,8 +141,7 @@ dumpcap_SOURCES = \
dumpcap.c \
pcapio.c \
ringbuffer.c \
sync_pipe_write.c \
version_info.c
sync_pipe_write.c
# corresponding headers
dumpcap_INCLUDES = \

View File

@ -397,10 +397,10 @@ reordercap.exe : $(LIBS_CHECK) config.h $(reordercap_OBJECTS) wsutil\libwsutil.
mt.exe -nologo -manifest "reordercap.exe.manifest" -outputresource:reordercap.exe;1
!ENDIF
text2pcap.exe : $(LIBS_CHECK) config.h text2pcap.obj text2pcap-scanner.obj pcapio.obj version_info.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\text2pcap.res
text2pcap.exe : $(LIBS_CHECK) config.h text2pcap.obj text2pcap-scanner.obj pcapio.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib image\text2pcap.res
@echo Linking $@
$(LINK) @<<
/OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) text2pcap.obj text2pcap-scanner.obj pcapio.obj version_info.obj $(text2pcap_LIBS) image\text2pcap.res
/OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) text2pcap.obj text2pcap-scanner.obj pcapio.obj $(text2pcap_LIBS) image\text2pcap.res
<<
!IFDEF MANIFEST_INFO_REQUIRED
mt.exe -nologo -manifest "text2pcap.exe.manifest" -outputresource:text2pcap.exe;1

View File

@ -107,8 +107,6 @@
#include <wsutil/unicode-utils.h>
#endif /* _WIN32 */
#include "version_info.h"
/*
* By default capinfos now continues processing
* the next filename if and when wiretap detects

View File

@ -72,8 +72,6 @@
#include "wsutil/wsgetopt.h"
#endif
#include "version_info.h"
static void
print_usage(FILE *output)
{

View File

@ -88,7 +88,6 @@
#endif
#include "ringbuffer.h"
#include "version_info.h"
#include "caputils/capture_ifinfo.h"
#include "caputils/capture-pcap-util.h"

View File

@ -64,7 +64,6 @@
#include <capchild/capture_session.h>
#include <caputils/capture_ifinfo.h>
#include <capchild/capture_sync.h>
#include "version_info.h"
#include "cfile.h"
#include "wsutil/crash_info.h"
#include "wsutil/privileges.h"

View File

@ -90,8 +90,6 @@
#include <wsutil/crash_info.h>
#include <wsutil/ws_version_info.h>
#include "version_info.h"
#include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */
/*

View File

@ -38,10 +38,9 @@
#include <epan/dissectors/packet-data.h>
#include <epan/dissectors/packet-frame.h>
#include <wsutil/filesystem.h>
#include <wsutil/ws_version_info.h>
#include <ftypes/ftypes-int.h>
#include "version_info.h"
#define PDML_VERSION "0"
#define PSML_VERSION "0"

View File

@ -62,8 +62,6 @@
#include <wiretap/merge.h>
#include "version_info.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif

View File

@ -90,7 +90,6 @@
#include "ui/capture_ui_utils.h"
#endif
#include "ui/util.h"
#include "version_info.h"
#include "register.h"
#include "conditions.h"
#include "capture_stop_conditions.h"

View File

@ -50,8 +50,6 @@
#include <wsutil/crash_info.h>
#include <wsutil/ws_version_info.h>
#include "version_info.h"
/* Show command-line usage */
static void
print_usage(FILE *output)

View File

@ -142,7 +142,6 @@
#include "pcapio.h"
#include "text2pcap.h"
#include "version_info.h"
#ifdef _WIN32
#include <wsutil/unicode-utils.h>

View File

@ -86,7 +86,6 @@
#include <epan/print.h>
#include <epan/addr_resolv.h>
#include "ui/util.h"
#include "version_info.h"
#include "register.h"
#include <epan/epan_dissect.h>
#include <epan/tap.h>

View File

@ -96,7 +96,6 @@
#include "ui/util.h"
#include "ui/ui_util.h"
#include "ui/cli/tshark-tap.h"
#include "version_info.h"
#include "register.h"
#include <epan/epan_dissect.h>
#include <epan/tap.h>

View File

@ -38,8 +38,7 @@
#include "wsutil/file_util.h"
#include "wsutil/filesystem.h"
#include "version_info.h"
#include "wsutil/ws_version_info.h"
/* XXX - We might want to switch this to a UAT */

View File

@ -101,7 +101,6 @@
#include "../color_filters.h"
#include "../register.h"
#include "../ringbuffer.h"
#include "../version_info.h"
#include "../log.h"
#include "gtk_iface_monitor.h"

View File

@ -41,13 +41,12 @@
#include "wsutil/tempfile.h"
#include "wsutil/file_util.h"
#include "wsutil/str_util.h"
#include "wsutil/ws_version_info.h"
#include "ws_symbol_export.h"
#include "color_utils.h"
#include "version_info.h"
#include "ui/follow.h"
#include "qt_ui_utils.h"

View File

@ -91,7 +91,6 @@
#include "register.h"
#include "ringbuffer.h"
#include "ui/util.h"
#include "version_info.h"
#include "log.h"
#include "ui/alert_box.h"

View File

@ -25,7 +25,7 @@
#include <epan/prefs.h>
#include "version_info.h"
#include "wsutil/ws_version_info.h"
#include "main_welcome.h"
#include "ui_main_welcome.h"

View File

@ -1,156 +0,0 @@
/* version_info.c
* Routines to report version information for stuff used by Wireshark
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <config.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LIBZ
#include <zlib.h> /* to get the libz version number */
#endif
#include "version_info.h"
#include <wsutil/glib_version_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/compiler_info.h>
#include <wsutil/cpu_info.h>
#include <wsutil/mem_info.h>
/*
* If the string doesn't end with a newline, append one.
* Then word-wrap it to 80 columns.
*/
static void
end_string(GString *str)
{
size_t point;
char *p, *q;
point = str->len;
if (point == 0 || str->str[point - 1] != '\n')
g_string_append(str, "\n");
p = str->str;
while (*p != '\0') {
q = strchr(p, '\n');
if (q - p > 80) {
/*
* Break at or before this point.
*/
q = p + 80;
while (q > p && *q != ' ')
q--;
if (q != p)
*q = '\n';
}
p = q + 1;
}
}
/*
* Get various library compile-time versions and append them to
* the specified GString.
*
* "additional_info" is called at the end to append any additional
* information; this is required in order to, for example, put the
* Portaudio information at the end of the string, as we currently
* don't use Portaudio in TShark.
*/
void
get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
void (*append_info)(GString *))
{
if (sizeof(str) == 4)
g_string_append(str, "(32-bit) ");
else
g_string_append(str, "(64-bit) ");
if (prepend_info) {
(*prepend_info)(str);
g_string_append(str, ", ");
}
get_glib_version_info(str);
/* Additional application-dependent information */
if (append_info)
(*append_info)(str);
g_string_append(str, ".");
end_string(str);
}
/*
* Get various library run-time versions, and the OS version, and append
* them to the specified GString.
*/
void
get_runtime_version_info(GString *str, void (*additional_info)(GString *))
{
#ifndef _WIN32
gchar *lang;
#endif
g_string_append(str, "on ");
get_os_version_info(str);
#ifndef _WIN32
/* Locale */
if ((lang = getenv ("LANG")) != NULL)
g_string_append_printf(str, ", with locale %s", lang);
else
g_string_append(str, ", with default locale");
#endif
/* Additional application-dependent information */
if (additional_info)
(*additional_info)(str);
g_string_append(str, ".");
/* CPU Info */
get_cpu_info(str);
/* Get info about installed memory Windows only */
get_mem_info(str);
/* Compiler info */
get_compiler_info(str);
end_string(str);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* ex: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/

View File

@ -1,71 +0,0 @@
/* version_info.h
* Declarations of outines to report version information for stuff used
* by Wireshark
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __VERSION_INFO_H__
#define __VERSION_INFO_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Get various library compile-time versions and append them to
* the specified GString.
*
* "prepend_info" is called at the start to prepend any additional
* information.
*
* "append_info" is called at the end to append any additional
* information; this is required in order to, for example, put the
* Portaudio information at the end of the string, as we currently
* don't use Portaudio in TShark.
*/
void get_compiled_version_info(GString *str,
void (*prepend_info)(GString *),
void (*append_info)(GString *));
/*
* Get various library run-time versions, and the OS version, and append
* them to the specified GString.
*/
void get_runtime_version_info(GString *str,
void (*additional_info)(GString *));
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __VERSION_INFO_H__ */
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -23,12 +23,123 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <wsutil/ws_version_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/glib_version_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/compiler_info.h>
#include <wsutil/cpu_info.h>
#include <wsutil/mem_info.h>
/*
* If the string doesn't end with a newline, append one.
* Then word-wrap it to 80 columns.
*/
static void
end_string(GString *str)
{
size_t point;
char *p, *q;
point = str->len;
if (point == 0 || str->str[point - 1] != '\n')
g_string_append(str, "\n");
p = str->str;
while (*p != '\0') {
q = strchr(p, '\n');
if (q - p > 80) {
/*
* Break at or before this point.
*/
q = p + 80;
while (q > p && *q != ' ')
q--;
if (q != p)
*q = '\n';
}
p = q + 1;
}
}
/*
* Get various library compile-time versions and append them to
* the specified GString.
*
* "additional_info" is called at the end to append any additional
* information; this is required in order to, for example, put the
* Portaudio information at the end of the string, as we currently
* don't use Portaudio in TShark.
*/
void
get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
void (*append_info)(GString *))
{
if (sizeof(str) == 4)
g_string_append(str, "(32-bit) ");
else
g_string_append(str, "(64-bit) ");
if (prepend_info) {
(*prepend_info)(str);
g_string_append(str, ", ");
}
get_glib_version_info(str);
/* Additional application-dependent information */
if (append_info)
(*append_info)(str);
g_string_append(str, ".");
end_string(str);
}
/*
* Get various library run-time versions, and the OS version, and append
* them to the specified GString.
*/
void
get_runtime_version_info(GString *str, void (*additional_info)(GString *))
{
#ifndef _WIN32
gchar *lang;
#endif
g_string_append(str, "on ");
get_os_version_info(str);
#ifndef _WIN32
/* Locale */
if ((lang = getenv ("LANG")) != NULL)
g_string_append_printf(str, ", with locale %s", lang);
else
g_string_append(str, ", with default locale");
#endif
/* Additional application-dependent information */
if (additional_info)
(*additional_info)(str);
g_string_append(str, ".");
/* CPU Info */
get_cpu_info(str);
/* Get info about installed memory Windows only */
get_mem_info(str);
/* Compiler info */
get_compiler_info(str);
end_string(str);
}
void
show_version(const gchar *prog_name_str, GString *comp_info_str,

View File

@ -30,6 +30,29 @@
extern "C" {
#endif /* __cplusplus */
/*
* Get various library compile-time versions and append them to
* the specified GString.
*
* "prepend_info" is called at the start to prepend any additional
* information.
*
* "append_info" is called at the end to append any additional
* information; this is required in order to, for example, put the
* Portaudio information at the end of the string, as we currently
* don't use Portaudio in TShark.
*/
WS_DLL_PUBLIC void get_compiled_version_info(GString *str,
void (*prepend_info)(GString *),
void (*append_info)(GString *));
/*
* Get various library run-time versions, and the OS version, and append
* them to the specified GString.
*/
WS_DLL_PUBLIC void get_runtime_version_info(GString *str,
void (*additional_info)(GString *));
WS_DLL_PUBLIC void show_version(const gchar *prog_name, GString *comp_info_str, GString *runtime_info_str);
/*