/*
 *	MDB.H		(Generalized Static/Dynamic Array Version)
 *
 *	Program:	Mini-Database
 *	Written by:	Leor Zolman
 *  Module:		Program Header File
 */

#define	TRUE	1
#define	FALSE	0

/*
 * Prototypes: 
 */

int do_menu(struct menu_item *mnu, char *title);
void write_db(char *filename);
int read_db(char *filename);
void edit_db(char *db_name);
void backup_db(void);

void error(char *msg);
struct record *alloc_rec(void);
void free_up(void);

/*
 * Data Definitions:
 */

struct record {			/* Database record definition	*/
	char 	active;		/* TRUE if Active, else FALSE	*/
	char	last[25], first[15];/* Name				*/
	long	id;					/* ID Number		*/
	int		age;				/* Age				*/
	char	gender;				/* M or F			*/
	float	salary;				/* Annual Salary	*/
};

#define	MAX_RECS	1000 /* Maximum number of records	*/


#ifdef MAIN_MODULE		/* Make sure data is only		*/
#define EXTERN			/* DEFINED in the main module,	*/
#else					/* and declared as EXTERNAL in	*/
#define EXTERN	extern	/* the other modules.			*/
#endif


EXTERN	struct	record *recs[MAX_RECS]; /* Array of ptr	*/
#define	RECS	recs		/* to struct of type record	*/
                                                                     
EXTERN	int n_recs;		/* # of records	in current db	*/
EXTERN	int max_recs;	/* Max # of recs allowed		*/

struct menu_item {			/* Menu definition record	*/
	int action_code;		/* Menu item code			*/
	char *descrip;			/* Menu item text			*/
};
