mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
update on array patch
This commit is contained in:
@@ -1025,52 +1025,6 @@ static esl_ssize_t handle_recv(esl_handle_t *handle, void *data, esl_size_t data
|
||||
return recv(handle->sock, data, datalen, 0);
|
||||
}
|
||||
|
||||
static int add_array(esl_event_t *event, const char *var, const char *val)
|
||||
{
|
||||
char *data;
|
||||
char **array;
|
||||
int idx;
|
||||
int max = 0;
|
||||
int len;
|
||||
const char *p;
|
||||
int i;
|
||||
|
||||
if (strlen(val) < 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = val + 7;
|
||||
|
||||
while((p = strstr(p, "::"))) {
|
||||
max++;
|
||||
p += 2;
|
||||
}
|
||||
|
||||
if (!max) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
data = strdup(val + 7);
|
||||
|
||||
len = (sizeof(char *) * max) + 1;
|
||||
|
||||
array = malloc(len);
|
||||
memset(array, 0, len);
|
||||
|
||||
idx = esl_separate_string_string(data, "::", array, max);
|
||||
|
||||
for(i = 0; i < max; i++) {
|
||||
esl_event_add_header_string(event, ESL_STACK_PUSH, var, array[i]);
|
||||
}
|
||||
|
||||
free(array);
|
||||
free(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_event_t **save_event)
|
||||
{
|
||||
char *c;
|
||||
@@ -1135,7 +1089,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
||||
esl_url_decode(hval);
|
||||
esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
|
||||
if (!strncmp(hval, "ARRAY::", 7)) {
|
||||
add_array(revent, hname, hval);
|
||||
esl_event_add_array(revent, hname, hval);
|
||||
} else {
|
||||
esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
|
||||
}
|
||||
@@ -1269,7 +1223,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
||||
}
|
||||
|
||||
if (!strncmp(hval, "ARRAY::", 7)) {
|
||||
add_array(handle->last_ievent, hname, hval);
|
||||
esl_event_add_array(handle->last_ievent, hname, hval);
|
||||
} else {
|
||||
esl_event_add_header_string(handle->last_ievent, ESL_STACK_BOTTOM, hname, hval);
|
||||
}
|
||||
|
Reference in New Issue
Block a user