Sat Apr 12 07:12:33 2008

Asterisk developer's documentation


ast_expr.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int ast_expr (char *expr, char *buf, int length)


Function Documentation

int ast_expr ( char *  expr,
char *  buf,
int  length 
)

Definition at line 3107 of file ast_expr2f.c.

03108 {
03109    struct parse_io io;
03110    int return_value = 0;
03111    
03112    memset(&io, 0, sizeof(io));
03113    io.string = expr;  /* to pass to the error routine */
03114    
03115    ast_yylex_init(&io.scanner);
03116    
03117    ast_yy_scan_string(expr, io.scanner);
03118    
03119    ast_yyparse ((void *) &io);
03120 
03121    ast_yylex_destroy(io.scanner);
03122 
03123    if (!io.val) {
03124       if (length > 1) {
03125          strcpy(buf, "0");
03126          return_value = 1;
03127       }
03128    } else {
03129       if (io.val->type == AST_EXPR_integer) {
03130          int res_length;
03131 
03132          res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
03133          return_value = (res_length <= length) ? res_length : length;
03134       } else {
03135 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
03136          strncpy(buf, io.val->u.s, length - 1);
03137 #else /* !STANDALONE && !LOW_MEMORY */
03138          ast_copy_string(buf, io.val->u.s, length);
03139 #endif /* STANDALONE || LOW_MEMORY */
03140          return_value = strlen(buf);
03141          free(io.val->u.s);
03142       }
03143       free(io.val);
03144    }
03145    return return_value;
03146 }


Generated on Sat Apr 12 07:12:33 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.5