Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

lib/rpmlead.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #if HAVE_MACHINE_TYPES_H
00008 # include <machine/types.h>
00009 #endif
00010 
00011 #if !defined(__LCLINT__)
00012 #include <netinet/in.h>
00013 #endif  /* __LCLINT__ */
00014 
00015 #include <rpmlib.h>
00016 
00017 #include "rpmlead.h"
00018 #include "debug.h"
00019 
00020 /* The lead needs to be 8 byte aligned */
00021 
00022 int writeLead(FD_t fd, struct rpmlead *lead)
00023 {
00024     struct rpmlead l;
00025 
00026     memcpy(&l, lead, sizeof(*lead));
00027     
00028     l.magic[0] = RPMLEAD_MAGIC0;
00029     l.magic[1] = RPMLEAD_MAGIC1;
00030     l.magic[2] = RPMLEAD_MAGIC2;
00031     l.magic[3] = RPMLEAD_MAGIC3;
00032 
00033     l.type = htons(l.type);
00034     l.archnum = htons(l.archnum);
00035     l.osnum = htons(l.osnum);
00036     l.signature_type = htons(l.signature_type);
00037         
00038     if (Fwrite(&l, sizeof(char), sizeof(l), fd) < 0) {
00039         return 1;
00040     }
00041 
00042     return 0;
00043 }
00044 
00045 int readLead(FD_t fd, struct rpmlead *lead)
00046 {
00047     if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
00048         rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd), 
00049               errno);
00050         return 1;
00051     }
00052 
00053     lead->type = ntohs(lead->type);
00054     lead->archnum = ntohs(lead->archnum);
00055     lead->osnum = ntohs(lead->osnum);
00056 
00057     if (lead->major >= 2)
00058         lead->signature_type = ntohs(lead->signature_type);
00059 
00060     return 0;
00061 }

Generated at Mon May 21 08:53:40 2001 for rpm by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001