3 #if HAVE_MACHINE_TYPES_H
4 # include <machine/types.h>
7 #include <netinet/in.h>
14 /* The lead needs to be 8 byte aligned */
16 int writeLead(int fd, struct rpmlead *lead)
20 memcpy(&l, lead, sizeof(*lead));
22 l.magic[0] = RPMLEAD_MAGIC0;
23 l.magic[1] = RPMLEAD_MAGIC1;
24 l.magic[2] = RPMLEAD_MAGIC2;
25 l.magic[3] = RPMLEAD_MAGIC3;
27 l.type = htons(l.type);
28 l.archnum = htons(l.archnum);
29 l.osnum = htons(l.osnum);
30 l.signature_type = htons(l.signature_type);
32 if (write(fd, &l, sizeof(l)) < 0) {
39 int readLead(int fd, struct rpmlead *lead)
41 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
42 rpmError(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);