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>
This commit is contained in:
Guy Harris 2018-02-16 14:10:47 -08:00
parent c881ee37d9
commit 4a69d10920
6 changed files with 32 additions and 21 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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

View File

@ -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;
}
/*

View File

@ -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
}

View File

@ -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;
}