librnd init sequence

int main(int argc, char *argv[])
{
	rnd_main_args_t ga;

	/* fill in rnd_app struct fields */
	rnd_app.package = "foobar";
	rnd_app.version = FOOBAR_VERSION;
	rnd_app.url = "http://repo.hu/projects/foobar";

	rnd_app.default_embedded_menu = "";
	rnd_app.menu_file_paths = menu_file_paths;
	rnd_app.menu_name_fmt = "foobar-menu.lht";

	rnd_app.conf_userdir_path = CONF_USER_DIR;
	rnd_app.conf_user_path = CONF_USER_DIR "/foobar-conf.lht";
	rnd_app.conf_sysdir_path = FOOBARSHAREDIR;
	rnd_app.conf_sys_path = FOOBARSHAREDIR "/foobar-conf.lht";

	rnd_app.crosshair_move_to = my_crosshair_move_to;
	rnd_app.draw_attached = my_draw_attached;

	/* pre-init */
	pcb_fix_locale_and_env();

	/* set up non-hidlib related app states */
	...

	rnd_main_args_init(&ga, argc, foobar_action_args);
	rnd_hidlib_init1(conf_core_init);

	for(n = 1; n < argc; n++) {
		/* optional override code could happen here to process some args locally */
		n += rnd_main_args_add(&ga, argv[n], argv[n+1]);
	}

	rnd_hidlib_init2(pup_buildins, foobar_buildins);
	rnd_hidlib_init3_auto();


	/* set up hidlib related app states - all main infrastructure is up by now */
	...

	if (rnd_main_args_setup1(&ga) != 0) {
		foobar_main_uninit();
		rnd_main_args_uninit(&ga);
		exit(1);
	}

	/* register core actions here */
	...

	if (rnd_main_args_setup2(&ga, &n) != 0) {
		foobar_main_uninit();
		rnd_main_args_uninit(&ga);
		exit(n);
	}


	/* load or create the design specified on command line */
	...

	if (rnd_main_exported(&ga, &foobar.hidlib, 0)) {
		foobar_main_uninit();
		rnd_main_args_uninit(&ga);
		exit(0);
	}

	/* pre-mainloop initializations */
	...

	if (RND_HAVE_GUI_ATTR_DLG)
		gui_support_plugins(1); /* load/initialize GUI plugins that will populate the top window */

	rnd_mainloop_interactive(&ga, &foobar.hidlib); /* main loop */

	/* application uninit *//
	foobar_main_uninit();
	rnd_main_args_uninit(&ga);
	return 0;
}


