7 #if HAVE_MACHINE_TYPES_H
8 # include <machine/types.h>
12 #define ntohl(_x) (_x)
13 #define ntohs(_x) (_x)
14 #define htonl(_x) (_x)
15 #define htons(_x) (_x)
17 #include <netinet/in.h>
18 #endif /* __LCLINT__ */
24 /* The lead needs to be 8 byte aligned */
26 int writeLead(FD_t fd, struct rpmlead *lead)
30 memcpy(&l, lead, sizeof(*lead));
32 l.magic[0] = RPMLEAD_MAGIC0;
33 l.magic[1] = RPMLEAD_MAGIC1;
34 l.magic[2] = RPMLEAD_MAGIC2;
35 l.magic[3] = RPMLEAD_MAGIC3;
37 l.type = htons(l.type);
38 l.archnum = htons(l.archnum);
39 l.osnum = htons(l.osnum);
40 l.signature_type = htons(l.signature_type);
42 if (Fwrite(&l, sizeof(char), sizeof(l), fd) < 0) {
49 int readLead(FD_t fd, struct rpmlead *lead)
51 if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
52 rpmError(RPMERR_READ, _("read failed: %s (%d)"), Fstrerror(fd),
57 lead->type = ntohs(lead->type);
58 lead->archnum = ntohs(lead->archnum);
59 lead->osnum = ntohs(lead->osnum);
62 lead->signature_type = ntohs(lead->signature_type);