Mon May 14 04:44:31 2007

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 3097 of file ast_expr2f.c.

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


Generated on Mon May 14 04:44:31 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1