Make "vms_check_file_type()" seek back to the beginning of the line that
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 27 May 2003 10:14:06 +0000 (10:14 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 27 May 2003 10:14:06 +0000 (10:14 +0000)
matched if it succeeds, so that it gets re-read when we read the capture
file - it's a line containing a time stamp for a packet, so we need to
re-read it to get that time stamp.

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

wiretap/vms.c

index 60402eed527ff58f10c5a1e2e90f668845bf397a..3dc505859a9703c4ada72e9f76906db2af315e9c 100644 (file)
@@ -1,6 +1,6 @@
 /* vms.c
  *
- * $Id: vms.c,v 1.18 2003/05/20 20:17:03 guy Exp $
+ * $Id: vms.c,v 1.19 2003/05/27 10:14:06 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
@@ -208,10 +208,17 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
 {
   char buf[VMS_LINE_LENGTH];
   guint        reclen, line;
+  long mpos;
   
   buf[VMS_LINE_LENGTH-1] = '\0';
   
   for (line = 0; line < VMS_HEADER_LINES_TO_CHECK; line++) {
+    mpos = file_tell(wth->fh);
+    if (mpos == -1) {
+      /* Error. */
+      *err = file_error(wth->fh);
+      return FALSE;
+    }
     if (file_gets(buf, VMS_LINE_LENGTH, wth->fh) != NULL) {
       
       reclen = strlen(buf);
@@ -224,6 +231,12 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
       if (strstr(buf, VMS_HDR_MAGIC_STR1) ||
          strstr(buf, VMS_HDR_MAGIC_STR2) ||
          strstr(buf, VMS_HDR_MAGIC_STR3)) {
+       /* Go back to the beginning of this line, so we will
+        * re-read it. */
+       if (file_seek(wth->fh, mpos, SEEK_SET, err) == -1) {
+         /* Error. */
+         return FALSE;
+       }
        return TRUE;
       }
     } else {