mirror of http://gerrit.asterisk.org/asterisk
provide parser files in source tree, so flex/bison are not need to build update Makefile to use simpler techniques to build parser update README to remove references to old vs. new parsers remove version comparison tool used for flex/bison programs git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6420 65c4cc65-6c06-0410-ace0-fbb531ad65f31.2-netsec
parent
7fa558c71e
commit
66e69e0143
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,109 @@
|
||||
/* A Bison parser, made by GNU Bison 1.875d. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
TOK_COLONCOLON = 258,
|
||||
TOK_COND = 259,
|
||||
TOK_OR = 260,
|
||||
TOK_AND = 261,
|
||||
TOK_NE = 262,
|
||||
TOK_LE = 263,
|
||||
TOK_GE = 264,
|
||||
TOK_LT = 265,
|
||||
TOK_GT = 266,
|
||||
TOK_EQ = 267,
|
||||
TOK_MINUS = 268,
|
||||
TOK_PLUS = 269,
|
||||
TOK_MOD = 270,
|
||||
TOK_DIV = 271,
|
||||
TOK_MULT = 272,
|
||||
TOK_COMPL = 273,
|
||||
TOK_EQTILDE = 274,
|
||||
TOK_COLON = 275,
|
||||
TOK_LP = 276,
|
||||
TOK_RP = 277,
|
||||
TOKEN = 278
|
||||
};
|
||||
#endif
|
||||
#define TOK_COLONCOLON 258
|
||||
#define TOK_COND 259
|
||||
#define TOK_OR 260
|
||||
#define TOK_AND 261
|
||||
#define TOK_NE 262
|
||||
#define TOK_LE 263
|
||||
#define TOK_GE 264
|
||||
#define TOK_LT 265
|
||||
#define TOK_GT 266
|
||||
#define TOK_EQ 267
|
||||
#define TOK_MINUS 268
|
||||
#define TOK_PLUS 269
|
||||
#define TOK_MOD 270
|
||||
#define TOK_DIV 271
|
||||
#define TOK_MULT 272
|
||||
#define TOK_COMPL 273
|
||||
#define TOK_EQTILDE 274
|
||||
#define TOK_COLON 275
|
||||
#define TOK_LP 276
|
||||
#define TOK_RP 277
|
||||
#define TOKEN 278
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
#line 137 "ast_expr2.y"
|
||||
typedef union YYSTYPE {
|
||||
struct val *val;
|
||||
} YYSTYPE;
|
||||
/* Line 1285 of yacc.c. */
|
||||
#line 87 "ast_expr2.h"
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
|
||||
typedef struct YYLTYPE
|
||||
{
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
} YYLTYPE;
|
||||
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYLTYPE_IS_DECLARED 1
|
||||
# define YYLTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,350 +0,0 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* A simple program version comparison tool.
|
||||
*
|
||||
* Copyright (C) 2005, Steven Michael Murphy (murf at e-tools dot com).
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
*/
|
||||
|
||||
/* vercomp.c
|
||||
args: <program> <comparison> <version>
|
||||
|
||||
where:
|
||||
|
||||
program = path to program (bison or flex)
|
||||
comparison = ">", "<", "<=", ">=", "=" -- depending on shell, you may have to use backslash escapes
|
||||
version = a version compare against, say 1.875, or 2.5.4, or whatever.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char *program_version[5];
|
||||
char *arg_version[5];
|
||||
|
||||
void get_program_version_string(char *command, char *output)
|
||||
{
|
||||
char cbuf[8000];
|
||||
char pbuf[8000];
|
||||
char zbuf[8000];
|
||||
char *res;
|
||||
FILE *p1;
|
||||
|
||||
zbuf[0] = 0;
|
||||
|
||||
sprintf( cbuf, "%s --version", command );
|
||||
p1 = popen(cbuf, "r");
|
||||
if( !p1 )
|
||||
{
|
||||
fprintf(stderr,"vercomp: Could not execute the command: %s\n", command);
|
||||
exit(125);
|
||||
}
|
||||
/* the first line is the magic one */
|
||||
res = fgets(zbuf, 8000, p1);
|
||||
/* clear the trailing blank */
|
||||
if( zbuf[strlen(zbuf)-1] == '\n' )
|
||||
zbuf[strlen(zbuf)-1] = 0;
|
||||
/* the rest is cruft, just empty the input stream */
|
||||
while( res )
|
||||
{
|
||||
res = fgets(pbuf, 8000, p1);
|
||||
}
|
||||
/* close the stream. Hopefully, we have what we need */
|
||||
pclose(p1);
|
||||
/* all we want is the last "word"-- so find the last blank, and grab everything after that */
|
||||
|
||||
res = strrchr(zbuf,' ');
|
||||
if( !res )
|
||||
{
|
||||
fprintf(stderr,"Something is wrong with the version string: %s\n", zbuf);
|
||||
exit(124);
|
||||
}
|
||||
strcpy(output,res+1);
|
||||
}
|
||||
|
||||
|
||||
void extract_version(char *ver_string, char **where)
|
||||
{
|
||||
int i=0;
|
||||
char *p=ver_string;
|
||||
|
||||
while( p && *p )
|
||||
{
|
||||
where[i++] = p;
|
||||
p = strchr(p,'.');
|
||||
if( p )
|
||||
{
|
||||
*p= 0;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void compare_versions(char *compare_func)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
/* start out at the beginning, then go to the end */
|
||||
if( program_version[i] && arg_version[i] && *program_version[i] && *arg_version[i] )
|
||||
{
|
||||
|
||||
if( strlen(program_version[i]) == strspn(program_version[i],"0123456789")
|
||||
&& strlen(arg_version[i]) == strspn(arg_version[i],"0123456789") )
|
||||
{
|
||||
/* just pure numbers -- do a numeric compare */
|
||||
int pv = atoi(program_version[i]);
|
||||
int av = atoi(arg_version[i]);
|
||||
|
||||
if( pv < av )
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else if( pv > av )
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* other junk thrown in -- do string compare */
|
||||
int res = strcmp(program_version[i], arg_version[i]);
|
||||
if( res < 0 ) /* prog is less than arg */
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else if( res > 0 ) /* prog is greater than arg */
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( program_version[i] && *program_version[i] )
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
else if( arg_version[i] && *arg_version[i] )
|
||||
{
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if( !strcmp(compare_func,"=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<") )
|
||||
{
|
||||
printf("false\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, ">=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
else if( !strcmp(compare_func, "<=") )
|
||||
{
|
||||
printf("true\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
printf("Usage: <program-path> <comparison> <version>\n\
|
||||
\n\
|
||||
where:\n\
|
||||
\n\
|
||||
program-path = path to program (bison or flex)\n\
|
||||
comparison = '>', '<', '<=', '>=', '=' -- depending on shell, you may have to use backslash escapes\n\
|
||||
version = a version compare against, say 1.875, or 2.5.4, or whatever.\n\n");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char program_version_string[8000];
|
||||
|
||||
/* before starting, check args and make sure all is OK */
|
||||
if( argc < 4 || argc > 4 )
|
||||
{
|
||||
usage();
|
||||
exit(-256);
|
||||
}
|
||||
if ( strcmp(argv[2],"=") && strcmp(argv[2],">") && strcmp(argv[2],"<") && strcmp(argv[2],">=") && strcmp(argv[2],"<=") )
|
||||
{
|
||||
fprintf(stderr,"vercomp: ILLEGAL input Comparison value: %s\n\n", argv[2]);
|
||||
usage();
|
||||
exit(-256);
|
||||
}
|
||||
|
||||
/* first, extract a version from the command line arg */
|
||||
extract_version(argv[3], arg_version);
|
||||
|
||||
/* next, extract a version from the command line */
|
||||
get_program_version_string(argv[1], program_version_string);
|
||||
extract_version(program_version_string, program_version);
|
||||
|
||||
/* next compare and return result */
|
||||
compare_versions(argv[2]);
|
||||
/* the above func shouldn't return */
|
||||
}
|
Loading…
Reference in new issue