Use tab indentation as elsewhere in the files.
authortuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 21 Feb 2012 15:16:45 +0000 (15:16 +0000)
committertuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 21 Feb 2012 15:16:45 +0000 (15:16 +0000)
Only whitespace changes.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@41110 f5534014-38df-0310-8fa8-9805f1628bb7

pcapio.c
pcapio.h

index 6f7d600acc3283f3349c4fbe552a1324b3a4ad4e..021b0f4a434e5099433d574a0916a8da91da2bbd 100644 (file)
--- a/pcapio.c
+++ b/pcapio.c
@@ -376,159 +376,167 @@ libpcap_write_session_header_block(FILE *fp,
 
 gboolean
 libpcap_write_interface_description_block(FILE *fp,
-                                          const char *comment, /* OPT_COMMENT       1 */
-                                          const char *name,            /* IDB_NAME              2 */
-                                          const char *descr,   /* IDB_DESCRIPTION   3 */
-                                          const char *filter,  /* IDB_FILTER       11 */
-                                          const char *os,              /* IDB_OS               12 */
+                                          const char *comment, /* OPT_COMMENT        1 */
+                                          const char *name,    /* IDB_NAME           2 */
+                                          const char *descr,   /* IDB_DESCRIPTION    3 */
+                                          const char *filter,  /* IDB_FILTER        11 */
+                                          const char *os,      /* IDB_OS            12 */
                                           int link_type,
                                           int snap_len,
                                           long *bytes_written,
-                                          guint64 if_speed,            /* IDB_IF_SPEED       8 */
-                                          guint8 tsresol,              /* IDB_TSRESOL        9 */
+                                          guint64 if_speed,    /* IDB_IF_SPEED       8 */
+                                          guint8 tsresol,      /* IDB_TSRESOL        9 */
                                           int *err)
 {
-    struct idb idb;
-    struct option option;
-    guint32 block_total_length;
-    const guint32 padding = 0;
-    gboolean have_options = FALSE;
-
-    block_total_length = sizeof(struct idb) + sizeof(guint32);
-    /* OPT_COMMENT */
-    if ((comment)&&(strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) {
-        block_total_length += sizeof(struct option) +
-                              (guint16)(ADD_PADDING(strlen(comment) + 1));
-        have_options = TRUE;
-    }
-
-    /* IDB_DESCRIPTION */
-    if ((descr)&&(strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) {
-        block_total_length += sizeof(struct option) +
-                              (guint16)(ADD_PADDING(strlen(descr) + 1));
-        have_options = TRUE;
-    }
-
-    /* IDB_NAME */
-    if ((name)&&(strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
-        block_total_length += sizeof(struct option) +
-                              (guint16)(ADD_PADDING(strlen(name) + 1));
-        have_options = TRUE;
-    }
-
-    /* IDB_FILTER */
-    if ((filter)&&(strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
-        block_total_length += sizeof(struct option) +
-                              (guint16)(ADD_PADDING(strlen(filter) + 1));
-        have_options = TRUE;
-    }
-
-    /* IDB_OS */
-    if ((os)&&(strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) {
-        block_total_length += sizeof(struct option) +
-                              (guint16)(ADD_PADDING(strlen(os) + 1));
-        have_options = TRUE;
-    }
-
-    /* IDB_IF_SPEED       8 */
-    if(if_speed != 0){
-        block_total_length += sizeof(struct option) + sizeof(guint64);
-        have_options = TRUE;
-    }
-    /* IDB_TSRESOL        9 */
-    if(tsresol != 0){
-        block_total_length += sizeof(struct option) + sizeof(struct option);
-        have_options = TRUE;
-    }
-    /* If we have options add size of end-of-options */
-    if(have_options){
-        block_total_length += sizeof(struct option);
-    }
-    /* write block header */
-    idb.block_type = INTERFACE_DESCRIPTION_BLOCK_TYPE;
-    idb.block_total_length = block_total_length;
-    idb.link_type = link_type;
-    idb.reserved = 0;
-    idb.snap_len = snap_len;
-    WRITE_DATA(fp, &idb, sizeof(struct idb), *bytes_written, err);
-    /* write comment string if applicable */
-    if ((comment)&&(strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) {
-        option.type = OPT_COMMENT;
-        option.value_length = (guint16)(strlen(comment) + 1);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, comment, strlen(comment) + 1, *bytes_written, err);
-        if ((strlen(comment) + 1) % 4) {
-            WRITE_DATA(fp, &padding, 4 - (strlen(comment) + 1) % 4 , *bytes_written, err);
-        }
-    }
-    /* write interface name string if applicable */
-    if ((name)&&(strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
-        option.type = IDB_NAME;
-        option.value_length = (guint16)(strlen(name) + 1);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, name, strlen(name) + 1, *bytes_written, err);
-        if ((strlen(name) + 1) % 4) {
-            WRITE_DATA(fp, &padding, 4 - (strlen(name) + 1) % 4 , *bytes_written, err);
-        }
-    }
-    /* write interface description string if applicable */
-    if ((descr)&&(strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) {
-        option.type = IDB_DESCRIPTION;
-        option.value_length = (guint16)(strlen(descr) + 1);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, name, strlen(descr) + 1, *bytes_written, err);
-        if ((strlen(descr) + 1) % 4) {
-            WRITE_DATA(fp, &padding, 4 - (strlen(descr) + 1) % 4 , *bytes_written, err);
-        }
-    }
-    /* write filter string if applicable */
-    if ((filter)&&(strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
-        option.type = IDB_FILTER;
-        option.value_length = (guint16)(strlen(filter) + 1);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, filter, strlen(filter) + 1, *bytes_written, err);
-        if ((strlen(filter) + 1) % 4) {
-            WRITE_DATA(fp, &padding, 4 - (strlen(filter) + 1) % 4 , *bytes_written, err);
-        }
-    }
-
-    /* write os string if applicable */
-    if ((os)&&(strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) {
-        option.type = IDB_OS;
-        option.value_length = (guint16)(strlen(filter) + 1);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, filter, strlen(os) + 1, *bytes_written, err);
-        if ((strlen(os) + 1) % 4) {
-            WRITE_DATA(fp, &padding, 4 - (strlen(os) + 1) % 4 , *bytes_written, err);
-        }
-    }
-
-
-    /* IDB_IF_SPEED       8 */
-    if(if_speed != 0){
-        option.type = IDB_IF_SPEED;
-        option.value_length = sizeof(guint64);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, &if_speed, sizeof(guint64), *bytes_written, err);
-    }
-    /* IDB_TSRESOL        9 */
-    if(tsresol != 0){
-        option.type = IDB_TSRESOL;
-        option.value_length = sizeof(guint8);
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-        WRITE_DATA(fp, &if_speed, sizeof(guint8), *bytes_written, err);
-        WRITE_DATA(fp, &padding, 3 , *bytes_written, err);
-    }
-
-    if(have_options){
-        /* write end of options */
-        option.type = OPT_ENDOFOPT;
-        option.value_length = 0;
-        WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
-    }
-    /* write the trailing Block Total Length */
-    WRITE_DATA(fp, &block_total_length, sizeof(guint32), *bytes_written, err);
-    return TRUE;
+       struct idb idb;
+       struct option option;
+       guint32 block_total_length;
+       const guint32 padding = 0;
+       gboolean have_options = FALSE;
+
+       block_total_length = sizeof(struct idb) + sizeof(guint32);
+       /* OPT_COMMENT */
+       if ((comment != NULL) && (strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) {
+               block_total_length += sizeof(struct option) +
+                                     (guint16)(ADD_PADDING(strlen(comment) + 1));
+               have_options = TRUE;
+       }
+
+       /* IDB_DESCRIPTION */
+       if ((descr != NULL) && (strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) {
+               block_total_length += sizeof(struct option) +
+                                     (guint16)(ADD_PADDING(strlen(descr) + 1));
+               have_options = TRUE;
+       }
+
+       /* IDB_NAME */
+       if ((name != NULL) && (strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
+               block_total_length += sizeof(struct option) +
+                                     (guint16)(ADD_PADDING(strlen(name) + 1));
+               have_options = TRUE;
+       }
+
+       /* IDB_FILTER */
+       if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
+               block_total_length += sizeof(struct option) +
+                                     (guint16)(ADD_PADDING(strlen(filter) + 1));
+               have_options = TRUE;
+       }
+
+       /* IDB_OS */
+       if ((os != NULL) && (strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) {
+               block_total_length += sizeof(struct option) +
+                                    (guint16)(ADD_PADDING(strlen(os) + 1));
+               have_options = TRUE;
+       }
+
+       /* IDB_IF_SPEED       8 */
+       if (if_speed != 0) {
+               block_total_length += sizeof(struct option) + sizeof(guint64);
+               have_options = TRUE;
+       }
+
+       /* IDB_TSRESOL        9 */
+       if (tsresol != 0) {
+               block_total_length += sizeof(struct option) + sizeof(struct option);
+               have_options = TRUE;
+       }
+
+       /* If we have options add size of end-of-options */
+       if (have_options) {
+               block_total_length += sizeof(struct option);
+       }
+
+       /* write block header */
+       idb.block_type = INTERFACE_DESCRIPTION_BLOCK_TYPE;
+       idb.block_total_length = block_total_length;
+       idb.link_type = link_type;
+       idb.reserved = 0;
+       idb.snap_len = snap_len;
+       WRITE_DATA(fp, &idb, sizeof(struct idb), *bytes_written, err);
+
+       /* write comment string if applicable */
+       if ((comment != NULL) && (strlen(comment) > 0) && (strlen(comment) < G_MAXUINT16)) {
+               option.type = OPT_COMMENT;
+               option.value_length = (guint16)(strlen(comment) + 1);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, comment, strlen(comment) + 1, *bytes_written, err);
+               if ((strlen(comment) + 1) % 4) {
+                       WRITE_DATA(fp, &padding, 4 - (strlen(comment) + 1) % 4 , *bytes_written, err);
+               }
+       }
+
+       /* write interface name string if applicable */
+       if ((name != NULL) && (strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
+               option.type = IDB_NAME;
+               option.value_length = (guint16)(strlen(name) + 1);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, name, strlen(name) + 1, *bytes_written, err);
+               if ((strlen(name) + 1) % 4) {
+                       WRITE_DATA(fp, &padding, 4 - (strlen(name) + 1) % 4 , *bytes_written, err);
+               }
+       }
+
+       /* write interface description string if applicable */
+       if ((descr != NULL) && (strlen(descr) > 0) && (strlen(descr) < G_MAXUINT16)) {
+               option.type = IDB_DESCRIPTION;
+               option.value_length = (guint16)(strlen(descr) + 1);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, name, strlen(descr) + 1, *bytes_written, err);
+               if ((strlen(descr) + 1) % 4) {
+                       WRITE_DATA(fp, &padding, 4 - (strlen(descr) + 1) % 4 , *bytes_written, err);
+               }
+       }
+
+       /* write filter string if applicable */
+       if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
+               option.type = IDB_FILTER;
+               option.value_length = (guint16)(strlen(filter) + 1);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, filter, strlen(filter) + 1, *bytes_written, err);
+               if ((strlen(filter) + 1) % 4) {
+                       WRITE_DATA(fp, &padding, 4 - (strlen(filter) + 1) % 4 , *bytes_written, err);
+               }
+       }
+
+       /* write os string if applicable */
+       if ((os != NULL) && (strlen(os) > 0) && (strlen(os) < G_MAXUINT16)) {
+               option.type = IDB_OS;
+               option.value_length = (guint16)(strlen(filter) + 1);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, filter, strlen(os) + 1, *bytes_written, err);
+               if ((strlen(os) + 1) % 4) {
+                       WRITE_DATA(fp, &padding, 4 - (strlen(os) + 1) % 4 , *bytes_written, err);
+               }
+       }
+
+       /* IDB_IF_SPEED       8 */
+       if (if_speed != 0) {
+               option.type = IDB_IF_SPEED;
+               option.value_length = sizeof(guint64);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, &if_speed, sizeof(guint64), *bytes_written, err);
+       }
+
+       /* IDB_TSRESOL        9 */
+       if (tsresol != 0) {
+               option.type = IDB_TSRESOL;
+               option.value_length = sizeof(guint8);
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+               WRITE_DATA(fp, &if_speed, sizeof(guint8), *bytes_written, err);
+               WRITE_DATA(fp, &padding, 3 , *bytes_written, err);
+       }
+
+       if (have_options) {
+               /* write end of options */
+               option.type = OPT_ENDOFOPT;
+               option.value_length = 0;
+               WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+       }
+
+       /* write the trailing Block Total Length */
+       WRITE_DATA(fp, &block_total_length, sizeof(guint32), *bytes_written, err);
+       return TRUE;
 }
 
 /* Write a record for a packet to a dump file.
index 16c8bc23c980133d2b36a845dd282f259cac9f86..d9e6d26dce506f96f5207575524aeb2f3da2c860 100644 (file)
--- a/pcapio.h
+++ b/pcapio.h
@@ -64,16 +64,16 @@ libpcap_write_session_header_block(FILE *fp,             /**< File pointer */
 
 extern gboolean
 libpcap_write_interface_description_block(FILE *fp,
-                                          const char *comment,  /* OPT_COMMENT       1 */
+                                          const char *comment,  /* OPT_COMMENT           1 */
                                           const char *name,     /* IDB_NAME             2 */
-                                          const char *descr,    /* IDB_DESCRIPTION   3 */
-                                          const char *filter,   /* IDB_FILTER       11 */
-                                          const char *os,              /* IDB_OS                       12 */
+                                          const char *descr,    /* IDB_DESCRIPTION       3 */
+                                          const char *filter,   /* IDB_FILTER           11 */
+                                          const char *os,       /* IDB_OS               12 */
                                           int link_type,
                                           int snap_len,
                                           long *bytes_written,
-                                          guint64 if_speed,            /* IDB_IF_SPEED       8 */
-                                          guint8 tsresol,              /* IDB_TSRESOL        9 */
+                                          guint64 if_speed,     /* IDB_IF_SPEED          8 */
+                                          guint8 tsresol,       /* IDB_TSRESOL           9 */
                                           int *err);
 
 extern gboolean