|
Revision 12429, 0.9 kB
(checked in by BrainSlayer, 5 months ago)
|
compressed ELF support is required for ubnt images
|
| Line | |
|---|
| 1 |
/* |
|---|
| 2 |
* lib.c |
|---|
| 3 |
* copyright 2009 Sebastian Gottschall / NewMedia-NET GmbH / DD-WRT.COM |
|---|
| 4 |
* licensed under GPL conditions |
|---|
| 5 |
* this code is based on linux sources |
|---|
| 6 |
*/ |
|---|
| 7 |
#include <linux/kernel.h> |
|---|
| 8 |
|
|---|
| 9 |
#include <asm/uaccess.h> |
|---|
| 10 |
|
|---|
| 11 |
char *strchr(const char *s, int c) |
|---|
| 12 |
{ |
|---|
| 13 |
for (; *s != (char)c; ++s) |
|---|
| 14 |
if (*s == '\0') |
|---|
| 15 |
return NULL; |
|---|
| 16 |
return (char *)s; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
size_t strlen(const char *s) |
|---|
| 20 |
{ |
|---|
| 21 |
const char *sc; |
|---|
| 22 |
|
|---|
| 23 |
for (sc = s; *sc != '\0'; ++sc) |
|---|
| 24 |
/* nothing */ ; |
|---|
| 25 |
return sc - s; |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
void *memmove( void *s1, const void *s2, size_t n ) |
|---|
| 29 |
{ |
|---|
| 30 |
char *dst = (char *)s1; |
|---|
| 31 |
const char *src = (const char *)s2; |
|---|
| 32 |
if ((src < dst) && (dst < (src + n))) |
|---|
| 33 |
{ |
|---|
| 34 |
// Have to copy backwards |
|---|
| 35 |
src += n; |
|---|
| 36 |
dst += n; |
|---|
| 37 |
while (n--) |
|---|
| 38 |
{ |
|---|
| 39 |
*--dst = *--src; |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
else |
|---|
| 43 |
{ |
|---|
| 44 |
while (n--) |
|---|
| 45 |
{ |
|---|
| 46 |
*dst++ = *src++; |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
return s1; |
|---|
| 52 |
} // __memmove() |
|---|
| 53 |
|
|---|