1 #include <netinet/in.h>
9 int writeLead(int fd, struct rpmlead *lead)
13 memcpy(&l, lead, sizeof(*lead));
15 l.magic[0] = RPMLEAD_MAGIC0;
16 l.magic[1] = RPMLEAD_MAGIC1;
17 l.magic[2] = RPMLEAD_MAGIC2;
18 l.magic[3] = RPMLEAD_MAGIC3;
20 l.type = htons(l.type);
21 l.archnum = htons(l.archnum);
22 l.osnum = htons(l.osnum);
23 l.signature_type = htons(l.signature_type);
25 write(fd, &l, sizeof(l));
30 int readLead(int fd, struct rpmlead *lead)
32 if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
33 error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
38 lead->type = ntohs(lead->type);
39 lead->archnum = ntohs(lead->archnum);
40 lead->osnum = ntohs(lead->osnum);
43 lead->signature_type = ntohs(lead->signature_type);