switch_separate_string
switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen);
完成split的功能
switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen);
完成split的功能
使用示例:
char *params = "param_1=p1,param_2=p2,param_3=p3";
//要获取到每一个param,就要将params用逗号分割
char *param_tmp = strdup(params);
char *param_array[10] = { 0 };
int p_index = 0;
int param_size = switch_separate_string(param_tmp ,',',param_array,(sizeof(param_array) / sizeof(param_array[0])));
for(p_index = 0; p_index < param_size; p_index ++)
{
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_NOTICE,"---[%s]---\n",param_array[p_index]);
}