Skip to content

Commit

Permalink
Convert the smaller executables to C99 types
Browse files Browse the repository at this point in the history
Convert captype, dftest, mergecap, randpkt, and reordercap
to C99 types.

Ping #19116
  • Loading branch information
johnthacker committed Jul 7, 2024
1 parent 6a1695d commit a354b30
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions captype.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ main(int argc, char *argv[])
};
wtap *wth;
int err;
gchar *err_info;
char *err_info;
int i;
int opt;
int overall_error_status;
Expand Down Expand Up @@ -149,7 +149,7 @@ main(int argc, char *argv[])

init_report_message("captype", &captype_report_routines);

wtap_init(TRUE);
wtap_init(true);

/* Process the options */
while ((opt = ws_getopt_long(argc, argv, "hv", long_options, NULL)) !=-1) {
Expand Down Expand Up @@ -182,7 +182,7 @@ main(int argc, char *argv[])
overall_error_status = 0;

for (i = 1; i < argc; i++) {
wth = wtap_open_offline(argv[i], WTAP_TYPE_AUTO, &err, &err_info, FALSE);
wth = wtap_open_offline(argv[i], WTAP_TYPE_AUTO, &err, &err_info, false);

if(wth) {
printf("%s: %s\n", argv[i], wtap_file_type_subtype_name(wtap_file_type_subtype(wth)));
Expand Down
18 changes: 9 additions & 9 deletions dftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ static int opt_show_types;
static int opt_dump_refs;
static int opt_dump_macros;

static gint64 elapsed_expand;
static gint64 elapsed_compile;
static int64_t elapsed_expand;
static int64_t elapsed_compile;

/*
* Report an error in command-line arguments.
Expand Down Expand Up @@ -153,7 +153,7 @@ print_macros(void)
static void
print_warnings(dfilter_t *df)
{
guint i;
unsigned i;
GPtrArray *deprecated;
int count = 0;

Expand Down Expand Up @@ -190,7 +190,7 @@ expand_filter(const char *text)
{
char *expanded = NULL;
df_error_t *err = NULL;
gint64 start;
int64_t start;

start = g_get_monotonic_time();
expanded = dfilter_expand(text, &err);
Expand All @@ -202,13 +202,13 @@ expand_filter(const char *text)
return expanded;
}

static gboolean
static bool
compile_filter(const char *text, dfilter_t **dfp)
{
unsigned df_flags = 0;
gboolean ok;
bool ok;
df_error_t *df_err = NULL;
gint64 start;
int64_t start;

if (opt_optimize > 0)
df_flags |= DF_OPTIMIZE;
Expand Down Expand Up @@ -428,13 +428,13 @@ main(int argc, char **argv)
* dissection-time handlers for file-type-dependent blocks can
* register using the file type/subtype value for the file type.
*/
wtap_init(TRUE);
wtap_init(true);

/* Register all dissectors; we must do this before checking for the
"-g" flag, as the "-g" flag dumps a list of fields registered
by the dissectors, and we must do it before we read the preferences,
in case any dissectors register preferences. */
if (!epan_init(NULL, NULL, TRUE))
if (!epan_init(NULL, NULL, true))
goto out;

/* Load libwireshark settings from the current profile. */
Expand Down
18 changes: 9 additions & 9 deletions mergecap.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ list_capture_types(void) {

fprintf(stderr, "mergecap: The available capture file types for the \"-F\" flag are:\n");
writable_type_subtypes = wtap_get_writable_file_types_subtypes(FT_SORT_BY_NAME);
for (guint i = 0; i < writable_type_subtypes->len; i++) {
for (unsigned i = 0; i < writable_type_subtypes->len; i++) {
int ft = g_array_index(writable_type_subtypes, int, i);
fprintf(stderr, " %s - %s\n", wtap_file_type_subtype_name(ft),
wtap_file_type_subtype_description(ft));
Expand All @@ -118,10 +118,10 @@ list_idb_merge_modes(void) {

static bool
merge_callback(merge_event event, int num,
const merge_in_file_t in_files[], const guint in_file_count,
const merge_in_file_t in_files[], const unsigned in_file_count,
void *data _U_)
{
guint i;
unsigned i;

switch (event) {

Expand Down Expand Up @@ -203,13 +203,13 @@ main(int argc, char *argv[])
{"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 }
};
gboolean do_append = FALSE;
gboolean verbose = FALSE;
bool do_append = false;
bool verbose = false;
int in_file_count = 0;
guint32 snaplen = 0;
uint32_t snaplen = 0;
int file_type = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN;
char *out_filename = NULL;
bool status = TRUE;
bool status = true;
idb_merge_mode mode = IDB_MERGE_MODE_MAX;
merge_progress_callback_t cb;

Expand Down Expand Up @@ -249,7 +249,7 @@ main(int argc, char *argv[])

init_report_message("mergecap", &mergecap_report_routines);

wtap_init(TRUE);
wtap_init(true);

/* Process the options first */
while ((opt = ws_getopt_long(argc, argv, "aF:hI:s:vVw:", long_options, NULL)) != -1) {
Expand Down Expand Up @@ -292,7 +292,7 @@ main(int argc, char *argv[])
break;

case 'V':
verbose = TRUE;
verbose = true;
break;

case 'v':
Expand Down
18 changes: 9 additions & 9 deletions randpkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ list_capture_types(void) {

cmdarg_err("The available capture file types for the \"-F\" flag are:\n");
writable_type_subtypes = wtap_get_writable_file_types_subtypes(FT_SORT_BY_NAME);
for (guint i = 0; i < writable_type_subtypes->len; i++) {
for (unsigned i = 0; i < writable_type_subtypes->len; i++) {
int ft = g_array_index(writable_type_subtypes, int, i);
fprintf(stderr, " %s - %s\n", wtap_file_type_subtype_name(ft),
wtap_file_type_subtype_description(ft));
Expand Down Expand Up @@ -79,7 +79,7 @@ randpkt_cmdarg_err_cont(const char *msg_format, va_list ap)

/* Print usage statement and exit program */
static void
usage(gboolean is_error)
usage(bool is_error)
{
FILE *output;
char** abbrev_list;
Expand Down Expand Up @@ -143,8 +143,8 @@ main(int argc, char *argv[])
int produce_count = 1000;
int file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN;
randpkt_example *example;
guint8* type = NULL;
int allrandom = FALSE;
uint8_t* type = NULL;
int allrandom = false;
wtap_dumper *savedump;
int ret = EXIT_SUCCESS;
static const struct ws_option long_options[] = {
Expand Down Expand Up @@ -182,7 +182,7 @@ main(int argc, char *argv[])

init_report_message("randpkt", &randpkt_report_routines);

wtap_init(TRUE);
wtap_init(true);

#ifdef _WIN32
create_app_running_mutex();
Expand Down Expand Up @@ -220,12 +220,12 @@ main(int argc, char *argv[])

case 'h':
show_help_header(NULL);
usage(FALSE);
usage(false);
goto clean_exit;
break;

case 'r':
allrandom = TRUE;
allrandom = true;
break;

case 'v':
Expand All @@ -243,7 +243,7 @@ main(int argc, char *argv[])
/* FALLTHROUGH */

default:
usage(TRUE);
usage(true);
ret = WS_EXIT_INVALID_OPTION;
goto clean_exit;
break;
Expand All @@ -254,7 +254,7 @@ main(int argc, char *argv[])
if (argc > ws_optind) {
produce_filename = argv[ws_optind];
} else {
usage(TRUE);
usage(true);
ret = WS_EXIT_INVALID_OPTION;
goto clean_exit;
}
Expand Down
22 changes: 11 additions & 11 deletions reordercap.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ print_usage(FILE *output)

/* Remember where this frame was in the file */
typedef struct FrameRecord_t {
gint64 offset;
guint num;
int64_t offset;
unsigned num;

nstime_t frame_time;
} FrameRecord_t;
Expand All @@ -83,7 +83,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
const char *outfile)
{
int err;
gchar *err_info;
char *err_info;

DEBUG_PRINT("\nDumping frame (offset=%" PRIu64 ")\n",
frame->offset);
Expand Down Expand Up @@ -178,11 +178,11 @@ main(int argc, char *argv[])
wtap_rec rec;
Buffer buf;
int err;
gchar *err_info;
gint64 data_offset;
guint wrong_order_count = 0;
gboolean write_output_regardless = TRUE;
guint i;
char *err_info;
int64_t data_offset;
unsigned wrong_order_count = 0;
bool write_output_regardless = true;
unsigned i;
wtap_dump_params params;
int ret = EXIT_SUCCESS;

Expand Down Expand Up @@ -231,13 +231,13 @@ main(int argc, char *argv[])

init_report_message("reordercap", &reordercap_message_routines);

wtap_init(TRUE);
wtap_init(true);

/* Process the options first */
while ((opt = ws_getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) {
switch (opt) {
case 'n':
write_output_regardless = FALSE;
write_output_regardless = false;
break;
case 'h':
show_help_header("Reorder timestamps of input file frames into output file.");
Expand Down Expand Up @@ -268,7 +268,7 @@ main(int argc, char *argv[])
/* Open infile */
/* TODO: if reordercap is ever changed to give the user a choice of which
open_routine reader to use, then the following needs to change. */
wth = wtap_open_offline(infile, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
wth = wtap_open_offline(infile, WTAP_TYPE_AUTO, &err, &err_info, true);
if (wth == NULL) {
cfile_open_failure_message(infile, err, err_info);
ret = WS_EXIT_OPEN_ERROR;
Expand Down

0 comments on commit a354b30

Please sign in to comment.