]> git.neil.brown.name Git - metad.git/blob - recvlist.c
Assorted reformating
[metad.git] / recvlist.c
1 #include <malloc.h>
2
3 char *recvbuf;
4 int recvptr;
5
6 void init_recv(char *buf)
7 {
8         recvbuf  = buf;
9         recvptr = 0;
10 }
11
12 int get_byte()
13 {
14         return 0xff & recvbuf[recvptr++];
15 }
16
17 int get_int()
18 {
19         int i = 0;
20         i = get_byte();
21         i = (i<<8) | get_byte();
22         i = (i<<8) | get_byte();
23         i = (i<<8) | get_byte();
24         return i;
25 }
26
27 char *get_str()
28 {
29         int l = get_int();
30         char *s,*p;
31         if (l == 0)
32                 return (char*)0;
33         p = s = (char*)malloc(l);
34         while (l--)
35                 *p++ = get_byte();
36         return s;
37 }