1 #include <netinet/in.h>
11 int writeLead(int fd, struct rpmlead *lead)
15 memcpy(&l, lead, sizeof(*lead));
17 l.magic[0] = RPMLEAD_MAGIC0;
18 l.magic[1] = RPMLEAD_MAGIC1;
19 l.magic[2] = RPMLEAD_MAGIC2;
20 l.magic[3] = RPMLEAD_MAGIC3;
22 l.type = htons(l.type);
23 l.archnum = htons(l.archnum);
24 l.osnum = htons(l.osnum);
25 l.signature_type = htons(l.signature_type);
27 write(fd, &l, sizeof(l));
32 int readLead(int fd, struct rpmlead *lead)
34 if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
35 error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
40 lead->type = ntohs(lead->type);
41 lead->archnum = ntohs(lead->archnum);
42 lead->osnum = ntohs(lead->osnum);
45 lead->signature_type = ntohs(lead->signature_type);