diff options
-rw-r--r-- | text2pcap-scanner.l | 10 | ||||
-rw-r--r-- | text2pcap.c | 3 | ||||
-rw-r--r-- | text2pcap.h | 4 | ||||
-rw-r--r-- | ui/text_import.c | 17 | ||||
-rw-r--r-- | ui/text_import_scanner.h | 2 | ||||
-rw-r--r-- | ui/text_import_scanner.l | 17 |
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; +} |