ReactOS 0.4.16-dev-258-g81860b4
Non-standard functions
Collaboration diagram for Non-standard functions:

Functions

charlwip_strnstr (const char *buffer, const char *token, size_t n)
 
charlwip_strnistr (const char *buffer, const char *token, size_t n)
 
int lwip_stricmp (const char *str1, const char *str2)
 
int lwip_strnicmp (const char *str1, const char *str2, size_t len)
 
void lwip_itoa (char *result, size_t bufsize, int number)
 

Detailed Description

lwIP provides default implementations for non-standard functions. These can be mapped to OS functions to reduce code footprint if desired. All defines related to this section must not be placed in lwipopts.h, but in arch/cc.h! These options cannot be #defined in lwipopts.h since they are not options of lwIP itself, but options of the lwIP port to your system.

Function Documentation

◆ lwip_itoa()

void lwip_itoa ( char result,
size_t  bufsize,
int  number 
)

lwIP default implementation for itoa() non-standard function. This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform port.

Definition at line 222 of file def.c.

223{
224 char *res = result;
225 char *tmp = result + bufsize - 1;
226 int n = (number >= 0) ? number : -number;
227
228 /* handle invalid bufsize */
229 if (bufsize < 2) {
230 if (bufsize == 1) {
231 *result = 0;
232 }
233 return;
234 }
235
236 /* First, add sign */
237 if (number < 0) {
238 *res++ = '-';
239 }
240 /* Then create the string from the end and stop if buffer full,
241 and ensure output string is zero terminated */
242 *tmp = 0;
243 while ((n != 0) && (tmp > res)) {
244 char val = (char)('0' + (n % 10));
245 tmp--;
246 *tmp = val;
247 n = n / 10;
248 }
249 if (n) {
250 /* buffer is too small */
251 *result = 0;
252 return;
253 }
254 if (*tmp == 0) {
255 /* Nothing added? */
256 *res++ = '0';
257 *res++ = 0;
258 return;
259 }
260 /* move from temporary buffer to output buffer (sign is not moved) */
261 memmove(res, tmp, (size_t)((result + bufsize) - tmp));
262}
unsigned char
Definition: typeof.h:29
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLuint64EXT * result
Definition: glext.h:11304
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static unsigned int number
Definition: dsound.c:1479

Referenced by file_write_http_header(), netif_index_to_name(), and test_def_itoa().

◆ lwip_stricmp()

int lwip_stricmp ( const char str1,
const char str2 
)

lwIP default implementation for stricmp() non-standard function. This can be #defined to stricmp() depending on your platform port.

Definition at line 151 of file def.c.

152{
153 char c1, c2;
154
155 do {
156 c1 = *str1++;
157 c2 = *str2++;
158 if (c1 != c2) {
159 char c1_upc = c1 | 0x20;
160 if ((c1_upc >= 'a') && (c1_upc <= 'z')) {
161 /* characters are not equal an one is in the alphabet range:
162 downcase both chars and check again */
163 char c2_upc = c2 | 0x20;
164 if (c1_upc != c2_upc) {
165 /* still not equal */
166 /* don't care for < or > */
167 return 1;
168 }
169 } else {
170 /* characters are not equal but none is in the alphabet range */
171 return 1;
172 }
173 }
174 } while (c1 != 0);
175 return 0;
176}

◆ lwip_strnicmp()

int lwip_strnicmp ( const char str1,
const char str2,
size_t  len 
)

lwIP default implementation for strnicmp() non-standard function. This can be #defined to strnicmp() depending on your platform port.

Definition at line 186 of file def.c.

187{
188 char c1, c2;
189
190 do {
191 c1 = *str1++;
192 c2 = *str2++;
193 if (c1 != c2) {
194 char c1_upc = c1 | 0x20;
195 if ((c1_upc >= 'a') && (c1_upc <= 'z')) {
196 /* characters are not equal an one is in the alphabet range:
197 downcase both chars and check again */
198 char c2_upc = c2 | 0x20;
199 if (c1_upc != c2_upc) {
200 /* still not equal */
201 /* don't care for < or > */
202 return 1;
203 }
204 } else {
205 /* characters are not equal but none is in the alphabet range */
206 return 1;
207 }
208 }
209 len--;
210 } while ((len != 0) && (c1 != 0));
211 return 0;
212}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by lwip_strnistr().

◆ lwip_strnistr()

char * lwip_strnistr ( const char buffer,
const char token,
size_t  n 
)

lwIP default implementation for strnistr() non-standard function. This can be #defined to strnistr() depending on your platform port.

Definition at line 128 of file def.c.

129{
130 const char *p;
131 size_t tokenlen = strlen(token);
132 if (tokenlen == 0) {
133 return LWIP_CONST_CAST(char *, buffer);
134 }
135 for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) {
136 if (lwip_strnicmp(p, token, tokenlen) == 0) {
137 return LWIP_CONST_CAST(char *, p);
138 }
139 }
140 return NULL;
141}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define LWIP_CONST_CAST(target_type, val)
Definition: arch.h:240
int lwip_strnicmp(const char *str1, const char *str2, size_t len)
Definition: def.c:186

◆ lwip_strnstr()

char * lwip_strnstr ( const char buffer,
const char token,
size_t  n 
)

lwIP default implementation for strnstr() non-standard function. This can be #defined to strnstr() depending on your platform port.

Definition at line 105 of file def.c.

106{
107 const char *p;
108 size_t tokenlen = strlen(token);
109 if (tokenlen == 0) {
110 return LWIP_CONST_CAST(char *, buffer);
111 }
112 for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) {
113 if ((*p == *token) && (strncmp(p, token, tokenlen) == 0)) {
114 return LWIP_CONST_CAST(char *, p);
115 }
116 }
117 return NULL;
118}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534