added support for old packages, lots of bug fixes
authorroot <devnull@localhost>
Wed, 14 Feb 1996 17:55:28 +0000 (17:55 +0000)
committerroot <devnull@localhost>
Wed, 14 Feb 1996 17:55:28 +0000 (17:55 +0000)
CVS patchset: 265
CVS date: 1996/02/14 17:55:28

lib/rpmlead.c
lib/rpmlead.h

index be211aa..2a5f2fd 100644 (file)
@@ -1,8 +1,9 @@
+#include <netinet/in.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <asm/byteorder.h>
 
+#include "rpmerr.h"
 #include "rpmlead.h"
 
 int writeLead(int fd, struct rpmlead *lead)
@@ -28,12 +29,18 @@ int writeLead(int fd, struct rpmlead *lead)
 
 int readLead(int fd, struct rpmlead *lead)
 {
-    read(fd, lead, sizeof(*lead));
+    if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
+       error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno), 
+             errno);
+       return 1;
+    }
 
     lead->type = ntohs(lead->type);
     lead->archnum = ntohs(lead->archnum);
     lead->osnum = ntohs(lead->osnum);
-    lead->signature_type = ntohs(lead->signature_type);
+
+    if (lead->major >= 2)
+       lead->signature_type = ntohs(lead->signature_type);
 
     return 0;
 }
index 62bd3c4..eadd16c 100644 (file)
@@ -25,6 +25,17 @@ struct rpmlead {
     char reserved[16];      /* pads to 96 bytes -- 8 byte aligned! */
 } ;
 
+struct oldrpmlead {            /* for version 1 packages */
+    unsigned char magic[4];
+    unsigned char major, minor;
+    short type;
+    short archnum;
+    char name[66];
+    unsigned long specOffset;
+    unsigned long specLength;
+    unsigned long archiveOffset;
+} ;
+
 int writeLead(int fd, struct rpmlead *lead);
 int readLead(int fd, struct rpmlead *lead);