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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
96
97
98
99
100
101
102
103
104
105
106
107
108
109
112
117
118
119
120
121
122
123
124
125
126
127
128
154
155
156
157
158
159
160
161
162
163
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
212
213
214
217
219
220
226
231
237
238
239
240
/* ... */
/* ... */
#include "lwip/opt.h"
#include "lwip/def.h"
#include <string.h>
#if BYTE_ORDER == LITTLE_ENDIAN
#if !defined(lwip_htons)
/* ... */
u16_t
lwip_htons(u16_t n)
{
return PP_HTONS(n);
}{ ... }
#endif/* ... */
#if !defined(lwip_htonl)
/* ... */
u32_t
lwip_htonl(u32_t n)
{
return PP_HTONL(n);
}{ ... }
#endif/* ... */
/* ... */
#endif
#ifndef lwip_strnstr
/* ... */
char *
lwip_strnstr(const char *buffer, const char *token, size_t n)
{
const char *p;
size_t tokenlen = strlen(token);
if (tokenlen == 0) {
return LWIP_CONST_CAST(char *, buffer);
}if (tokenlen == 0) { ... }
for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) {
if ((*p == *token) && (strncmp(p, token, tokenlen) == 0)) {
return LWIP_CONST_CAST(char *, p);
}if ((*p == *token) && (strncmp(p, token, tokenlen) == 0)) { ... }
}for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) { ... }
return NULL;
}{ ... }
#endif/* ... */
#ifndef lwip_stricmp
/* ... */
int
lwip_stricmp(const char *str1, const char *str2)
{
char c1, c2;
do {
c1 = *str1++;
c2 = *str2++;
if (c1 != c2) {
char c1_upc = c1 | 0x20;
if ((c1_upc >= 'a') && (c1_upc <= 'z')) {
/* ... */
char c2_upc = c2 | 0x20;
if (c1_upc != c2_upc) {
return 1;
}if (c1_upc != c2_upc) { ... }
}if ((c1_upc >= 'a') && (c1_upc <= 'z')) { ... } else {
return 1;
}else { ... }
}if (c1 != c2) { ... }
...} while (c1 != 0);
return 0;
}{ ... }
#endif/* ... */
#ifndef lwip_strnicmp
/* ... */
int
lwip_strnicmp(const char *str1, const char *str2, size_t len)
{
char c1, c2;
do {
c1 = *str1++;
c2 = *str2++;
if (c1 != c2) {
char c1_upc = c1 | 0x20;
if ((c1_upc >= 'a') && (c1_upc <= 'z')) {
/* ... */
char c2_upc = c2 | 0x20;
if (c1_upc != c2_upc) {
return 1;
}if (c1_upc != c2_upc) { ... }
}if ((c1_upc >= 'a') && (c1_upc <= 'z')) { ... } else {
return 1;
}else { ... }
}if (c1 != c2) { ... }
len--;
...} while ((len != 0) && (c1 != 0));
return 0;
}{ ... }
#endif/* ... */
#ifndef lwip_itoa
/* ... */
void
lwip_itoa(char *result, size_t bufsize, int number)
{
char *res = result;
char *tmp = result + bufsize - 1;
int n = (number >= 0) ? number : -number;
if (bufsize < 2) {
if (bufsize == 1) {
*result = 0;
}if (bufsize == 1) { ... }
return;
}if (bufsize < 2) { ... }
if (number < 0) {
*res++ = '-';
}if (number < 0) { ... }
/* ... */
*tmp = 0;
while ((n != 0) && (tmp > res)) {
char val = (char)('0' + (n % 10));
tmp--;
*tmp = val;
n = n / 10;
}while ((n != 0) && (tmp > res)) { ... }
if (n) {
*result = 0;
return;
}if (n) { ... }
if (*tmp == 0) {
*res++ = '0';
*res++ = 0;
return;
}if (*tmp == 0) { ... }
memmove(res, tmp, (size_t)((result + bufsize) - tmp));
}{ ... }
#endif/* ... */