memory.c 700 Bytes
#include <scot/memory.h>
#include <scot/scot_types.h>

SIZE_T
str_length (const char * str)
{
	const char * s = str;
	while (*(s++));
	return s-str-1;
}

char *
str_copy (char * dest, const char * src)
{
	char * d = dest;
   while (*(d++) = *(src++));
	return dest;
}

char * 
strn_copy (char * dest, const char * src, SIZE_T size)
{
	char * d = dest;
   while ((d-dest) < size && (*(d++) = *(src++)));
	return dest;
}

char * 
str_char (const char * str, int ch)
{
	while ((*str != ch) && *(str++));
	return (*str)?(char *)str:NULL;
}

char *
strr_char (const char * str, int ch)
{
   const char * s = str;
	while (*(s++));
	while ((*(--s) != ch) &&  (s != str));
	return (s!=str)?(char *)s:NULL;
}