Wed Aug 15 01:24:44 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 3122 of file ast_expr2f.c.

03123 {
03124    struct parse_io io;
03125    int return_value = 0;
03126    
03127    memset(&io, 0, sizeof(io));
03128    io.string = expr;  /* to pass to the error routine */
03129    
03130    ast_yylex_init(&io.scanner);
03131    
03132    ast_yy_scan_string(expr, io.scanner);
03133    
03134    ast_yyparse ((void *) &io);
03135 
03136    ast_yylex_destroy(io.scanner);
03137 
03138    if (!io.val) {
03139       if (length > 1) {
03140          strcpy(buf, "0");
03141          return_value = 1;
03142       }
03143    } else {
03144       if (io.val->type == AST_EXPR_integer) {
03145          int res_length;
03146 
03147          res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
03148          return_value = (res_length <= length) ? res_length : length;
03149       } else {
03150 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
03151          strncpy(buf, io.val->u.s, length - 1);
03152 #else /* !STANDALONE && !LOW_MEMORY */
03153          ast_copy_string(buf, io.val->u.s, length);
03154 #endif /* STANDALONE || LOW_MEMORY */
03155          return_value = strlen(buf);
03156          free(io.val->u.s);
03157       }
03158       free(io.val);
03159    }
03160    return return_value;
03161 }


Generated on Wed Aug 15 01:24:44 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.3