sec_vt_header: dissect cont_id + opnum
[wireshark-wip.git] / ui / follow.c
blobfe08c021569455aba47b017913ceecdc72fa0d0e
1 /* follow.c
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "config.h"
26 #include <string.h>
28 #include <glib.h>
30 #include <epan/filesystem.h>
31 #include <epan/dfilter/dfilter.h>
33 #include "ui/follow.h"
35 #ifdef HAVE_LIBZ
36 char *
37 sgetline(char *str, int *next)
39 char *end;
41 end = strstr(str, "\r\n");
42 if (!end) {
43 *next = (int)strlen(str);
44 return NULL;
46 *end = '\0';
47 *next = (int)(end-str+2);
48 return str;
51 gboolean
52 parse_http_header(char *data, size_t len, size_t *content_start)
54 char *tmp, *copy, *line;
55 size_t pos = 0;
56 int next_line;
57 gboolean is_gzipped;
59 /* XXX handle case where only partial header is passed in here.
60 * we should pass something back to indicate whether header is complete.
61 * (if not, is_gzipped is may still be unknown)
65 * In order to parse header, we duplicate data and tokenize lines.
66 * We aren't interested in actual data, so use g_strndup instead of memcpy
67 * to (possibly) copy fewer bytes (e.g., if a nul byte exists in data)
68 * This also ensures that we have a terminated string for futher processing.
70 tmp = copy = g_strndup(data, len);
71 if (!tmp) {
72 *content_start = 0;
73 return FALSE;
76 /* skip HTTP... line*/
77 /*line = */sgetline(tmp, &next_line);
79 tmp += next_line;
80 pos += next_line;
82 is_gzipped = FALSE;
84 *content_start = -1;
85 while ((line = sgetline(tmp, &next_line))) {
86 char *key, *val, *c;
88 tmp += next_line;
89 pos += next_line;
91 if (strlen(line) == 0) {
92 /* end of header*/
93 break;
96 c = strchr(line, ':');
97 if (!c) break;
99 key = line;
100 *c = '\0';
101 val = c+2;
103 if (!strcmp(key, "Content-Encoding") && strstr(val, "gzip")) {
104 is_gzipped = TRUE;
107 *content_start = pos;
108 g_free(copy);
109 return is_gzipped;
111 #endif
115 * Editor modelines
117 * Local Variables:
118 * c-basic-offset: 4
119 * tab-width: 8
120 * indent-tabs-mode: nil
121 * End:
123 * ex: set shiftwidth=4 tabstop=8 expandtab:
124 * :indentSize=4:tabSize=8:noTabs=true: