int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
{
- struct parse_io io;
+ struct parse_io io = { .string = expr, .chan = chan };
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);
return return_value;
}
+#ifndef STANDALONE
+int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
+{
+ struct parse_io io = { .string = expr, .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) {
+ ast_str_set(str, maxlen, "0");
+ } else {
+ if (io.val->type == AST_EXPR_number) {
+ int res_length;
+ ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
+ } else if (io.val->u.s) {
+ ast_str_set(str, maxlen, "%s", io.val->u.s);
+ free(io.val->u.s);
+ }
+ free(io.val);
+ }
+ return ast_str_strlen(*str);
+}
+#endif
+
char extra_error_message[4095];
int extra_error_message_supplied = 0;
/* calc a length, malloc, fill, and return; yyerror had better free it! */
int len=0,i;
const char *p;
- char *res, *s,*t;
+ char *res, *s;
+ const char *t;
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
for (p=mess; *p; p++) {
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_SUBMINOR_VERSION 34
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
-#endif /* ! C99 */
-
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ * Given that the standard has decreed that size_t exists since 1989,
+ * I guess we can afford to depend on it. Manoj.
+ */
+
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
static int curlycount = 0;
static char *expr2_token_subst(const char *mess);
-#line 598 "ast_expr2f.c"
+#line 604 "ast_expr2f.c"
#define INITIAL 0
#define var 1
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
#line 125 "ast_expr2.fl"
-#line 844 "ast_expr2f.c"
+#line 850 "ast_expr2f.c"
yylval = yylval_param;
#line 233 "ast_expr2.fl"
ECHO;
YY_BREAK
-#line 1190 "ast_expr2f.c"
+#line 1196 "ast_expr2f.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(var):
yyterminate();
/** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
* scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
}
/** Set the current column.
- * @param column_no
+ * @param line_number
* @param yyscanner The scanner object.
*/
void ast_yyset_column (int column_no , yyscan_t yyscanner)
void ast_yyfree(void *ptr, yyscan_t yyscanner)
{
- /* the normal generated ast_yyfree func just frees its first arg;
- this get complaints on some systems, as sometimes this
- arg is a nil ptr! It's usually not fatal, but is irritating! */
- free( (char *) ptr );
+ /* the normal generated ast_yyfree func just frees its first arg;
+ this get complaints on some systems, as sometimes this
+ arg is a nil ptr! It's usually not fatal, but is irritating! */
+ free( (char *) ptr );
}
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
int return_value = 0;
ast_yylex_init(&io.scanner);
+
ast_yy_scan_string(expr, io.scanner);
+
ast_yyparse ((void *) &io);
+
ast_yylex_destroy(io.scanner);
if (!io.val) {
return return_value;
}
-#if !defined(STANDALONE)
+#ifndef STANDALONE
int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
{
struct parse_io io = { .string = expr, .chan = chan };
extra_error_message[0] = 0;
}
-static char *expr2_token_equivs1[] =
+static const char * const expr2_token_equivs1[] =
{
"TOKEN",
"TOK_COND",
"TOK_LP"
};
-static char *expr2_token_equivs2[] =
+static const char * const expr2_token_equivs2[] =
{
"<token>",
"?",
/* calc a length, malloc, fill, and return; yyerror had better free it! */
int len=0,i;
const char *p;
- char *res, *s,*t;
+ char *res, *s;
+ const char *t;
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
for (p=mess; *p; p++) {