4 #if HAVE_MACHINE_TYPES_H
5 # include <machine/types.h>
9 #include <netinet/in.h>
21 /* The lead needs to be 8 byte aligned */
23 int writeLead(int fd, struct rpmlead *lead)
27 memcpy(&l, lead, sizeof(*lead));
29 l.magic[0] = RPMLEAD_MAGIC0;
30 l.magic[1] = RPMLEAD_MAGIC1;
31 l.magic[2] = RPMLEAD_MAGIC2;
32 l.magic[3] = RPMLEAD_MAGIC3;
34 l.type = htons(l.type);
35 l.archnum = htons(l.archnum);
36 l.osnum = htons(l.osnum);
37 l.signature_type = htons(l.signature_type);
39 if (write(fd, &l, sizeof(l)) < 0) {
46 int readLead(int fd, struct rpmlead *lead)
48 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
49 rpmError(RPMERR_READERROR, _("read failed: %s (%d)"), strerror(errno),
54 lead->type = ntohs(lead->type);
55 lead->archnum = ntohs(lead->archnum);
56 lead->osnum = ntohs(lead->osnum);
59 lead->signature_type = ntohs(lead->signature_type);