-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode_reply.ino
51 lines (48 loc) · 1.07 KB
/
decode_reply.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
int get_header_line(int line,word off)
{
memset(line_buf,NULL,sizeof(line_buf));
if (off != 0)
{
uint16_t pos = off;
int line_num = 0;
int line_pos = 0;
while (Ethernet::buffer[pos])
{
if (Ethernet::buffer[pos]=='\n')
{
line_num++; line_buf[line_pos] = '\0';
line_pos = 0;
if (line_num == line) return 1;
}
else
{
if (line_pos<49) {line_buf[line_pos] = Ethernet::buffer[pos]; line_pos++;}
}
pos++;
}
}
return 0;
}
int get_reply_data(word off)
{
memset(line_buf,NULL,sizeof(line_buf));
if (off != 0)
{
uint16_t pos = off;
int line_num = 0;
int line_pos = 0;
// Skip over header until data part is found
while (Ethernet::buffer[pos]) {
if (Ethernet::buffer[pos-1]=='\n' && Ethernet::buffer[pos]=='\r') break;
pos++;
}
pos+=4;
while (Ethernet::buffer[pos])
{
if (line_pos<49) {line_buf[line_pos] = Ethernet::buffer[pos]; line_pos++;} else break;
pos++;
}
line_buf[line_pos] = '\0';
}
return 0;
}