nuclear@6: #include nuclear@6: nuclear@6: void *memset(void *s, int c, size_t n) nuclear@6: { nuclear@6: char *ptr = s; nuclear@6: while(n--) { nuclear@6: *ptr++ = c; nuclear@6: } nuclear@6: return s; nuclear@6: } nuclear@6: nuclear@6: void *memcpy(void *dest, const void *src, size_t n) nuclear@6: { nuclear@6: char *dptr = dest; nuclear@6: const char *sptr = src; nuclear@6: nuclear@6: while(n--) { nuclear@6: *dptr++ = *sptr++; nuclear@6: } nuclear@6: return dest; nuclear@6: } nuclear@6: nuclear@6: void *memmove(void *dest, const void *src, size_t n) nuclear@6: { nuclear@6: int i; nuclear@6: char *dptr; nuclear@6: const char *sptr; nuclear@6: nuclear@6: if(dest <= src) { nuclear@6: /* forward copy */ nuclear@6: dptr = dest; nuclear@6: sptr = src; nuclear@6: for(i=0; i= s) { nuclear@6: if(*ptr == c) { nuclear@6: return (char*)ptr; nuclear@6: } nuclear@6: } nuclear@6: return 0; nuclear@6: } nuclear@6: nuclear@6: char *strstr(const char *str, const char *substr) nuclear@6: { nuclear@6: while(*str) { nuclear@6: const char *s1 = str; nuclear@6: const char *s2 = substr; nuclear@6: nuclear@6: while(*s1 && *s1 == *s2) { nuclear@6: s1++; nuclear@6: s2++; nuclear@6: } nuclear@6: if(!*s2) { nuclear@6: return (char*)str; nuclear@6: } nuclear@6: str++; nuclear@6: } nuclear@6: return 0; nuclear@6: } nuclear@6: nuclear@6: int strcmp(const char *s1, const char *s2) nuclear@6: { nuclear@6: while(*s1 && *s1 == *s2) { nuclear@6: s1++; nuclear@6: s2++; nuclear@6: } nuclear@6: return *s1 - *s2; nuclear@6: }