#ifndef SQLTOKENH
#define SQLTOKENH
#define EVAL    0
#define DONTEVAL  1  
#define NOTYPECHECK  0  
#define TYPECHECK  1  
#define  EOF_CHAR '\x7f'
typedef enum {
               NOTOKEN,       
               IDENTIFIER,
               NUMBER,
               AND,
               OR,
               FOR,
               WHERE,
               SELECT,
               FROM,
               SQLLISTCOMMAND,
               CREATE,
               ALTER,
               DBFTABLE,
               MODIFY,
               VIEW,
               LPAREN,
               RPAREN,
               EQ,
               NOT,
               CHAR_TYPE,
               ON,
               AS, 
               END_OF_FILE,
               PLUS,
               MINUS,
               SEMICOLON,
               TO,
               ENDOFSTRING,
               COMMA,
               RANGLE,
               LANGLE,
               SINGLEQUOTE,
               DOT,
			   ATSIGN,
               LBRACKET,
               RBRACKET,
               INDEXCOMMAND,
               LT,
               GT,
               NE,
               LE,
               GE,
			   STAR,
               SLASH,
               DIV, 
               MOD, 
               STRING,
               UNARYMINUS,
               ASSIGN,
               DATE_TYPE,
               TIME_TYPE,
               BACKSLASH,
               DELETED,
               BOTH,
               DELETE_TYPE,
               INSERT,
               POINTER,
               ALL,
               LISTBUFFER,
               SQLUSECOMMAND,
               SETCOMMAND,
               TOPREC,
               NEXTREC,
               PREVREC,
               BOTREC,
               SORTCOMMAND,
               BY,
               UNIQUE,
               CLOSEALL,
               CLOSE,
               REMOVE,
               REPLACE,
               UNDELETE,
               SETDRIVE,
               SETERROR,
               RESET,
               SKIPCOMMAND,                          
               ORDER,
               INTO,
               GROUP,
               HAVING,
               ASCENDING,
               DECENDING,
               AVGFUNC,      
               SUMFUNC,      
               MINFUNC,      
               MAXFUNC,      
               COUNTFUNC,
               DISTINCT,
               WITH,
               GOTO,
               REINDEX,
               COLON,
               SQLZAP,
               PACK,
               LENGTHFUNC,
               WITHIN,
               UPDATE,
               IDENTIFIER_DOT_IDENTIFIER,
               IDENTIFIER_DOT_STAR,
               STARFIELD,
               NULLVALUE,               
               USERFUNC,
               DATETOCHAR,
               CHARTODATE,
               DROP,
               RECOVER,
               MAKE,
               STRING_DOT_IDENTIFIER,
               STRING_DOT_STAR,
               IN_TYPE,
               NOTIN,
               NOTWITHIN,
               INSET,
               NOTINSET,
               WITHINSET,
               NOTWITHINSET,
               NOTNULL,
               BETWEENSET,
               NOTBETWEENSET,
               BETWEEN,
               NOTBETWEEN,
               RECORDNUMBER,
               STRING_DOT_RECORDNUMBER,
               IDENTIFIER_DOT_RECORDNUMBER,
               RELDATABASE,
               COMMIT,
               ROLLBACK,
               INCLUDETABLE,
               SQLLOGIN,
               SQLLOGOUT,
               SQLREMOTE,
               SQLCONNECT,
               SQLDISCONNECT,
               SQLGRANT,
               SQLREVOKE,
               SQLEXPANDDATABASE,
               SQLLOCK,
               SQLUNLOCK,
               SQLADD,
               SQLCHANGEUSERSTAT,
               SQLDESCRIBE,
               SQLSHOW,
               SQLUSER,
			   //SQLGROUP,
			   SQLDEBUG,
			   OFF,
			   ROWID,
			   SUPERUSER,
			   SQLPRIVILEGE,
			   SQLTEAM,
			   SQLUPLOAD,
			   SQLDOWNLOAD,
			   SQLEXPORT,
			   SQLIMPORT,
			   SQLWRITESTORAGE,
			   SQLREADSTORAGE,
			   PE_0,
			   PE_1,
			   PE_2,
			   PE_3,
			   PE_4,
			   PE_5,
			   PE_6,
			   PE_7,
			   PE_8,
			   PE_9,
			   PE_10,
			   PE_11,
			   PE_12,
			   PE_13,
			   PE_14,
			   PE_15,
			   NPE_0,
               NPE_1,
               NPE_2,
               NPE_3,
               NPE_4,
               NPE_5,
               NPE_6,
               NPE_7,
               NPE_8,
               NPE_9,
               NPE_10,
               NPE_11,
               NPE_12,
               NPE_13,
               NPE_14,
               NPE_15,
			   SQLLIKE,
			   SQLNOTLIKE,
			   SQLGETCOMMAND,
			   SQLDESC,
			   SQLHOSTNAME,
			   SQLOPEN,
			   SQLCLOSE,
               IDENTIFIER_DOT_IDENTIFIER_DOT_IDENTIFIER,
               IDENTIFIER_DOT_IDENTIFIER_DOT_STAR,
               IDENTIFIER_DOT_STRING_DOT_IDENTIFIER,
               IDENTIFIER_DOT_STRING_DOT_STAR,
               IDENTIFIER_DOT_STRING_DOT_RECORDNUMBER,
               IDENTIFIER_DOT_IDENTIFIER_DOT_RECORDNUMBER,
               SQLHELP,
               SQLGET,
			   SQLSERVER,
			   SQLRUN,
			   NUMBER_STRING,
			   MATCH,
			   NOT_MATCH,
			   RECOGNIZE,
			   //Vector/AI extension (ivec). APPENDED AFTER RECOGNIZE on
			   //purpose: this enum is positionally aligned with the token
			   //name table in kmrnga10.cpp, so a token inserted anywhere
			   //but the end shifts every later token's code and silently
			   //makes the lexer return the wrong one. Append here, append
			   //there, and the alignment is preserved by construction.
			   VECTOR,
			   //VINSERT - storage-float vector insert. Appended right after
			   //VECTOR so the enum stays positionally aligned with the token
			   //name table in kmrnga10.cpp (see the note above).
			   VINSERT,
              }TOKENCODE;
int GetPartialCount(INTERNET_SQL_OBJECT *obj,TOKENCODE t );
typedef enum {
	OP_SELECT,
		OP_INDEXCOMMAND,
		OP_SQLLOCK,
		OP_SQLUNLOCK,
		OP_SQLDESCRIBE,
		OP_SQLREVOKE,
		OP_SQLGRANT,
               OP_SQLLOCKTABLE, //
               OP_SQLUNLOCKTABLE,
              
               OP_SQLDROPTABLE,
               OP_SQLDROPVIEW,
               OP_SQLDROPINDEX,
               OP_SQLRECOVERTABLE,
               OP_SQLRECOVERINDEX,
               OP_SQLRECOVERVIEW,

               OP_SQLINSERT,
               OP_SQLDELETEFROM,
               OP_SQLALTER,
               OP_SQLUNDELETEFROM,
			   OP_SQLUPDATE,
			   OP_SQLUPLOAD_FILE,
			   OP_SQLDOWNLOAD_FILE,
			   OP_SQLUPLOAD_BINARY,
			   OP_SQLDOWNLOAD_BINARY,

} TABLE_PERMISSIONS;
   
#endif
void GetTokenUntilBlank(INTERNET_SQL_OBJECT *);
void GetIdToken(INTERNET_SQL_OBJECT *);
void initscan(void);
void MakeString(INTERNET_SQL_OBJECT *,char *sqlcommand);
char ParseSet(INTERNET_SQL_OBJECT *,POSTFIXLINK *pf,TOKENCODE token);
char InsertOrderItem(INTERNET_SQL_OBJECT *,MAINSELECT *ms,TOKENCODE t,char *buf);
char InsertGroupItem(INTERNET_SQL_OBJECT *,MAINSELECT *ms,TOKENCODE t,char *buf);
char TokenIn(INTERNET_SQL_OBJECT *,TOKENCODE *list);
char Synchronize(INTERNET_SQL_OBJECT *,
				 TOKENCODE *list1,
                 TOKENCODE *list2,
                 TOKENCODE *list3
                 );
 POSTFIXLINK AddSqlFunc(INTERNET_SQL_OBJECT *obj,POSTFIXLINK *postlnk,
                               TOKENCODE op);
POSTFIXLINK AddSqlIdentifier(INTERNET_SQL_OBJECT *obj,POSTFIXLINK *postlnk,TOKENCODE token);
char EvalWhereItem(INTERNET_SQL_OBJECT *obj,MAINSELECT *ms,POSTFIXLINK postlnk,FROMTABLE *FromTables,char typecheck);
char DoWhereAnalysis(INTERNET_SQL_OBJECT *obj,MAINSELECT *ms,POSTFIXLINK pf,FROMTABLE *FromTables,char typecheck);
RECORDLIST AddSqlQryField(INTERNET_SQL_OBJECT *,RECORDLIST *,RECORDLIST,int,TOKENCODE, int selectflag);





