int doTyphoon();
int  dbError();
void dbErrorMsg();
void initSequences();

void dbHELP(char *cmd);
void dbCMD(char *cmd, int command);

void dbPrintSection(int cmd);
void dbPrintAddress(int cmd);
void dbPrintCode(int cmd);
void dbPrintIntCode(int cmd);
void dbPrintFinCode(int cmd);
void dbPrintName(int cmd);
void dbPrintComment(int cmd);
void dbPrintXref(int cmd);
void dbPrintImport(int cmd);
void dbPrintLib(int cmd);
void dbPrintExport(int cmd);
void dbPrintString(int cmd);
void dbPrintFunction(int cmd);
void dbPrintFuncParam(int cmd);
void dbPrintFuncLocal(int cmd);
void dbPrintInline(int cmd);
void dbPrintInlineType(int cmd);
void dbPrintStructure(int cmd);
void dbPrintStructMember(int cmd);
void dbPrintDataType(int cmd);
void dbPrintConstant(int cmd);
void dbPrintMacro(int cmd);
typedef void (*dbPrintFunc)(int);
struct dbPrintFuncTable {
		  int table;
		  dbPrintFunc func;
} static dbPrintFuncs[] = {
  	{ SECTION, dbPrintSection },
  	{ ADDRESS, dbPrintAddress },
  	{ CODE, dbPrintCode },
  	{ INT_CODE, dbPrintIntCode },
  	{ FIN_CODE, dbPrintFinCode },
  	{ NAME, dbPrintName },
  	{ COMMENT, dbPrintComment },
  	{ XREF, dbPrintXref },
  	{ IMPORT, dbPrintImport },
  	{ LIB, dbPrintLib },
  	{ EXPORT, dbPrintExport },
  	{ STRING, dbPrintString },
  	{ FUNCTION, dbPrintFunction },
  	{ FUNC_PARAM, dbPrintFuncParam },
  	{ FUNC_LOCAL, dbPrintFuncLocal },
  	{ F_INLINE, dbPrintInline },
  	{ INLINE_TYPE, dbPrintInlineType },
  	{ STRUCTURE, dbPrintStructure },
  	{ STRUCT_MEMBER, dbPrintStructMember },
 	{ DATA_TYPE, dbPrintDataType },
 	{ CONSTANT, dbPrintConstant },
 	{ SEER_MACRO, dbPrintMacro},
	{ 0, NULL}
};

struct DB_SEQUENCE {
	int int_code;
	int fin_code;
	int xref;
	int comment;
	int func;
	int func_param;
	int func_local;
	int f_inline;
	int inline_type;
	int structure;
	int struct_member;
	int data_type;
	int library;
	int constant;
	int seer_macro;
} seq;

#define DB_DESC	0
#define DB_DUMP	1
#define DB_MIN		2
#define DB_MAX		3
#define DB_COUNT	4
#define DB_FIND	5
#define DB_PRINT	6

/* The DB will be a .tgz of the typhoon files, a file_id.idz - type 
 * file providing target info, and a copy of the target. Yes, this wastes
 * space, but since the entire binary code of the target will have to be
 * stored in the DB *regardless* [in order to allow SaveAsEXE features that
 * actually work], it is better to keep an image of the file, mmap it 
 * during execution, store the 'binary data' in the DB as offsets from the
 * start of the EXE + a size value
 */

