Fri Jun 19 12:10:06 2009

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

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


Generated on Fri Jun 19 12:10:06 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7