7 #if HAVE_MACHINE_TYPES_H
8 # include <machine/types.h>
11 #include <netinet/in.h>
18 /* The lead needs to be 8 byte aligned */
20 int writeLead(FD_t fd, const struct rpmlead *lead)
24 memcpy(&l, lead, sizeof(*lead));
26 l.magic[0] = RPMLEAD_MAGIC0;
27 l.magic[1] = RPMLEAD_MAGIC1;
28 l.magic[2] = RPMLEAD_MAGIC2;
29 l.magic[3] = RPMLEAD_MAGIC3;
31 l.type = htons(l.type);
32 l.archnum = htons(l.archnum);
33 l.osnum = htons(l.osnum);
34 l.signature_type = htons(l.signature_type);
36 if (Fwrite(&l, sizeof(char), sizeof(l), fd) != sizeof(l)) {
43 int readLead(FD_t fd, struct rpmlead *lead)
45 memset(lead, 0, sizeof(*lead));
46 if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
47 rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd),
52 lead->type = ntohs(lead->type);
53 lead->archnum = ntohs(lead->archnum);
54 lead->osnum = ntohs(lead->osnum);
57 lead->signature_type = ntohs(lead->signature_type);