Subversion Repositories SvarDOS

Rev

Rev 49 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 49 Rev 53
Line 12... Line 12...
12
#include <string.h>  /* memcpy() */
12
#include <string.h>  /* memcpy() */
13
#include <unistd.h>
13
#include <unistd.h>
14
 
14
 
15
#include "kitten\kitten.h"
15
#include "kitten\kitten.h"
16
 
16
 
-
 
17
#include "cdrom.h"
17
#include "input.h"
18
#include "input.h"
18
#include "video.h"
19
#include "video.h"
19
 
20
 
20
 
21
 
21
/* color scheme (color, mono) */
22
/* color scheme (color, mono) */
Line 288... Line 289...
288
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
289
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
289
      return(-1);
290
      return(-1);
290
    }
291
    }
291
    /* if not formatted, propose to format it right away (try to create a directory) */
292
    /* if not formatted, propose to format it right away (try to create a directory) */
292
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
293
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
293
    if (mkdir(buff) != 0) {
294
    if (mkdir(buff) == 0) {
-
 
295
      rmdir(buff);
-
 
296
    } else {
294
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
297
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
295
      list[0] = kittengets(0, 6, list[0]);
298
      list[0] = kittengets(0, 6, list[0]);
296
      list[1] = kittengets(0, 2, list[1]);
299
      list[1] = kittengets(0, 2, list[1]);
297
      sprintf(buff, kittengets(3, 10, "ERROR: Drive %c: seems to be unformated."), cselecteddrive);
300
      sprintf(buff, kittengets(3, 10, "ERROR: Drive %c: seems to be unformated."), cselecteddrive);
298
      video_putstring(7, 2, COLOR_BODY[mono], buff);
301
      video_putstring(7, 2, COLOR_BODY[mono], buff);
Line 302... Line 305...
302
      video_movecursor(0, 0);
305
      video_movecursor(0, 0);
303
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
306
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
304
      system(buff);
307
      system(buff);
305
      continue;
308
      continue;
306
    }
309
    }
307
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
-
 
308
    rmdir(buff);
-
 
309
    /* check total disk space */
310
    /* check total disk space */
310
    ds = disksize(selecteddrive);
311
    ds = disksize(selecteddrive);
311
    if (ds < SVAROG_DISK_REQ) {
312
    if (ds < SVAROG_DISK_REQ) {
312
      sprintf(buff, kittengets(3, 12, "ERROR: Drive %c: is not big enough!"), cselecteddrive);
313
      sprintf(buff, kittengets(3, 12, "ERROR: Drive %c: is not big enough!"), cselecteddrive);
313
      video_putstring(9, 2, COLOR_BODY[mono], buff);
314
      video_putstring(9, 2, COLOR_BODY[mono], buff);
Line 348... Line 349...
348
    }
349
    }
349
  }
350
  }
350
}
351
}
351
 
352
 
352
 
353
 
-
 
354
/* copy file src into dst, substituting all characters c1 by c2 */
-
 
355
static void fcopysub(char *dst, char *src, char c1, char c2) {
-
 
356
  FILE *fdd, *fds;
-
 
357
  int buff;
-
 
358
  fds = fopen(src, "rb");
-
 
359
  if (fds == NULL) return;
-
 
360
  fdd = fopen(dst, "wb");
-
 
361
  if (fdd == NULL) {
-
 
362
    fclose(fds);
-
 
363
    return;
-
 
364
  }
-
 
365
  /* */
-
 
366
  for (;;) {
-
 
367
    buff = fgetc(fds);
-
 
368
    if (buff == EOF) break;
-
 
369
    if (buff == c1) buff = c2;
-
 
370
    fprintf(fdd, "%c", buff);
-
 
371
  }
-
 
372
  /* close files and return */
-
 
373
  fclose(fdd);
-
 
374
  fclose(fds);
-
 
375
}
-
 
376
 
-
 
377
 
353
static void bootfilesgen(int targetdrv, char *lang) {
378
static void bootfilesgen(int targetdrv, char *lang, int cdromdrv) {
354
  char buff[128];
379
  char buff[128];
355
  int cp, egafile;
380
  int cp, egafile;
356
  FILE *fd;
381
  FILE *fd;
357
  cp = getnlscp(lang, &egafile);
382
  cp = getnlscp(lang, &egafile);
-
 
383
  /*** CONFIG.SYS ***/
-
 
384
  sprintf(buff, "%c:\\CONFIG.SYS", targetdrv);
-
 
385
  fd = fopen(buff, "wb");
-
 
386
  if (fd == NULL) return;
-
 
387
  fprintf(fd, "DOS=UMB,HIGH\r\n");
-
 
388
  fprintf(fd, "FILES=50\r\n");
-
 
389
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEMX.EXE\r\n", targetdrv);
-
 
390
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512 /P\r\n", targetdrv);
-
 
391
  if (egafile > 0) fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\DISPLAY.SYS\r\n", targetdrv);
-
 
392
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\CONF\\COUNTRY.SYS\r\n", targetdrv);
-
 
393
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
-
 
394
  fclose(fd);
358
  /*** AUTOEXEC.BAT ***/
395
  /*** AUTOEXEC.BAT ***/
359
  sprintf(buff, "%c:\\AUTOEXEC.BAT", targetdrv);
396
  sprintf(buff, "%c:\\AUTOEXEC.BAT", targetdrv);
360
  fd = fopen(buff, "wb");
397
  fd = fopen(buff, "wb");
361
  if (fd == NULL) return;
398
  if (fd == NULL) return;
362
  fprintf(fd, "@ECHO OFF\r\n");
399
  fprintf(fd, "@ECHO OFF\r\n");
363
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
400
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
364
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
401
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
365
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
402
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
366
  fprintf(fd, "SET LANG=%s\r\n", lang);
403
  fprintf(fd, "SET LANG=%s\r\n", lang);
367
  fprintf(fd, "SET DIRCMD=/OGNE/P\r\n");
404
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
368
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n");
405
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n", targetdrv);
369
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n");
406
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n", targetdrv);
370
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%%DOSDIR%%\\LINKS\r\n");
407
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%c:\\SYSTEM\\LINKS\r\n", targetdrv);
371
  fprintf(fd, "PROMPT $P$G\r\n");
408
  fprintf(fd, "PROMPT $P$G\r\n");
372
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
409
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
373
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
410
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
374
  fprintf(fd, "\r\n");
411
  fprintf(fd, "\r\n");
375
  if (egafile > 0) {
412
  if (egafile > 0) {
Line 384... Line 421...
384
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
421
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
385
  fprintf(fd, "\r\n");
422
  fprintf(fd, "\r\n");
386
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
423
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
387
  fprintf(fd, "REM CTMOUSE\r\n");
424
  fprintf(fd, "REM CTMOUSE\r\n");
388
  fprintf(fd, "\r\n");
425
  fprintf(fd, "\r\n");
389
  fprintf(fd, "ECHO.");
426
  fprintf(fd, "ECHO.\r\n");
390
  fprintf(fd, "ECHO WELCOME TO SVAROG386! TYPE 'HELP' IF YOU NEED HELP.\r\n");
427
  fprintf(fd, "ECHO Welcome to Svarog386! Type 'HELP' if your need help.\r\n");
391
  fclose(fd);
-
 
392
  /*** CONFIG.SYS ***/
-
 
393
  sprintf(buff, "%c:\\CONFIG.SYS", targetdrv);
-
 
394
  fd = fopen(buff, "wb");
-
 
395
  if (fd == NULL) return;
-
 
396
  fprintf(fd, "DOS=UMB,HIGH\r\n");
-
 
397
  fprintf(fd, "FILES=50\r\n");
-
 
398
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEMX.EXE\r\n", targetdrv);
-
 
399
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512 /P\r\n", targetdrv);
-
 
400
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
-
 
401
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
-
 
402
  fclose(fd);
428
  fclose(fd);
-
 
429
  /*** CREATE DIRECTORY FOR OTHER CONFIGURATION FILES ***/
-
 
430
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
-
 
431
  mkdir(buff);
-
 
432
  /*** FDNPKG.CFG ***/
-
 
433
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
-
 
434
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
-
 
435
  /*** COUNTRY.SYS ***/
-
 
436
  /*** PICOTCP ***/
-
 
437
  /*** WATTCP ***/
403
}
438
}
404
 
439
 
405
 
440
 
406
static void installpackages(int targetdrv) {
441
static void installpackages(int targetdrv, int cdromdrv) {
407
  char *pkglist[] = {
442
  char *pkglist[] = {
408
    "APPEND",
443
    "APPEND",
409
    "ASSIGN",
444
    "ASSIGN",
410
    "ATTRIB",
445
    "ATTRIB",
411
    "CHKDSK",
446
    "CHKDSK",
Line 471... Line 506...
471
  for (i = 0; pkglist[i] != NULL; i++) {
506
  for (i = 0; pkglist[i] != NULL; i++) {
472
    char buff[128];
507
    char buff[128];
473
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
508
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
474
    strcat(buff, "       ");
509
    strcat(buff, "       ");
475
    video_putstring(10, 2, COLOR_BODY[mono], buff);
510
    video_putstring(10, 2, COLOR_BODY[mono], buff);
476
    sprintf(buff, "FDINST INSTALL X:\\CORE\\%s.ZIP > NUL", pkglist[i]);
511
    sprintf(buff, "FDINST INSTALL %c:\\CORE\\%s.ZIP > NUL", cdromdrv, pkglist[i]);
477
    system(buff);
512
    system(buff);
478
  }
513
  }
479
}
514
}
480
 
515
 
481
 
516
 
Line 516... Line 551...
516
 
551
 
517
 
552
 
518
int main(void) {
553
int main(void) {
519
  char lang[4];
554
  char lang[4];
520
  int targetdrv;
555
  int targetdrv;
-
 
556
  int cdromdrv;
-
 
557
 
-
 
558
  /* find where the cdrom drive is */
-
 
559
  cdromdrv = cdrom_findfirst();
-
 
560
  if (cdromdrv < 0) {
-
 
561
    printf("ERROR: CD-ROM DRIVE NOT FOUND\r\n");
-
 
562
    return(1);
-
 
563
  }
-
 
564
  cdromdrv += 'A'; /* convert the cdrom 'id' (A=0) to an actual drive letter */
521
 
565
 
522
  /* init screen and detect mono status */
566
  /* init screen and detect mono status */
523
  mono = video_init();
567
  mono = video_init();
524
 
568
 
525
  for (;;) { /* fake loop, it's here just to break out easily */
569
  for (;;) { /* fake loop, it's here just to break out easily */
Line 530... Line 574...
530
    /*selectkeyb();*/ /* what keyb layout should we use? */
574
    /*selectkeyb();*/ /* what keyb layout should we use? */
531
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
575
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
532
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
576
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
533
    if (targetdrv < 0) break;
577
    if (targetdrv < 0) break;
534
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
578
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
535
    installpackages(targetdrv);   /* install packages */
579
    installpackages(targetdrv, cdromdrv);    /* install packages */
536
    bootfilesgen(targetdrv, lang); /* generate simple boot files */
580
    bootfilesgen(targetdrv, lang, cdromdrv); /* generate boot files and other configurations */
537
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
581
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
538
    /*netcfg();*/ /* basic networking config */
582
    /*netcfg();*/ /* basic networking config */
539
    /* TODO compute a customized FDNPKG file that looks either to local CD or net */
-
 
540
    finalreboot(); /* remove the CD and reboot */
583
    finalreboot(); /* remove the CD and reboot */
541
    break;
584
    break;
542
  }
585
  }
543
  kittenclose(); /* close NLS support */
586
  kittenclose(); /* close NLS support */
544
  video_clear(0x0700, 0);
587
  video_clear(0x0700, 0);