diff options
-rwxr-xr-x | chanvars.c | 39 | ||||
-rwxr-xr-x | doc/linkedlists.README | 95 | ||||
-rwxr-xr-x | include/asterisk/ast_expr.h | 1 | ||||
-rwxr-xr-x | include/asterisk/frame.h | 2 | ||||
-rwxr-xr-x | pbx/pbx_config.c | 16 |
5 files changed, 148 insertions, 5 deletions
diff --git a/chanvars.c b/chanvars.c new file mode 100755 index 000000000..70324b161 --- /dev/null +++ b/chanvars.c @@ -0,0 +1,39 @@ +#include <asterisk/chanvars.h> +#include <malloc.h> +#include <string.h> + +struct ast_var_t *ast_var_assign(char *name,char *value) { + int i; + struct ast_var_t *var; + + var=malloc(sizeof(struct ast_var_t)); + + i=strlen(value); + var->value=malloc(i+1); + strncpy(var->value,value,i); + var->value[i]='\0'; + + i=strlen(name); + var->name=malloc(i+1); + strncpy(var->name,name,i); + var->name[i]='\0'; + return(var); +} + +void ast_var_delete(struct ast_var_t *var) { + if (var!=NULL) { + if (var->name!=NULL) free(var->name); + if (var->value!=NULL) free(var->value); + free(var); + } +} + +char *ast_var_name(struct ast_var_t *var) { + return(var->name); +} + +char *ast_var_value(struct ast_var_t *var) { + return(var->value); +} + +
\ No newline at end of file diff --git a/doc/linkedlists.README b/doc/linkedlists.README new file mode 100755 index 000000000..87e396fbc --- /dev/null +++ b/doc/linkedlists.README @@ -0,0 +1,95 @@ + +2nd version, implemented as macros. + + include <asterisk/linkedlists.h> + +AST_LIST_ENTRY declares pointers inside the object structure : + + struct ast_var_t { + char *name; + char *value; + AST_LIST_ENTRY(ast_var_t) listpointers; + }; + +AST_LIST_HEAD declares a head structure, which is initialized +to AST_LIST_HEAD_NULL : + + AST_LIST_HEAD(head, ast_var_t) head + +Next, we declare a pointer to this structure : + + struct headtype *headp = head; + +AST_LIST_INIT initializes the head pointer to a null value + + AST_LIST_INIT(headp); + +AST_LIST_INSERT_HEAD inserts an element to the head of the list : + + struct ast_var_t *node; + + node=malloc(sizeof(struct ast_var_t)); + (...we fill data in struct....) + data->name=malloc(100); + strcpy(data->name,"lalalalaa"); + etc etc + + (then we insert the node in the head of the list :) + + AST_LIST_INSERT_HEAD(headp,node,listpointers); + +AST_LIST_INSERT_HEAD_AFTER inserts an element after another : + + struct ast_var_t *node1; + ... + AST_LIST_INSERT_AFTER(node,node1,listpointers); + +AST_LIST_REMOVE removes an arbitrary element from the head: + + AST_LIST_REMOVE(headp,node1,ast_var_t,listpointers); + +AST_LIST_REMOVE_HEAD removes the entry at the head of the list: + + AST_LIST_REMOVE(headp,listpointers); + +AST_LIST_FIRST returns a pointer to the first element of the list; + + struct ast_var_t *firstnode; + firstnode=AST_LIST_FIRST(headp); + +AST_LIST_NEXT returns a pointer to the next element : + + struct ast_var_t *nextnode; + nextnode=AST_LIST_NEXT(firstnode,listpointers); + +AST_LIST_TRAVERSE traverses all elements of the list : + + struct ast_var_t *node; + + AST_LIST_TRAVERSE(headp,node,listpointers) { + printf("%s\n",node->name); + } + +AST_LIST_EMPTY evaluates to a true condition if there are no elements on +the list. + +To completely delete a list : + + struct ast_var_t *vardata; + + while (!AST_LIST_EMPTY(headp)) { /* List Deletion. */ + vardata = AST_LIST_FIRST(head); + AST_LIST_REMOVE_HEAD(head, listpointers); + free(vardata->name); + free(vardata->value); + } + +AST_LIST_LOCK returns true if it can lock the list, AST_LIST_UNLOCK unlocks +the list : + +if (AST_LIST_LOCK(headp)) { + ...do all list operations here... + AST_LIST_UNLOCK(headp); +} else { + ast_log(LOG_WARNING,"List locked bla bla bla\n"); +} diff --git a/include/asterisk/ast_expr.h b/include/asterisk/ast_expr.h new file mode 100755 index 000000000..3739acb7e --- /dev/null +++ b/include/asterisk/ast_expr.h @@ -0,0 +1 @@ +extern char *ast_expr (char *arg); diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index de7ebb5b3..f5e1479b6 100755 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -129,6 +129,8 @@ struct ast_frame_chain { #define AST_FORMAT_LPC10 (1 << 7) /*! G.729A audio */ #define AST_FORMAT_G729A (1 << 8) +/*! SpeeX Free Compression */ +#define AST_FORMAT_SPEEX (1 << 9) /*! Maximum audio format */ #define AST_FORMAT_MAX_AUDIO (1 << 15) /*! JPEG Images */ diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 38c6e1f39..fbcb04a2e 100755 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1463,6 +1463,7 @@ static int pbx_load_module(void) { struct ast_config *cfg; struct ast_variable *v; + char *ptrptr; char *cxt, *ext, *pri, *appl, *data, *tc, *cidmatch; struct ast_context *con; @@ -1485,17 +1486,22 @@ static int pbx_load_module(void) while(v) { if (!strcasecmp(v->name, "exten")) { tc = strdup(v->value); - ext = strtok(tc, ","); + ext = strtok_r(tc, ",",&ptrptr); if (!ext) ext=""; - pri = strtok(NULL, ","); + pri = strtok_r(NULL, ",",&ptrptr); if (!pri) pri=""; - appl = strtok(NULL, ","); + appl = strtok_r(NULL, ",",&ptrptr); if (!appl) appl=""; - data = strtok(NULL, ","); - + if (*ptrptr=='"') { + ptrptr++; + data = strtok_r(NULL, "\"",&ptrptr); + ptrptr++; + } else { + data = strtok_r(NULL, ",",&ptrptr); + } cidmatch = strchr(ext, '/'); if (cidmatch) { *cidmatch = '\0'; |