summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-20 14:36:52 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-20 21:37:41 +0000
commit77f969958c75a8ba138d5adeeddbef50664f52c0 (patch)
tree1651eb1a190dde5c94b934665d10b6b863e0c410 /file.c
parent0bbe48304a50b6f664c2cef8181c5ba90b62b073 (diff)
downloadwireshark-77f969958c75a8ba138d5adeeddbef50664f52c0.tar.gz
Fix support for writing out edited records.
Add a cf_set_frame_edited() routine to set the record header and data for a record; have it do all the non-GUI work, and have it set the file's "unsaved changes" flag. Have the GUI code just call that routine and then update the title bar to reflect the unsaved changes. While we're at it, unmark a no-longer-unused argument to save_record(). Change-Id: Ieb513fdf423b388519527621ecec4cf634b98caf Reviewed-on: https://code.wireshark.org/review/4885 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r--file.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/file.c b/file.c
index 31d2b6a713..ecb42887b5 100644
--- a/file.c
+++ b/file.c
@@ -4036,6 +4036,50 @@ cf_comment_types(capture_file *cf)
return comment_types;
}
+#ifdef WANT_PACKET_EDITOR
+static gint
+g_direct_compare_func(gconstpointer a, gconstpointer b, gpointer user_data _U_)
+{
+ if (a > b)
+ return 1;
+ else if (a < b)
+ return -1;
+ else
+ return 0;
+}
+
+static void
+modified_frame_data_free(gpointer data)
+{
+ modified_frame_data *mfd = (modified_frame_data *)data;
+
+ g_free(mfd->pd);
+ g_free(mfd);
+}
+
+/*
+ * Give a frame new, edited data.
+ */
+void
+cf_set_frame_edited(capture_file *cf, frame_data *fd,
+ struct wtap_pkthdr *phdr, guint8 *pd)
+{
+ modified_frame_data *mfd = (modified_frame_data *)g_malloc(sizeof(modified_frame_data));
+
+ mfd->phdr = *phdr;
+ mfd->pd = pd;
+
+ if (cf->edited_frames == NULL)
+ cf->edited_frames = g_tree_new_full(g_direct_compare_func, NULL, NULL,
+ modified_frame_data_free);
+ g_tree_insert(cf->edited_frames, GINT_TO_POINTER(fd->num), mfd);
+ fd->file_off = -1;
+
+ /* Mark the file as having unsaved changes */
+ cf->unsaved_changes = TRUE;
+}
+#endif
+
typedef struct {
wtap_dumper *pdh;
const char *fname;
@@ -4050,7 +4094,7 @@ typedef struct {
* up a message box for the failure.
*/
static gboolean
-save_record(capture_file *cf _U_, frame_data *fdata,
+save_record(capture_file *cf, frame_data *fdata,
struct wtap_pkthdr *phdr, const guint8 *pd,
void *argsp)
{