1 #ifdef HAVE_MACHINE_TYPES_H
2 # include <machine/types.h>
5 #include <netinet/in.h>
16 /* The lead needs to be 8 byte aligned */
18 int writeLead(int fd, struct rpmlead *lead)
22 memcpy(&l, lead, sizeof(*lead));
24 l.magic[0] = RPMLEAD_MAGIC0;
25 l.magic[1] = RPMLEAD_MAGIC1;
26 l.magic[2] = RPMLEAD_MAGIC2;
27 l.magic[3] = RPMLEAD_MAGIC3;
29 l.type = htons(l.type);
30 l.archnum = htons(l.archnum);
31 l.osnum = htons(l.osnum);
32 l.signature_type = htons(l.signature_type);
34 write(fd, &l, sizeof(l));
39 int readLead(int fd, struct rpmlead *lead)
41 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
42 error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
47 lead->type = ntohs(lead->type);
48 lead->archnum = ntohs(lead->archnum);
49 lead->osnum = ntohs(lead->osnum);
52 lead->signature_type = ntohs(lead->signature_type);