7 #if HAVE_MACHINE_TYPES_H
8 # include <machine/types.h>
11 #include <netinet/in.h>
18 /*@unchecked@*/ /*@observer@*/
19 static unsigned char lead_magic[] = {
20 RPMLEAD_MAGIC0, RPMLEAD_MAGIC1, RPMLEAD_MAGIC2, RPMLEAD_MAGIC3
23 /* The lead needs to be 8 byte aligned */
25 rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
30 memcpy(&l, lead, sizeof(l));
32 memcpy(&l.magic, lead_magic, sizeof(l.magic));
34 l.type = htons(l.type);
35 l.archnum = htons(l.archnum);
36 l.osnum = htons(l.osnum);
37 l.signature_type = htons(l.signature_type);
40 if (Fwrite(&l, 1, sizeof(l), fd) != sizeof(l))
47 rpmRC readLead(FD_t fd, struct rpmlead *lead)
50 memset(lead, 0, sizeof(*lead));
52 /*@-type@*/ /* FIX: remove timed read */
53 if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
54 rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd),
60 if (memcmp(lead->magic, lead_magic, sizeof(lead_magic)))
63 lead->type = ntohs(lead->type);
64 lead->archnum = ntohs(lead->archnum);
65 lead->osnum = ntohs(lead->osnum);
68 lead->signature_type = ntohs(lead->signature_type);