741455b94b2fc766179742f966c727d32f0ca35f
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 size_t strlen(const char *str
)
26 for(len
=0; str
[len
] != '\0'; len
++);
31 char *strcpy(char *dest
, const char *src
)
42 char *strncpy(char *dest
, const char *src
, size_t count
)
46 while((*src
) && (count
--))
55 char *strcat(char *dest
, const char *src
)
69 char *strncat(char *dst
, const char *src
, size_t n
)
91 char *strchr(const char *s
, int c
)
105 char *strrchr(const char *s
, int c
)
108 const char *sp
=(char *)0;
120 int strcmp(const char *string1
, const char *string2
)
122 while(*string1
== *string2
)
131 return *(unsigned const char *)string1
- *(unsigned const char *)(string2
);
134 int stricmp(const char *string1
, const char *string2
)
136 while(tolower(*string1
) == tolower(*string2
))
145 return (int)tolower(*string1
) - (int)tolower(*string2
);
148 int strnicmp(const char *string1
, const char *string2
, size_t length
)
154 if (toupper(*string1
) != toupper(*string2
++))
155 return toupper(*(unsigned const char *)string1
) - toupper(*(unsigned const char *)--string2
);
159 while (--length
!= 0);
163 int strncmp(const char *string1
, const char *string2
, size_t length
)
169 if (*string1
!= *string2
++)
170 return *(unsigned const char *)string1
- *(unsigned const char *)--string2
;
174 while (--length
!= 0);