1 #ifdef HAVE_MACHINE_TYPES_H
2 # include <machine/types.h>
6 #include <netinet/in.h>
17 /* The lead needs to be 8 byte aligned */
19 int writeLead(int fd, struct rpmlead *lead)
23 memcpy(&l, lead, sizeof(*lead));
25 l.magic[0] = RPMLEAD_MAGIC0;
26 l.magic[1] = RPMLEAD_MAGIC1;
27 l.magic[2] = RPMLEAD_MAGIC2;
28 l.magic[3] = RPMLEAD_MAGIC3;
30 l.type = htons(l.type);
31 l.archnum = htons(l.archnum);
32 l.osnum = htons(l.osnum);
33 l.signature_type = htons(l.signature_type);
35 write(fd, &l, sizeof(l));
40 int readLead(int fd, struct rpmlead *lead)
42 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
43 rpmError(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
48 lead->type = ntohs(lead->type);
49 lead->archnum = ntohs(lead->archnum);
50 lead->osnum = ntohs(lead->osnum);
53 lead->signature_type = ntohs(lead->signature_type);