#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <glib.h>
* @return TRUE if the capture starts successfully, FALSE otherwise.
*/
gboolean
-capture_start(capture_options *capture_opts, capture_session *cap_session)
+capture_start(capture_options *capture_opts, capture_session *cap_session, void(*update_cb)(void))
{
gboolean ret;
guint i;
cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
g_string_free(source, TRUE);
/* try to start the capture child process */
- ret = sync_pipe_start(capture_opts, cap_session);
+ ret = sync_pipe_start(capture_opts, cap_session, update_cb);
if(!ret) {
if(capture_opts->save_file != NULL) {
g_free(capture_opts->save_file);
/* if we are in real-time mode, open the new file now */
if(capture_opts->real_time_mode) {
/* Attempt to open the capture file and set up to read from it. */
- switch(cf_start_tail((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
+ switch(cf_open((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
case CF_OK:
break;
case CF_ERROR:
ws_unlink(capture_opts->save_file);
+ /* If we have a ring buffer, the original save file has been overwritten
+ with the "ring filename". Restore it before starting again */
+ if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) {
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = g_strdup(capture_opts->orig_save_file);
+ }
+
/* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
if(cf_is_tempfile((capture_file *)cap_session->cf)) {
g_free(capture_opts->save_file);
/* close the currently loaded capture file */
cf_close((capture_file *)cap_session->cf);
- capture_start(capture_opts, cap_session);
+ capture_start(capture_opts, cap_session,NULL); /*XXX is this NULL ok or we need an update_cb???*/
} else {
/* We're not doing a capture any more, so we don't have a save file. */
g_free(capture_opts->save_file);
* mechanism, so opening all the devices and presenting packet
* counts might not always be a good idea.
*/
- if (sync_interface_stats_open(&stat_fd, &fork_child, &msg) == 0) {
+ if (sync_interface_stats_open(&stat_fd, &fork_child, &msg, NULL) == 0) {
sc = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
sc->stat_fd = stat_fd;
sc->fork_child = fork_child;