#ifndef _BASTARD_MACRO_H
#define _BASTARD_MACRO_H

/* command EQU's */
#define CMD_SET 	1	//basic commands
#define CMD_SHOW	2
#define CMD_DB		3
#define CMD_LOAD	4
#define CMD_EXEC	5
#define CMD_DEBUG	6	
#define CMD_HELP	7
#define CMD_QUIT	8
#define CMD_HEADER	10	// target info commands
#define CMD_SECTION	11
#define CMD_RANGE	12
#define CMD_DISASM	13
#define CMD_STRINGS	14	
#define CMD_MACRO	20	//macro commands
#define CMD_ENDMACRO 21	//macro commands
#define CMD_RECORD	22
#define CMD_STOP	23
#define CMD_RUN		24
#define CMD_BRACE	25
#define CMD_UNDEF	0	

/* command alias mapping */
int CMD_SHORTCUT[43];
// -- the .rc file should be able to reset these

static char* HELPSTR[] = {
"UNRECOGNIZED COMMAND\t -- These are assumed to be internal API commands; they will be compiled into SeerC scripts and executed.",
"SET [variable] [value]\t-- Set internal environment variables.",
"SHOW [variable]\t-- Display current settings of internal environment variables",
"DB [command]\t-- Execute a database command or query. \'DB ?\' lists all commands.",
"LOAD [target] [format] [cpu]\t-- loads and disassembles target. Assumes the values \'a.out\', \'ELF\', and \'ix86\' if parameters are not specified.",
"EXEC [command]\t-- Run a shell or a shell script command",
"DEBUG\t-- Run the target inside an external debugger",
"HELP Topics: DB DEBUG DISASM EXEC HEADER LOAD MACRO QUIT RANGE RECORD RUN SECTION SET SHOW STOP STRINGS",
"QUIT\t-- Exit the disassembler",
" ",
"HEADER\t-- Display target file header",
"SECTION [name]\t-- Dump disassembly of section \'name\'",
"RANGE [start] [end]\t-- Display a disassembled listing of addresses between \'start\' and \'end\'",
"DISASM [filename]\t-- Display a disassembled listing of the target; use \'filename\' instead of STDOUT if specified.",
"STRINGS\t-- Display the ASCII strings identified in the target.",
" ", " ", " ", " ", " ",
"MACRO [name]\t-- Start writing a command-line macro/batch file",
"ENDMACRO\t-- Stop writing a command-line macro/batch file",
"RECORD [name]\t-- Start recording a command-line macro/batch file",
"STOP\t-- Stop recording",
"RUN [name]\t-- Run a macro/batch file",
"{{\t-- Write the main function of a SeerC script"
};

#define NUM_DB_CMD 10
static char* DB_CMD[] = {
"HELP",
"COUNT",
"DESC",
"DUMP",
"FIND",
"MAX",
"MIN",
};

static char* DB_HELPSTR[] = {
"HELP Topics: COUNT DEL DESC DUMP FIND INSERT MAX MIN UPDATE",
"COUNT [table]\t -- Count number of records in table",
"DESC [table]\t-- Describe table",
"DUMP [table]\t-- Dump contents of table to STDOUT",
"FIND [table] [key] [value]\t-- Find record in table where key == value",
"MAX [table] [key]\t -- Find record in table where key has the greatest value",
"MIN [table] [key]\t -- Find record in table where key has the least value",
};

#define NUM_ENV_CMD 1
static char* ENV_CMD = {
"HELP"
};

static char scTemplate[]="#include bastard\n\nexport main;\nint main(int argc, char **argv) {\n\t%s\n\treturn(0);\n}\n";
#endif

/* function prototypes */

/* utility */
int istrncmp( char *s1, char *s2, int len);
int strtoupper( char *table, int len);
int CharToConst( char *c);

/* interpreter commands */
int cmdSET(char *cmd);
int cmdSHOW(char *cmd);
int cmdLOAD(char *file);
int cmdDB(char *cmd);
int cmdMACRO(char *cmd);
int cmdRECORD(char *cmd);
int cmdEXEC(char *cmd);
int cmdDEBUG(char *cmd);
int cmdHELP(char *cmd);
int cmdQUIT();

int TranslateSubCmd(char  *cmd, char* cmd_array[], int max);

/* Seer stuff */
char *c_inc, *b_inc, *b_def;
void doSeer();
void finSeer();
int checkLine( char *line);
int ExecMacroLine( char *cmd );
