Thu Apr 28 2011 17:15:35

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, 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.

Referenced by check_pval_item(), and pbx_substitute_variables_helper_full().

{
   struct parse_io io;
   int return_value = 0;
   
   memset(&io, 0, sizeof(io));
   io.string = expr;  /* to pass to the error routine */
   io.chan = chan;
   
   ast_yylex_init(&io.scanner);
   
   ast_yy_scan_string(expr, io.scanner);
   
   ast_yyparse ((void *) &io);

   ast_yylex_destroy(io.scanner);

   if (!io.val) {
      if (length > 1) {
         strcpy(buf, "0");
         return_value = 1;
      }
   } else {
      if (io.val->type == AST_EXPR_number) {
         int res_length;

         res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
         return_value = (res_length <= length) ? res_length : length;
      } else {
         if (io.val->u.s)
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
            strncpy(buf, io.val->u.s, length - 1);
#else /* !STANDALONE && !LOW_MEMORY */
            ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE || LOW_MEMORY */
         else
            buf[0] = 0;
         return_value = strlen(buf);
         free(io.val->u.s);
      }
      free(io.val);
   }
   return return_value;
}