3 #if HAVE_MACHINE_TYPES_H
4 # include <machine/types.h>
7 #include <netinet/in.h>
13 /* The lead needs to be 8 byte aligned */
15 int writeLead(FD_t fd, struct rpmlead *lead)
19 memcpy(&l, lead, sizeof(*lead));
21 l.magic[0] = RPMLEAD_MAGIC0;
22 l.magic[1] = RPMLEAD_MAGIC1;
23 l.magic[2] = RPMLEAD_MAGIC2;
24 l.magic[3] = RPMLEAD_MAGIC3;
26 l.type = htons(l.type);
27 l.archnum = htons(l.archnum);
28 l.osnum = htons(l.osnum);
29 l.signature_type = htons(l.signature_type);
31 if (fdWrite(fd, &l, sizeof(l)) < 0) {
38 int readLead(FD_t fd, struct rpmlead *lead)
40 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
41 rpmError(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);