Make it possible to edit capture comments
[metze/wireshark/wip.git] / wiretap / wtap.c
index e494a9e7576a278da9c632562a8a0208c832b5bd..7a6ee5ca48c5072b41883f5bc7bbf21b88034701 100644 (file)
@@ -78,7 +78,7 @@ wtap_file_type(wtap *wth)
        return wth->file_type;
 }
 
-int
+guint
 wtap_snapshot_length(wtap *wth)
 {
        return wth->snapshot_length;
@@ -96,6 +96,41 @@ wtap_file_tsprecision(wtap *wth)
        return wth->tsprecision;
 }
 
+wtapng_section_t* wtap_file_get_shb_info(wtap *wth)
+{
+       wtapng_section_t                *shb_hdr;
+
+       shb_hdr = g_new(wtapng_section_t,1);
+       shb_hdr->section_length = wth->shb_hdr.section_length;
+       /* options */
+       shb_hdr->opt_comment   =        wth->shb_hdr.opt_comment;       /* NULL if not available */
+       shb_hdr->shb_hardware  =        wth->shb_hdr.shb_hardware;      /* NULL if not available, UTF-8 string containing the description of the hardware used to create this section. */
+       shb_hdr->shb_os        =        wth->shb_hdr.shb_os;            /* NULL if not available, UTF-8 string containing the name of the operating system used to create this section. */
+       shb_hdr->shb_user_appl =        wth->shb_hdr.shb_user_appl;     /* NULL if not available, UTF-8 string containing the name of the application used to create this section. */
+
+
+       return shb_hdr;
+}
+
+void wtap_write_shb_comment(wtap *wth, gchar *comment)
+{
+       g_free(wth->shb_hdr.opt_comment);
+       wth->shb_hdr.opt_comment = comment;
+
+}
+
+wtapng_iface_descriptions_t* wtap_file_get_idb_info(wtap *wth)
+{
+       wtapng_iface_descriptions_t *idb_info;
+
+       idb_info = g_new(wtapng_iface_descriptions_t,1);
+
+       idb_info->number_of_interfaces  = wth->number_of_interfaces;
+       idb_info->interface_data                = wth->interface_data;
+
+       return idb_info;
+}
+
 /* Table of the encapsulation types we know about. */
 struct encap_type_info {
        const char *name;
@@ -501,9 +536,24 @@ static struct encap_type_info encap_table_base[] = {
 
        /* WTAP_ENCAP_DVBCI */
        { "DVB-CI (Common Interface)", "dvbci"},
-       
-       /* WTAP_ENCAP_MUX27010 */
-       { "MUX27010", "mux27010"}
+
+       /* WTAP_ENCAP_MUX27010 */
+       { "MUX27010", "mux27010"},
+
+       /* WTAP_ENCAP_MIME */
+       { "MIME", "mime" },
+
+       /* WTAP_ENCAP_NETANALYZER */
+       { "netANALYZER", "netanalyzer" },
+
+       /* WTAP_ENCAP_NETANALYZER_TRANSPARENT */
+       { "netANALYZER-Transparent", "netanalyzer-transparent" },
+
+       /* WTAP_ENCAP_IP_OVER_IB */
+       { "IP over Infiniband", "ip-over-ib" },
+
+       /* WTAP_ENCAP_MPEG_2_TS */
+       { "ISO/IEC 13818-1 MPEG2-TS", "mp2ts" }
 };
 
 gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
@@ -593,7 +643,7 @@ static const char *wtap_errlist[] = {
        NULL,
        NULL,
        "Less data was read than was expected",
-       "File contains a record that's not valid",
+       "The file appears to be damaged or corrupt.",
        "Less data was written than was requested",
        "Uncompression error: data oddly truncated",
        "Uncompression error: data would overflow buffer",
@@ -622,7 +672,7 @@ const char
                        return "Unknown reason";
                return wtap_errlist[wtap_errlist_index];
        } else
-               return strerror(err);
+               return g_strerror(err);
 }
 
 /* Close only the sequential side, freeing up memory it uses.
@@ -679,10 +729,9 @@ wtap_close(wtap *wth)
 }
 
 void
-wtap_cleareof(wtap *wth _U_) {
+wtap_cleareof(wtap *wth) {
        /* Reset EOF */
-       if (file_eof(wth->fh))
-               file_clearerr(wth->fh);
+       file_clearerr(wth->fh);
 }
 
 void wtap_set_cb_new_ipv4(wtap *wth, wtap_new_ipv4_callback_t add_new_ipv4) {