字符串的分割提取

char *
strtok_index(
  const char *text, int text_size,
  const char *delm, int delm_size,
  int index)
{
  int i,j,s;
  int n_match = -1;
  for(i=0, s=0; i<=text_size; i++){
    for(j=0; j<delm_size; j++){
      if( i==text_size || text[i]==delm[j] ) break;
    }

    if(j==delm_size) continue;    // not match

    if( s==0 || i>s || s==text_size ){
      n_match++;

      if( n_match==index ){
        char *result = (char *)malloc(i-s+1);
        return strncat(result, text+s, i-s);
      }
    }
    s = i+1;
  }
  return NULL;
}