Change "4 space tabs" indentation to use "4 spaces";
[metze/wireshark/wip.git] / cfile.c
1 /* cfile.c
2  * capture_file GUI-independent manipulation
3  * Vassilii Khachaturov <vassilii@tarunz.org>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "config.h"
27
28 #include <glib.h>
29
30 #include <epan/packet.h>
31
32 #include "cfile.h"
33
34 const char *
35 cap_file_get_interface_name(void *data, guint32 interface_id)
36 {
37   capture_file *cf = (capture_file *) data;
38   wtapng_iface_descriptions_t *idb_info;
39   const wtapng_if_descr_t *wtapng_if_descr = NULL;
40
41   idb_info = wtap_file_get_idb_info(cf->wth);
42
43   if (interface_id < idb_info->number_of_interfaces)
44     wtapng_if_descr = &g_array_index(idb_info->interface_data, wtapng_if_descr_t, interface_id);
45
46   g_free(idb_info);
47
48   if (wtapng_if_descr) {
49     if (wtapng_if_descr->if_name)
50       return wtapng_if_descr->if_name;
51     else if (wtapng_if_descr->if_description)
52       return wtapng_if_descr->if_description;
53   }
54   return "unknown";
55 }
56
57 void
58 cap_file_init(capture_file *cf)
59 {
60   /* Initialize the capture file struct */
61   memset(cf, 0, sizeof(capture_file));
62   cf->snap            = WTAP_MAX_PACKET_SIZE;
63 }