aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-16 14:10:47 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-16 22:40:26 +0000
commit4a69d10920c47fbbb5522adbb478cfeb8f6785dc (patch)
tree327d87b3d61abeea16761265884b84273c7c419a
parentc881ee37d955428cea8f377aaa0a66d5c0b0e60d (diff)
Squelch redundant declaration warnings.
Have the text-to-pcap scanners define a routine that the main code calls, which both allocates and destroys the scanner. Don't declare the Lex-generated routines in a header file we create, declare that routine, instead. Change-Id: Icad6a83db1a0dea8ac390315af72383fc99f8513 Reviewed-on: https://code.wireshark.org/review/25822 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--text2pcap-scanner.l10
-rw-r--r--text2pcap.c3
-rw-r--r--text2pcap.h4
-rw-r--r--ui/text_import.c17
-rw-r--r--ui/text_import_scanner.h2
-rw-r--r--ui/text_import_scanner.l17
6 files changed, 32 insertions, 21 deletions
diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l
index c233999d4d..51c5d67bca 100644
--- a/text2pcap-scanner.l
+++ b/text2pcap-scanner.l
@@ -113,3 +113,13 @@ eol \r?\n\r?
* Turn diagnostics back on, so we check the code that we've written.
*/
DIAG_ON_FLEX
+
+int
+text2pcap_scan(void)
+{
+ int ret;
+
+ ret = text2pcap_lex();
+ text2pcap_lex_destroy();
+ return ret;
+}
diff --git a/text2pcap.c b/text2pcap.c
index ffa3c0fc84..2aea8e78e9 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -1908,7 +1908,7 @@ main(int argc, char *argv[])
curr_offset = header_length;
text2pcap_in = input_file;
- if (text2pcap_lex() == EXIT_SUCCESS) {
+ if (text2pcap_scan() == EXIT_SUCCESS) {
if (write_current_packet(FALSE) != EXIT_SUCCESS)
ret = EXIT_FAILURE;
} else {
@@ -1923,7 +1923,6 @@ main(int argc, char *argv[])
bytes_written, (bytes_written == 1) ? "" : "s");
}
clean_exit:
- text2pcap_lex_destroy();
if (input_file) {
fclose(input_file);
}
diff --git a/text2pcap.h b/text2pcap.h
index d9cd7f9d28..02816561ad 100644
--- a/text2pcap.h
+++ b/text2pcap.h
@@ -27,9 +27,7 @@ typedef enum {
int parse_token(token_t token, char *str);
-int text2pcap_lex(void);
-
-int text2pcap_lex_destroy(void);
+int text2pcap_scan(void);
#endif
diff --git a/ui/text_import.c b/ui/text_import.c
index 6cf315fb54..244ba2e3b5 100644
--- a/ui/text_import.c
+++ b/ui/text_import.c
@@ -905,7 +905,6 @@ parse_token (token_t token, char *str)
int
text_import(text_import_info_t *info)
{
- yyscan_t scanner;
int ret;
struct tm *now_tm;
@@ -1029,21 +1028,9 @@ text_import(text_import_info_t *info)
max_offset = info->max_frame_length;
- if (text_import_lex_init(&scanner) != 0) {
- ret = errno;
- g_free(packet_buf);
- return ret;
- }
-
- text_import_set_in(info->import_text_file, scanner);
-
- text_import_lex(scanner);
-
- text_import_lex_destroy(scanner);
-
+ ret = text_import_scan(info->import_text_file);
g_free(packet_buf);
-
- return 0;
+ return ret;
}
/*
diff --git a/ui/text_import_scanner.h b/ui/text_import_scanner.h
index f762ef3040..b0a6d0c71c 100644
--- a/ui/text_import_scanner.h
+++ b/ui/text_import_scanner.h
@@ -34,7 +34,7 @@ void write_current_packet(void);
extern FILE *text_importin;
-int text_importlex(void);
+int text_import_scan(FILE *input_file);
#ifdef __cplusplus
}
diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l
index 70255e6f77..f9c45b8c25 100644
--- a/ui/text_import_scanner.l
+++ b/ui/text_import_scanner.l
@@ -142,3 +142,20 @@ eol \r?\n\r?
* Turn diagnostics back on, so we check the code that we've written.
*/
DIAG_ON_FLEX
+
+int
+text_import_scan(FILE *input_file)
+{
+ yyscan_t scanner;
+
+ if (text_import_lex_init(&scanner) != 0)
+ return errno;
+
+ text_import_set_in(input_file, scanner);
+
+ text_import_lex(scanner);
+
+ text_import_lex_destroy(scanner);
+
+ return 0;
+}