diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-04-04 18:56:27 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-04-05 02:49:43 +0000 |
commit | 8a5b26efb14b7f8f5375383436f03108d52d9aed (patch) | |
tree | eb57791fc53deab1c618b259e11092f122a8ee97 /editcap.c | |
parent | b572b65e518937f43b630991c07369d8e0c79f53 (diff) |
Have wtap_read() fill in a wtap_rec and Buffer.
That makes it - and the routines that implement it - work more like the
seek-read routine.
Change-Id: I0cace2d0e4c9ebfc21ac98fd1af1ec70f60a240d
Reviewed-on: https://code.wireshark.org/review/32727
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'editcap.c')
-rw-r--r-- | editcap.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1054,6 +1054,8 @@ main(int argc, char *argv[]) guint max_packet_number = 0; GArray *dsb_types = NULL; GPtrArray *dsb_filenames = NULL; + wtap_rec read_rec; + Buffer read_buf; const wtap_rec *rec; wtap_rec temp_rec; wtap_dump_params params = WTAP_DUMP_PARAMS_INIT; @@ -1566,13 +1568,15 @@ main(int argc, char *argv[]) } /* Read all of the packets in turn */ - while (wtap_read(wth, &read_err, &read_err_info, &data_offset)) { + wtap_rec_init(&read_rec); + ws_buffer_init(&read_buf, 1500); + while (wtap_read(wth, &read_rec, &read_buf, &read_err, &read_err_info, &data_offset)) { if (max_packet_number <= read_count) break; read_count++; - rec = wtap_get_rec(wth); + rec = &read_rec; /* Extra actions for the first packet */ if (read_count == 1) { @@ -1605,7 +1609,7 @@ main(int argc, char *argv[]) } /* first packet only handling */ - buf = wtap_get_buf_ptr(wth); + buf = ws_buffer_start_ptr(&read_buf); /* * Not all packets have time stamps. Only process the time @@ -1699,7 +1703,7 @@ main(int argc, char *argv[]) /* We simply write it, perhaps after truncating it; we could * do other things, like modify it. */ - rec = wtap_get_rec(wth); + rec = &read_rec; if (rec->presence_flags & WTAP_HAS_TS) { /* Do we adjust timestamps to ensure strict chronological @@ -2024,6 +2028,8 @@ main(int argc, char *argv[]) } count++; } + wtap_rec_cleanup(&read_rec); + ws_buffer_free(&read_buf); g_free(fprefix); g_free(fsuffix); |