eyBuildLib API Reference : eyBuildLib
ebstring - eybuild string library
strdup( ) - make a copy of source string
stricmp( ) - compare strings, ignoring case
strnicmp( ) - compare strings, limit length, ignoring case
strrev( ) - reverse a string
strndup( ) - make a copy of source string limit length
strissp( ) - check string just include white space or not
strnissp( ) - limit lenth check string just include white space or not
strrspn( ) - search character not in a given set retrorsely
strncspn( ) - search character in a given set limit the search length
strrcspn( ) - search character in a given set retrorsely
strrpbrk( ) - search character in a given set retrorsely
strrtok( ) - break down a string into tokens reverse
strnchr( ) - limit lenth find the first occurrence of a character in a string
strichr( ) - find the first occurrence of a character in a string
strnichr( ) - find the first occurrence of a character in a string
strnstr( ) - find the first occurrence of substr in a string
stristr( ) - find the first occurrence of substr in a string
strnistr( ) - find the first occurrence of substr in a string
strltrim( ) - jumpover white-space in the left side of a string
strrtrim( ) - remove white-space in the right side of a string
strtrim( ) - remove white-space in the both side of a string
strtoupper( ) - convert string into uppercase
strtolower( ) - convert string into lowercase
strrep( ) - replace the substring str with rep in source string
strirep( ) - replace the substring str with rep case-insensitive
strtr( ) - translating all occurrences in "from" to the corresponding in "to"
ltostr( ) - covert a long number into a string
ultostr( ) - covert an unsigned long number into a string
strsplit( ) - split src string into at most max sub string
eybuild util tools library
ebstring.h
strdup( ) - make a copy of source string
char * strdup ( const char * src )
this routine is to allocate a new space and make a copy of source string
pointer to new string, or NULL if allocate failure
stricmp( ) - compare strings, ignoring case
int stricmp ( const char * s1, const char * s2 )
this routine compare strings, ignoring case
same as strcmp
strnicmp( ) - compare strings, limit length, ignoring case
int strnicmp ( const char * s1, const char * s2, size_t n )
this routine compare strings, limit length, ignoring case
same as strncmp
strrev( ) - reverse a string
char * strrev ( char * s )
this routine is to reverse the string s, and store into source buffer
pointer to source string
strndup( ) - make a copy of source string limit length
char * strndup ( const char * src, size_t n )
this routine is to allocate a new space and make a copy of source string, but it will at most copy n byte from src. This routine will add \0 for new string automaticly.
pointer to new string, or NULL if allocate failure
strissp( ) - check string just include white space or not
int strissp ( const char * s )
this routine is to check string just include white space or not, here white space includes \t, \x20, \r and \n
not zero if just white space, otherwize 0
strnissp( ) - limit lenth check string just include white space or not
int strnissp ( const char * s, size_t n )
this routine is to check string just include white space or not in specified length, here white space includes \t, \x20, \r' and \n.
not zero if just white space, otherwize 0
strrspn( ) - search character not in a given set retrorsely
size_t strrspn ( const char * s, const char * set )
this routine computes the length of the maximum initial segment of string s that consists entirely of characters from the string set, retrorsely.
offset = strrspn("12345\t\t\x20", "\t\x20"); /* returned 5 */
offset from the start
ebstring, strspn( ), strcspn( ), strrcspn( ), strncspn( ), strrpbrk( )
strncspn( ) - search character in a given set limit the search length
size_t strncspn ( const char * s, const char * set, size_t len )
this routine computes the length of the maximum initial segment of string s1 that consists entirely of characters not included in string s2, limit the search length.
offset = strncspn("12345abc", "abc", 3); /* returned 3 */ offset = strncspn("12345abc", "345", 5); /* returned 2 */
the index of first find retrorsely, or length of len if not found
ebstring, strspn( ), strrspn( ), strcspn( ), strrcspn( ), strrpbrk( )
strrcspn( ) - search character in a given set retrorsely
size_t strrcspn ( const char * s, const char * set )
this routine computes the length of the maximum initial segment of string s1 that consists entirely of characters not included in string s2, retrorsely.
offset = strrcspn("\x20\t\t12345", "\t\x20"); /* returned 2 */ offset = strrcspn("12345", "\t\x20"); /* returned 0 */
the index of first find retrorsely, or length of s if not found
ebstring, strspn( ), strrspn( ), strcspn( ), strncspn( ), strrpbrk( )
strrpbrk( ) - search character in a given set retrorsely
char * strrpbrk ( const char * s, const char * set )
this routine computes the length of the maximum initial segment of string s1 that consists entirely of characters not included in string s2, retrorsely.
offset = strrcspn("\x20\t\t12345", "\t\x20"); /* returned 2 */
pointer to the first find retrorsely
ebstring, strspn( ), strrspn( ), strcspn( ), strrcspn( ), strncspn( )
strrtok( ) - break down a string into tokens reverse
char * strrtok ( char * string, /* string to break into tokens */ const char * separators /* the separators */ )
This routine break down a string into tokens reverse, unlike strtok you needn't set string points to NULL for next search. you should detect the return value equal to string pointer or not, to judge reach to head of string or not.
char buf[] = "Hello, this is strrtok()!"; char * p = NULL; while ( (p=strrtok(buf, "\x20\t,()!")) ) { printf("p: %s\n", p); if (p == buf) /* reach head of <buf> */ break; }
A pointer to the last character of a token, or a NULL pointer if there is no token.
ebstring, strtok( )
strnchr( ) - limit lenth find the first occurrence of a character in a string
char * strnchr ( const char * s, int ch, size_t len )
This routine finds the first occurrence of character c in string s, at most not longer than len.
pointer to first occurrence or NULL if not found
strichr( ) - find the first occurrence of a character in a string
char * strichr ( const char * s, int ch )
This routine finds the first occurrence of character c in string s, case-insensitive.
pointer to first occurrence or NULL if not found
strnichr( ) - find the first occurrence of a character in a string
char * strnichr ( const char * s, int ch, size_t len )
This routine finds the first occurrence of character c in string s, case-insensitive, at most not longer than len.
pointer to first occurrence or NULL if not found
strnstr( ) - find the first occurrence of substr in a string
char * strnstr ( const char * s, const char * substr, size_t len )
This routine finds the first occurrence of substring substr in string s
pointer to first occurrence or NULL if not found
stristr( ) - find the first occurrence of substr in a string
char * stristr ( const char * s, const char * substr )
This routine finds the first occurrence of substring substr in string s, case-insensitive.
pointer to first occurrence or NULL if not found
strnistr( ) - find the first occurrence of substr in a string
char * strnistr ( const char * s, const char * substr, size_t len )
This routine finds the first occurrence of substring substr in string s, case-insensitive, at most not longer than len.
pointer to first occurrence or NULL if not found
strltrim( ) - jumpover white-space in the left side of a string
char * strltrim ( const char * s )
this routine jumpover white-space in the left side of a string, here white space includes \t, \x20, \r and \n
pointer to first charactor not white space
strrtrim( ) - remove white-space in the right side of a string
char * strrtrim ( char * s )
this routine remove white-space in the left side of a string, here white space includes \t, \x20, \r and \n
pointer to source string
strtrim( ) - remove white-space in the both side of a string
char * strtrim ( char * s )
this routine remove white-space in the both side of a string, here white space includes \t, \x20, \r and \n
pointer to source string
strtoupper( ) - convert string into uppercase
char * strtoupper ( char * s )
this routine convert string into uppercase
pointer to source string
strtolower( ) - convert string into lowercase
char * strtolower ( char * s )
this routine convert string into lowercase
pointer to source string
strrep( ) - replace the substring str with rep in source string
char * strrep ( char * s, const char * str, const char * rep )
this routine replace the substring find with rep in source string s, user must keep source buffer longer enough.
pointer to source string
strirep( ) - replace the substring str with rep case-insensitive
char * strirep ( char * s, const char * str, const char * rep )
this routine replace the substring find with rep case-insensitive in source string s, user must keep source buffer longer enough.
pointer to source string
strtr( ) - translating all occurrences in "from" to the corresponding in "to"
char * strtr ( char * src, const char * from, const char * to )
this routine translating all occurrences of each character in "from" to the corresponding character in "to". If "from" and "to" are different lengths, the extra characters in the longer of the two are ignored.
pointer to source string
ltostr( ) - covert a long number into a string
char * ltostr ( long val, /* value to be converted */ char * str, /* output string */ unsigned base /* conversion base */ )
this routine is to covert a long number val into a string, and output into string str base on the parameter base. The base must be in the range 2-36.
printf("buf: %s\n", ltostr(-2007, buf, 10)); printf("buf: %s\n", ltostr(2008, buf, 2));
the converted string str. If no conversion could be performed, the returned string is zero-length.
ultostr( )
ultostr( ) - covert an unsigned long number into a string
char * ultostr ( unsigned long val, /* value to be converted */ char * str, /* output string */ unsigned base /* conversion base */ )
this routine is to covert an unsigned long number val into a string, and output into string str base on the parameter base. The base must be in the range 2-36.
the converted string str. If no conversion could be performed, the returned string is zero-length.
ltostr( )
strsplit( ) - split src string into at most max sub string
int strsplit ( char * src, /* source string */ const char * seps, /* spliter charaters */ const char * slist[], /* where to store result */ size_t max /* max to split into */ )
This routine split source string into at most max sub string (note, it means the src string must be writable). Paramters slist is to store the split result, max is to limit max number to split.
char src[] = "abc, def, ghi / 123, 456"; char * slist[32]; int i, ret; ret = strsplit(src, "\x20/,", slist, 32); for (i=0; i<ret; i++) printf("%d. {%s}\n", i, slist[i]);
the number of sub string splited