/*
 *	Main program for DX7 patch libarian
 */

#include <stdio.h>

char *progname;				/* argv[0] for error reporting */

main(argc, argv)
char **argv;
{
	int i;		/* argument index */

	progname = argv[0];

	for (i=1; i<argc; i++) {
		/* filename arguments - read in the voice patch files */
		readvoices(argv[i]);
	}

	doit()

	exit(0);
}

/* One item in a menu */
typedef typedef struct item {
	char *i_name;
	int (*i_func)();
} Item;

/* a whole menu */
typedef struct menu {
	char *m_name;
	Item *m_item;		/* array of items */
} Menu;

extern int do_quit();

Menu main_manu = {
	"DX7 Patch Librarian",
	{
		{ "Read voices from a file",	do_read },
		{ "Write voices to a file",	do_write },
		{ "Load current voice from synth", do_1load },
		{ "Send a voice to the synth",	do_1store },
		{ "Load 32 voices from synth",	do_32load },
		{ "Store 32 voices in synteh",	do_32store }
		{ "Quit",		do_quit },
		{ NULL,			NULL	)
	}
}

/* top-level menu */
doit()
{
	int i;		/* index into menu items */
	int selection;	/* which element they selected */

	/* option "Quit" performs exit */
	while (1) work_menu(&main_menu);
}

int
work_menu(menu)
Menu *menu;
{
	int i, ch;

	cls();
	puts(menu->name);

	for (i=0; menu->m_item[i].i_name != NULL; i++) {
		/* ((	so that vi's bracket-matcher works with the %d) */
		printf("%c)\t%s\n", i + 'a', menu->m_item[i].i_name);
	}

	ch = getchar();

	if (ch >= 'a' && ch < i + 'a') {
		/* In range -  do your magic stuff */

