1 #ifdef HAVE_MACHINE_TYPES_H
2 # include <machine/types.h>
5 #include <netinet/in.h>
15 /* The lead needs to be 8 byte aligned */
17 int writeLead(int fd, struct rpmlead *lead)
21 memcpy(&l, lead, sizeof(*lead));
23 l.magic[0] = RPMLEAD_MAGIC0;
24 l.magic[1] = RPMLEAD_MAGIC1;
25 l.magic[2] = RPMLEAD_MAGIC2;
26 l.magic[3] = RPMLEAD_MAGIC3;
28 l.type = htons(l.type);
29 l.archnum = htons(l.archnum);
30 l.osnum = htons(l.osnum);
31 l.signature_type = htons(l.signature_type);
33 write(fd, &l, sizeof(l));
38 int readLead(int fd, struct rpmlead *lead)
40 if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
41 error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
46 lead->type = ntohs(lead->type);
47 lead->archnum = ntohs(lead->archnum);
48 lead->osnum = ntohs(lead->osnum);
51 lead->signature_type = ntohs(lead->signature_type);