3 #if HAVE_MACHINE_TYPES_H
4 # include <machine/types.h>
10 #define htonl(_x) (_x)
11 #define htons(_x) (_x)
13 #include <netinet/in.h>
14 #endif /* __LCLINT__ */
20 /* The lead needs to be 8 byte aligned */
22 int writeLead(FD_t fd, struct rpmlead *lead)
26 memcpy(&l, lead, sizeof(*lead));
28 l.magic[0] = RPMLEAD_MAGIC0;
29 l.magic[1] = RPMLEAD_MAGIC1;
30 l.magic[2] = RPMLEAD_MAGIC2;
31 l.magic[3] = RPMLEAD_MAGIC3;
33 l.type = htons(l.type);
34 l.archnum = htons(l.archnum);
35 l.osnum = htons(l.osnum);
36 l.signature_type = htons(l.signature_type);
38 if (fdWrite(fd, &l, sizeof(l)) < 0) {
45 int readLead(FD_t fd, struct rpmlead *lead)
47 if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
48 rpmError(RPMERR_READERROR, _("read failed: %s (%d)"), strerror(errno),
53 lead->type = ntohs(lead->type);
54 lead->archnum = ntohs(lead->archnum);
55 lead->osnum = ntohs(lead->osnum);
58 lead->signature_type = ntohs(lead->signature_type);