Wed Aug 18 22:34:04 2010

Asterisk developer's documentation


ast_expr.h File Reference

Go to the source code of this file.

Functions

int ast_expr (char *expr, char *buf, int length, struct ast_channel *chan)


Detailed Description

???????
Todo:
Explain this file!

Definition in file ast_expr.h.


Function Documentation

int ast_expr ( char *  expr,
char *  buf,
int  length,
struct ast_channel chan 
)

Definition at line 2399 of file ast_expr2f.c.

02400 {
02401    struct parse_io io;
02402    int return_value = 0;
02403    
02404    memset(&io, 0, sizeof(io));
02405    io.string = expr;  /* to pass to the error routine */
02406    io.chan = chan;
02407    
02408    ast_yylex_init(&io.scanner);
02409    
02410    ast_yy_scan_string(expr, io.scanner);
02411    
02412    ast_yyparse ((void *) &io);
02413 
02414    ast_yylex_destroy(io.scanner);
02415 
02416    if (!io.val) {
02417       if (length > 1) {
02418          strcpy(buf, "0");
02419          return_value = 1;
02420       }
02421    } else {
02422       if (io.val->type == AST_EXPR_number) {
02423          int res_length;
02424 
02425          res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
02426          return_value = (res_length <= length) ? res_length : length;
02427       } else {
02428          if (io.val->u.s)
02429 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
02430             strncpy(buf, io.val->u.s, length - 1);
02431 #else /* !STANDALONE && !LOW_MEMORY */
02432             ast_copy_string(buf, io.val->u.s, length);
02433 #endif /* STANDALONE || LOW_MEMORY */
02434          else
02435             buf[0] = 0;
02436          return_value = strlen(buf);
02437          free(io.val->u.s);
02438       }
02439       free(io.val);
02440    }
02441    return return_value;
02442 }


Generated on Wed Aug 18 22:34:04 2010 for Asterisk - the Open Source PBX by  doxygen 1.4.7