Go to the source code of this file.
Functions | |
int | ast_expr (char *expr, char *buf, int length, struct ast_channel *chan) |
Evaluate the given expression. | |
int | ast_str_expr (struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr) |
Evaluate the given expression. |
???????
Definition in file ast_expr.h.
int ast_expr | ( | char * | expr, | |
char * | buf, | |||
int | length, | |||
struct ast_channel * | chan | |||
) |
Evaluate the given expression.
expr | An expression | |
buf | Result buffer | |
length | Size of the result buffer, in bytes | |
chan | Channel to use for evaluating included dialplan functions, if any |
Definition at line 2396 of file ast_expr2f.c.
Referenced by check_pval_item(), and pbx_substitute_variables_helper_full().
02397 { 02398 struct parse_io io = { .string = expr, .chan = chan }; 02399 int return_value = 0; 02400 02401 ast_yylex_init(&io.scanner); 02402 02403 ast_yy_scan_string(expr, io.scanner); 02404 02405 ast_yyparse ((void *) &io); 02406 02407 ast_yylex_destroy(io.scanner); 02408 02409 if (!io.val) { 02410 if (length > 1) { 02411 strcpy(buf, "0"); 02412 return_value = 1; 02413 } 02414 } else { 02415 if (io.val->type == AST_EXPR_number) { 02416 int res_length; 02417 02418 res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i); 02419 return_value = (res_length <= length) ? res_length : length; 02420 } else { 02421 if (io.val->u.s) 02422 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE) 02423 strncpy(buf, io.val->u.s, length - 1); 02424 #else /* !STANDALONE && !LOW_MEMORY */ 02425 ast_copy_string(buf, io.val->u.s, length); 02426 #endif /* STANDALONE || LOW_MEMORY */ 02427 else 02428 buf[0] = 0; 02429 return_value = strlen(buf); 02430 free(io.val->u.s); 02431 } 02432 free(io.val); 02433 } 02434 return return_value; 02435 }
int ast_str_expr | ( | struct ast_str ** | str, | |
ssize_t | maxlen, | |||
struct ast_channel * | chan, | |||
char * | expr | |||
) |
Evaluate the given expression.
str | Dynamic result buffer | |
maxlen | <0 if the size of the buffer should remain constant, >0 if the size of the buffer should expand to that many bytes, maximum, or 0 for unlimited expansion of the result buffer | |
chan | Channel to use for evaluating included dialplan functions, if any | |
expr | An expression |
Definition at line 2438 of file ast_expr2f.c.
References AST_EXPR_number, ast_str_set(), ast_str_strlen(), ast_yy_scan_string(), ast_yylex_destroy(), ast_yylex_init(), ast_yyparse(), FP___PRINTF, free, parse_io::scanner, and parse_io::string.
Referenced by ast_str_substitute_variables_full().
02439 { 02440 struct parse_io io = { .string = expr, .chan = chan }; 02441 02442 ast_yylex_init(&io.scanner); 02443 ast_yy_scan_string(expr, io.scanner); 02444 ast_yyparse ((void *) &io); 02445 ast_yylex_destroy(io.scanner); 02446 02447 if (!io.val) { 02448 ast_str_set(str, maxlen, "0"); 02449 } else { 02450 if (io.val->type == AST_EXPR_number) { 02451 int res_length; 02452 ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i); 02453 } else if (io.val->u.s) { 02454 ast_str_set(str, maxlen, "%s", io.val->u.s); 02455 free(io.val->u.s); 02456 } 02457 free(io.val); 02458 } 02459 return ast_str_strlen(*str); 02460 }