
/* MINIFDOS installer
 * ------------------

*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <time.h>
#include <string.h>
#include "\nxdos\src\toolbox.h"


void main(int argc, char *argv[]) {


}






void install(void) {
     textbackground(0);
     textcolor(7);
     clrscr();
     if (params!=0) {
	error = spawnl(P_WAIT, "sys.com", "%c:",drive);
	}
     error = spawnl(P_WAIT, "lha.exe", "x utils.lzh %c:\\%s",drive,path);
     /* error = spawnl(P_WAIT, "lha.exe", "x src.zip %c:\\%s\\src\\",drive,path); */               if (error != 0) {
     // let user know of install error
     if (error!=0) {
	install_error();
	c=getch();
	} else {
	if ((configsysf = fopen("\\CONFIG.SYS", "wt")) == NULL) {
	   textcolor(12);
	   cprintf("Cannot create config.sys!\n");
	   error = 2; } else {
	   fprintf(configsysf,"files=50\n");
	   fprintf(configsysf,"buffers=20\n");
	   fprintf(configsysf,"break=on\n");
	   fprintf(configsysf,"stacks=0,0\n");
	   fprintf(configsysf,"lastdrive=Z\n");
	   fprintf(configsysf,"DOS=HIGH,UMB\n");
	   fprintf(configsysf,"SET PATH=\\FREEDOS\;c:\\utils\\\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXXMS.SYS BIOS NUMHANDLES=64\n");
	   fprintf(configsysf,"DEVICE=\\FREEDOS\\HIMEM.EXE\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXMS.SYS\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXMS286.SYS\n");
	   fprintf(configsysf,"DEVICE=\\FREEDOS\\EMM386.EXE\n");
	   fprintf(configsysf,"DEVICEHIGH=\\FREEDOS\\NANSI.SYS /S\n");
	   fclose(configsysf);
	   }
	if ((autoexecf = fopen("\\AUTOEXEC.BAT", "wt")) == NULL) {
	   textcolor(12);
	   cprintf("Cannot create autoexec.bat!\n");
	   error = 3; } else {
	   fprintf(autoexecf,"@echo off\n");
	   fprintf(autoexecf,"SET PROMPT=$[0;1;33;44m$G$P\n");
	   fprintf(autoexecf,":exit\n");
	   fclose(autoexecf);
	   }
	   if (error==0) startupfiles_done();
}

void mainscreen(void) {
    strcpy(path,defaultpath);
    if (stricmp("/?",argv[1])==0) { display_help(); } else {
	 while (done==0) {
	 introscreen();
	 textcolor(7);
	 cprintf("Welcome to the MINI FreeDOS Distribution!");
	 gotoxy(12,11); cprintf("This program will help you install FreeDOS.");
	 gotoxy(12,13); cprintf(" 1) DRIVE: %c:\\",drive);
	 gotoxy(12,14); cprintf(" 2) PATH : %s",path);
	 gotoxy(12,15); cprintf(" I) Install");
	 gotoxy(12,16); cprintf(" Q) Quit");
	 gotoxy(12,17);
	 textbackground(1);
	 c=getch();
	 switch(char(toupper(c))) {
	   case '1' : {
		      gotoxy(23,13); textbackground(3);
		      drive=getch();
		      break; }
	   case '2' : {
		      gotoxy(23,14); textbackground(3); clreol();
		      scanf("%s",path);
		      break; }
	   case 'I' : {
		      done=2;
		      install();
		      break; }
	   case 'Q' : {
		      done=1;
		      break; }
	   default : {
		      break; }
	 }
	} // while
}

void mainscreen(void) {
    strcpy(path,defaultpath);

	 while (done==0) {
	 introscreen();
	} // while
}

/*
void install(void) {
     textbackground(0);
     textcolor(7);
     clrscr();
     if (params!=0) {
	error = spawnl(P_WAIT, "sys.com", "%c:",drive);
	}
     error = spawnl(P_WAIT, "lha.exe", "x utils.lzh %c:\\%s",drive,path);
     /* error = spawnl(P_WAIT, "lha.exe", "x src.zip %c:\\%s\\src\\",drive,path); */               if (error != 0) {
     // let user know of install error
     if (error!=0) {
	install_error();
	c=getch();
	} else {
	if ((configsysf = fopen("\\CONFIG.SYS", "wt")) == NULL) {
	   textcolor(12);
	   cprintf("Cannot create config.sys!\n");
	   error = 2; } else {
	   fprintf(configsysf,"files=50\n");
	   fprintf(configsysf,"buffers=20\n");
	   fprintf(configsysf,"break=on\n");
	   fprintf(configsysf,"stacks=0,0\n");
	   fprintf(configsysf,"lastdrive=Z\n");
	   fprintf(configsysf,"DOS=HIGH,UMB\n");
	   fprintf(configsysf,"SET PATH=\\FREEDOS\;c:\\utils\\\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXXMS.SYS BIOS NUMHANDLES=64\n");
	   fprintf(configsysf,"DEVICE=\\FREEDOS\\HIMEM.EXE\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXMS.SYS\n");
	   fprintf(configsysf,"REM DEVICE=\\FREEDOS\\FDXMS286.SYS\n");
	   fprintf(configsysf,"DEVICE=\\FREEDOS\\EMM386.EXE\n");
	   fprintf(configsysf,"DEVICEHIGH=\\FREEDOS\\NANSI.SYS /S\n");
	   fclose(configsysf);
	   }
	if ((autoexecf = fopen("\\AUTOEXEC.BAT", "wt")) == NULL) {
	   textcolor(12);
	   cprintf("Cannot create autoexec.bat!\n");
	   error = 3; } else {
	   fprintf(autoexecf,"@echo off\n");
	   fprintf(autoexecf,"SET PROMPT=$[0;1;33;44m$G$P\n");
	   fprintf(autoexecf,":exit\n");
	   fclose(autoexecf);
	   }
	   if (error==0) startupfiles_done();
}
*/
