sort #includes by directories
[obnox/wireshark/wip.git] / gtk / export_object_http.c
1 /* export_object_http.c
2  * Routines for tracking & saving objects found in HTTP streams
3  * See also: export_object.c / export_object.h for common code
4  * Copyright 2007, Stephen Fisher <stephentfisher@yahoo.com>
5  *
6  * $Id$
7  * 
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
25  * USA.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <glib.h>
33 #include <gtk/gtk.h>
34
35 /* This feature uses some functions only available in GTK 2.4 and above. */
36 #if GTK_CHECK_VERSION(2,4,0)
37
38 #include <epan/dissectors/packet-http.h>
39 #include <epan/emem.h>
40 #include <epan/tap.h>
41
42 #include "gtk/export_object.h"
43
44
45 static int
46 eo_http_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_,
47                const void *data)
48 {
49         export_object_list_t *object_list = tapdata;
50         const http_eo_t *eo_info = data;
51         export_object_entry_t *entry;
52
53         if(eo_info) { /* We have data waiting for us */
54                 /* These values will be freed when the Export Object window
55                  * is closed. */
56                 entry = g_malloc(sizeof(export_object_entry_t));
57
58                 entry->pkt_num = pinfo->fd->num;
59                 entry->hostname = g_strdup(eo_info->hostname);
60                 entry->content_type = g_strdup(eo_info->content_type);
61                 entry->filename = g_strdup(g_path_get_basename(eo_info->filename));
62                 entry->payload_len = eo_info->payload_len;
63                 entry->payload_data = g_memdup(eo_info->payload_data,
64                                                eo_info->payload_len);
65
66                 object_list->entries =
67                         g_slist_append(object_list->entries, entry);
68
69                 return 1; /* State changed - window should be redrawn */
70         } else {
71                 return 0; /* State unchanged - no window updates needed */
72         }
73 }
74
75 void
76 eo_http_cb(GtkWidget *widget _U_, gpointer data _U_)
77 {
78         export_object_window("http_eo", "HTTP", eo_http_packet);
79 }
80
81 #endif /* GTK_CHECK_VERSION(2,4,0) */