get rid of some warnings
[platform/upstream/rpm.git] / lib / rpmlead.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <asm/byteorder.h>
5
6 #include "rpmlead.h"
7
8 int writeLead(int fd, struct rpmlead *lead)
9 {
10     struct rpmlead l;
11
12     memcpy(&l, lead, sizeof(*lead));
13     
14     l.magic[0] = RPMLEAD_MAGIC0;
15     l.magic[1] = RPMLEAD_MAGIC1;
16     l.magic[2] = RPMLEAD_MAGIC2;
17     l.magic[3] = RPMLEAD_MAGIC3;
18
19     l.type = htons(l.type);
20     l.archnum = htons(l.archnum);
21     l.osnum = htons(l.osnum);
22     l.signature_type = htons(l.signature_type);
23         
24     write(fd, &l, sizeof(l));
25
26     return 0;
27 }
28
29 int readLead(int fd, struct rpmlead *lead)
30 {
31     read(fd, lead, sizeof(*lead));
32
33     lead->type = ntohs(lead->type);
34     lead->archnum = ntohs(lead->archnum);
35     lead->osnum = ntohs(lead->osnum);
36     lead->signature_type = ntohs(lead->signature_type);
37
38     return 0;
39 }
40