[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Config selector



I would like MiNT to have a primitive configuration file selection instead
of that 'Boot MiNT (y/n)?'. Copying those files with a boot manager is IMHO
clumsy :-).

Changing MiNT to read one of mint.cn[f123456789] files would only need
something like I wrote at the bottom (to MiNT 1.12-h3 sources, not tested).
The hardest part would be the modifying of the texts to all the needed
languages ;-).


	- Eero

Main.c:
---------
char *cnf_filename(char *path);

void
load_config()
{
	int fd;

	fd = (int) f_open(cnf_filename(""), 0);
	if (fd < 0)
		fd = (int) f_open(cnf_filename("\\mint\\"), 0);
	if (fd < 0)
		fd = (int) f_open(cnf_filename("\\multitos\\"), 0);B
	if (fd < 0) return;
	do_file(fd);
	f_close(fd);
}
---------
Wellcome.c:
---------
#include <string.h>		/* strcpy() & strcat() */

/*
 * "Select MiNT configuration?" messages (when shift pressed),
 * in various languages:
 */

static char *boot_it[MAXLANG] = {
{"\n\nSelect " MINT_NAME " configuration 1-9 or quit (any other key)\n: "}
{"Same in another language"}
{"ditto"}
{"etc."}
};

/* name of the MiNT configuration file */
#define CONF_NAMELEN	8
static char cnf_name[8] = "mint.cnf";

/*
 * Ask the user which configuration file should be used or whether MiNT
 * should quit; modifies MiNT config filename accordingly and returns 1
 * or returns 0 for quit.
 */

int
boot_kernel_p()
{
	extern int gl_lang;
	int y;

	Cconws(&boot_it[gl_lang]);
	y = (int) Cconin();
	if (y >= '1' && y <= '9')
	{
	  	cnf_name[CONF_NAMELEN - 1] = y;
		return 1;
	}
	else
		return 0;
}

/* return the path with the MiNT configuration filename concatenated */
char *cnf_filename(char *path)
{
	int len;
	static char buf[128];

	len = strlen(path);
	if(len == 0 && len >= 128 - CONF_NAMELEN)
		return cnf_name;

	strcpy(buf, path);
	strcat(buf, cnf_name);
	return buf;
}
---------