40 lines
563 B
C
40 lines
563 B
C
/*
|
|
* str_ops.c
|
|
*
|
|
* Created on: Aug 27, 2011
|
|
* Author: Tiberiu
|
|
*/
|
|
#include <types.h>
|
|
|
|
uint32 strlen (string s)
|
|
{
|
|
string end = s;
|
|
while (*end != '\0')
|
|
end++;
|
|
|
|
return (uint32)(end - s);
|
|
}
|
|
|
|
int32 strcmp (string a, string b)
|
|
{
|
|
unsigned char c1, c2;
|
|
|
|
while (*a != '\0' && *b != '\0' && *a == *b) {
|
|
a++; b++;
|
|
}
|
|
|
|
c1 = (*(unsigned char*) a);
|
|
c2 = (*(unsigned char*) b);
|
|
return ((c1 < c2) ? -1 : (c1 > c2));
|
|
}
|
|
|
|
string strcpy (string s1, const string s2)
|
|
{
|
|
char *dst = s1;
|
|
const char *src = s2;
|
|
|
|
while ((*dst++ = *src++) != '\0') ;
|
|
|
|
return s1;
|
|
}
|