4 #if HAVE_MACHINE_TYPES_H
5 # include <machine/types.h>
8 #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 if (write(fd, &l, sizeof(l)) < 0) {
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);