eyBuildLib API Reference : eyBuildLib

ebstring

NAME

ebstring - eybuild string library

ROUTINES

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

DESCRIPTION

eybuild util tools library

INCLUDE

ebstring.h


eyBuildLib : Routines

strdup( )

NAME

strdup( ) - make a copy of source string

SYNOPSIS

char * strdup
    (
    const char * src
    )

DESCRIPTION

this routine is to allocate a new space and make a copy of source string

RETURNS

pointer to new string, or NULL if allocate failure

SEE ALSO

ebstring


eyBuildLib : Routines

stricmp( )

NAME

stricmp( ) - compare strings, ignoring case

SYNOPSIS

int stricmp
    (
    const char * s1,
    const char * s2
    )

DESCRIPTION

this routine compare strings, ignoring case

RETURNS

same as strcmp

SEE ALSO

ebstring


eyBuildLib : Routines

strnicmp( )

NAME

strnicmp( ) - compare strings, limit length, ignoring case

SYNOPSIS

int strnicmp
    (
    const char * s1,
    const char * s2,
    size_t       n
    )

DESCRIPTION

this routine compare strings, limit length, ignoring case

RETURNS

same as strncmp

SEE ALSO

ebstring


eyBuildLib : Routines

strrev( )

NAME

strrev( ) - reverse a string

SYNOPSIS

char * strrev
    (
    char * s
    )

DESCRIPTION

this routine is to reverse the string s, and store into source buffer

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strndup( )

NAME

strndup( ) - make a copy of source string limit length

SYNOPSIS

char * strndup
    (
    const char * src,
    size_t       n
    )

DESCRIPTION

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.

RETURNS

pointer to new string, or NULL if allocate failure

SEE ALSO

ebstring


eyBuildLib : Routines

strissp( )

NAME

strissp( ) - check string just include white space or not

SYNOPSIS

int strissp
    (
    const char * s
    )

DESCRIPTION

this routine is to check string just include white space or not, here white space includes \t, \x20, \r and \n

RETURNS

not zero if just white space, otherwize 0

SEE ALSO

ebstring


eyBuildLib : Routines

strnissp( )

NAME

strnissp( ) - limit lenth check string just include white space or not

SYNOPSIS

int strnissp
    (
    const char * s,
    size_t       n
    )

DESCRIPTION

this routine is to check string just include white space or not in specified length, here white space includes \t, \x20, \r' and \n.

RETURNS

not zero if just white space, otherwize 0

SEE ALSO

ebstring


eyBuildLib : Routines

strrspn( )

NAME

strrspn( ) - search character not in a given set retrorsely

SYNOPSIS

size_t strrspn
    (
    const char * s,
    const char * set
    )

DESCRIPTION

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 */

RETURNS

offset from the start

SEE ALSO

ebstring, strspn( ), strcspn( ), strrcspn( ), strncspn( ), strrpbrk( )


eyBuildLib : Routines

strncspn( )

NAME

strncspn( ) - search character in a given set limit the search length

SYNOPSIS

size_t strncspn
    (
    const char * s,
    const char * set,
    size_t       len
    )

DESCRIPTION

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 */

RETURNS

the index of first find retrorsely, or length of len if not found

SEE ALSO

ebstring, strspn( ), strrspn( ), strcspn( ), strrcspn( ), strrpbrk( )


eyBuildLib : Routines

strrcspn( )

NAME

strrcspn( ) - search character in a given set retrorsely

SYNOPSIS

size_t strrcspn
    (
    const char * s,
    const char * set
    )

DESCRIPTION

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 */

RETURNS

the index of first find retrorsely, or length of s if not found

SEE ALSO

ebstring, strspn( ), strrspn( ), strcspn( ), strncspn( ), strrpbrk( )


eyBuildLib : Routines

strrpbrk( )

NAME

strrpbrk( ) - search character in a given set retrorsely

SYNOPSIS

char * strrpbrk
    (
    const char * s,
    const char * set
    )

DESCRIPTION

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 */

RETURNS

pointer to the first find retrorsely

SEE ALSO

ebstring, strspn( ), strrspn( ), strcspn( ), strrcspn( ), strncspn( )


eyBuildLib : Routines

strrtok( )

NAME

strrtok( ) - break down a string into tokens reverse

SYNOPSIS

char * strrtok
    (
    char *       string,      /* string to break into tokens */
    const char * separators   /* the separators */
    )

DESCRIPTION

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;
}

RETURNS

A pointer to the last character of a token, or a NULL pointer if there is no token.

SEE ALSO

ebstring, strtok( )


eyBuildLib : Routines

strnchr( )

NAME

strnchr( ) - limit lenth find the first occurrence of a character in a string

SYNOPSIS

char * strnchr
    (
    const char * s,
    int          ch,
    size_t       len
    )

DESCRIPTION

This routine finds the first occurrence of character c in string s, at most not longer than len.

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

strichr( )

NAME

strichr( ) - find the first occurrence of a character in a string

SYNOPSIS

char * strichr
    (
    const char * s,
    int          ch
    )

DESCRIPTION

This routine finds the first occurrence of character c in string s, case-insensitive.

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

strnichr( )

NAME

strnichr( ) - find the first occurrence of a character in a string

SYNOPSIS

char * strnichr
    (
    const char * s,
    int          ch,
    size_t       len
    )

DESCRIPTION

This routine finds the first occurrence of character c in string s, case-insensitive, at most not longer than len.

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

strnstr( )

NAME

strnstr( ) - find the first occurrence of substr in a string

SYNOPSIS

char * strnstr
    (
    const char * s,
    const char * substr,
    size_t       len
    )

DESCRIPTION

This routine finds the first occurrence of substring substr in string s

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

stristr( )

NAME

stristr( ) - find the first occurrence of substr in a string

SYNOPSIS

char * stristr
    (
    const char * s,
    const char * substr
    )

DESCRIPTION

This routine finds the first occurrence of substring substr in string s, case-insensitive.

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

strnistr( )

NAME

strnistr( ) - find the first occurrence of substr in a string

SYNOPSIS

char * strnistr
    (
    const char * s,
    const char * substr,
    size_t       len
    )

DESCRIPTION

This routine finds the first occurrence of substring substr in string s, case-insensitive, at most not longer than len.

RETURNS

pointer to first occurrence or NULL if not found

SEE ALSO

ebstring


eyBuildLib : Routines

strltrim( )

NAME

strltrim( ) - jumpover white-space in the left side of a string

SYNOPSIS

char * strltrim
    (
    const char * s
    )

DESCRIPTION

this routine jumpover white-space in the left side of a string, here white space includes \t, \x20, \r and \n

RETURNS

pointer to first charactor not white space

SEE ALSO

ebstring


eyBuildLib : Routines

strrtrim( )

NAME

strrtrim( ) - remove white-space in the right side of a string

SYNOPSIS

char * strrtrim
    (
    char * s
    )

DESCRIPTION

this routine remove white-space in the left side of a string, here white space includes \t, \x20, \r and \n

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strtrim( )

NAME

strtrim( ) - remove white-space in the both side of a string

SYNOPSIS

char * strtrim
    (
    char * s
    )

DESCRIPTION

this routine remove white-space in the both side of a string, here white space includes \t, \x20, \r and \n

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strtoupper( )

NAME

strtoupper( ) - convert string into uppercase

SYNOPSIS

char * strtoupper
    (
    char * s
    )

DESCRIPTION

this routine convert string into uppercase

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strtolower( )

NAME

strtolower( ) - convert string into lowercase

SYNOPSIS

char * strtolower
    (
    char * s
    )

DESCRIPTION

this routine convert string into lowercase

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strrep( )

NAME

strrep( ) - replace the substring str with rep in source string

SYNOPSIS

char * strrep
    (
    char *       s,
    const char * str,
    const char * rep
    )

DESCRIPTION

this routine replace the substring find with rep in source string s, user must keep source buffer longer enough.

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strirep( )

NAME

strirep( ) - replace the substring str with rep case-insensitive

SYNOPSIS

char * strirep
    (
    char *       s,
    const char * str,
    const char * rep
    )

DESCRIPTION

this routine replace the substring find with rep case-insensitive in source string s, user must keep source buffer longer enough.

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

strtr( )

NAME

strtr( ) - translating all occurrences in "from" to the corresponding in "to"

SYNOPSIS

char * strtr
    (
    char *       src,
    const char * from,
    const char * to
    )

DESCRIPTION

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.

RETURNS

pointer to source string

SEE ALSO

ebstring


eyBuildLib : Routines

ltostr( )

NAME

ltostr( ) - covert a long number into a string

SYNOPSIS

char * ltostr
    (
    long     val,             /* value to be converted */
    char *   str,             /* output string */
    unsigned base             /* conversion base */
    )

DESCRIPTION

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));

RETURNS

the converted string str. If no conversion could be performed, the returned string is zero-length.

ALSO SEE

ultostr( )

SEE ALSO

ebstring


eyBuildLib : Routines

ultostr( )

NAME

ultostr( ) - covert an unsigned long number into a string

SYNOPSIS

char * ultostr
    (
    unsigned long val,        /* value to be converted */
    char *        str,        /* output string */
    unsigned      base        /* conversion base */
    )

DESCRIPTION

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.

RETURNS

the converted string str. If no conversion could be performed, the returned string is zero-length.

ALSO SEE

ltostr( )

SEE ALSO

ebstring


eyBuildLib : Routines

strsplit( )

NAME

strsplit( ) - split src string into at most max sub string

SYNOPSIS

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 */
    )

DESCRIPTION

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]);

RETURNS

the number of sub string splited

SEE ALSO

ebstring