1 #include <netinet/in.h>
11 /* The lead needs to be 8 byte aligned */
13 int writeLead(int fd, struct rpmlead *lead)
17 memcpy(&l, lead, sizeof(*lead));
19 l.magic[0] = RPMLEAD_MAGIC0;
20 l.magic[1] = RPMLEAD_MAGIC1;
21 l.magic[2] = RPMLEAD_MAGIC2;
22 l.magic[3] = RPMLEAD_MAGIC3;
24 l.type = htons(l.type);
25 l.archnum = htons(l.archnum);
26 l.osnum = htons(l.osnum);
27 l.signature_type = htons(l.signature_type);
29 write(fd, &l, sizeof(l));
34 int readLead(int fd, struct rpmlead *lead)
36 if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
37 error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
42 lead->type = ntohs(lead->type);
43 lead->archnum = ntohs(lead->archnum);
44 lead->osnum = ntohs(lead->osnum);
47 lead->signature_type = ntohs(lead->signature_type);