Subversion Repositories SvarDOS

Rev

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

Rev 197 Rev 200
Line 381... Line 381...
381
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
381
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
382
  return(res);
382
  return(res);
383
}
383
}
384
 
384
 
385
 
385
 
-
 
386
/* set new DOS "current drive" to drv ('A', 'B', etc). returns 0 on success */
-
 
387
static int set_cur_drive(char drv) {
-
 
388
  union REGS r;
-
 
389
  if ((drv < 'A') || (drv > 'Z')) return(-1);
-
 
390
  r.h.ah = 0x0E; /* DOS 1+ SELECT DEFAULT DRIVE */
-
 
391
  r.h.dl = drv - 'A';
-
 
392
  int86(0x21, &r, &r);
-
 
393
  if (r.h.al < drv - 'A') return(-1);
-
 
394
  return(0);
-
 
395
}
-
 
396
 
-
 
397
 
-
 
398
/* returns 0 if file exists, non-zero otherwise */
-
 
399
static int fileexists(const char *fname) {
-
 
400
  FILE *fd;
-
 
401
  fd = fopen(fname, "rb");
-
 
402
  if (fd == NULL) return(-1);
-
 
403
  fclose(fd);
-
 
404
  return(0);
-
 
405
}
-
 
406
 
-
 
407
 
386
static int preparedrive(void) {
408
static int preparedrive(void) {
387
  int driveremovable;
409
  int driveremovable;
388
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
410
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
389
  int cselecteddrive;
411
  int cselecteddrive;
390
  int ds;
412
  int ds;
Line 593... Line 615...
593
  fprintf(fd, "REM CTMOUSE\r\n");
615
  fprintf(fd, "REM CTMOUSE\r\n");
594
  fprintf(fd, "\r\n");
616
  fprintf(fd, "\r\n");
595
  fprintf(fd, "ECHO.\r\n");
617
  fprintf(fd, "ECHO.\r\n");
596
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to SvarDOS! Type 'HELP' if you need help."));
618
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to SvarDOS! Type 'HELP' if you need help."));
597
  fclose(fd);
619
  fclose(fd);
598
  /*** CREATE DIRECTORY FOR OTHER CONFIGURATION FILES ***/
620
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
-
 
621
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM", targetdrv);
-
 
622
  mkdir(buff);
599
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
623
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
600
  mkdir(buff);
624
  mkdir(buff);
601
  /*** FDNPKG.CFG ***/
625
  /*** FDNPKG.CFG ***/
602
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
626
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
603
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
627
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
Line 640... Line 664...
640
      case '\r':
664
      case '\r':
641
        pkglist[i] = 0;
665
        pkglist[i] = 0;
642
        break;
666
        break;
643
    }
667
    }
644
  }
668
  }
645
  /* set DOSDIR */
669
  /* set DOSDIR, TEMP, COMSPEC and FDNPKG.CFG */
646
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVARDOS", targetdrv);
670
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVARDOS", targetdrv);
647
  setenv("DOSDIR", buff, 1);
671
  setenv("DOSDIR", buff, 1);
648
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
672
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
649
  setenv("TEMP", buff, 1);
673
  setenv("TEMP", buff, 1);
-
 
674
  snprintf(buff, sizeof(buff), "%c:\\COMMAND.COM", targetdrv);
-
 
675
  setenv("COMSPEC", buff, 1);
-
 
676
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
-
 
677
  setenv("FDNPKG.CFG", buff, 1);
-
 
678
  /* copy pkginst to the new drive so it is not read from floppy each time I need it */
-
 
679
  snprintf(buff, sizeof(buff), "COPY %c:\\FDINST.EXE %c:\\ > NUL", cdromdrv, targetdrv);
-
 
680
  system(buff);
-
 
681
  /* change current drive to target so I use the on-hdd fdinst from now on */
-
 
682
  if (set_cur_drive(targetdrv) != 0) {
-
 
683
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: CHANGING DRIVE TO TARGET FAILED", -1);
-
 
684
    input_getkey();
-
 
685
    return(-1);
-
 
686
  }
650
  /* install packages */
687
  /* install packages */
651
  pkgptr = pkglist;
688
  pkgptr = pkglist;
652
  for (i = 0;; i++) {
689
  for (i = 0;; i++) {
653
    char buff[64];
690
    char buff[64];
654
    /* move forward to nearest entry or end of list */
691
    /* move forward to nearest entry or end of list */
Line 656... Line 693...
656
    if (*pkgptr == 0xff) break;
693
    if (*pkgptr == 0xff) break;
657
    /* install the package */
694
    /* install the package */
658
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkgptr);
695
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkgptr);
659
    strcat(buff, "       ");
696
    strcat(buff, "       ");
660
    video_putstringfix(10, 1, COLOR_BODY[mono], buff, sizeof(buff));
697
    video_putstringfix(10, 1, COLOR_BODY[mono], buff, sizeof(buff));
-
 
698
    /* wait for new diskette if package not found */
-
 
699
    snprintf(buff, sizeof(buff), "%c:\\%s.zip", cdromdrv, pkgptr);
-
 
700
    while (fileexists(buff) != 0) {
-
 
701
      putstringnls(12, 1, COLOR_BODY[mono], 4, 1, "*** INSERT THE DISK THAT CONTAINS THE REQUIRED FILE AND PRESS ANY KEY ***");
-
 
702
      input_getkey();
-
 
703
      video_putstringfix(12, 1, COLOR_BODY[mono], "", 80); /* erase the 'insert disk' message */
-
 
704
    }
-
 
705
    /* proceed with package install */
661
    snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\%s.ZIP > NUL", cdromdrv, pkgptr);
706
    snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\%s.ZIP > NUL", cdromdrv, pkgptr);
662
    if (system(buff) != 0) {
707
    if (system(buff) != 0) {
663
      video_putstring(10, 30, COLOR_BODY[mono], "ERROR: PKG INSTALL FAILED", -1);
708
      video_putstring(12, 30, COLOR_BODY[mono], "ERROR: PKG INSTALL FAILED", -1);
664
      input_getkey();
709
      input_getkey();
665
      return(-1);
710
      return(-1);
666
    }
711
    }
667
    /* jump to next entry or end of list */
712
    /* jump to next entry or end of list */
668
    while ((*pkgptr != 0) && (*pkgptr != 0xff)) pkgptr++;
713
    while ((*pkgptr != 0) && (*pkgptr != 0xff)) pkgptr++;
Line 705... Line 750...
705
  r.h.ah = 0; /* re-set video mode (to whatever is set in AL) */
750
  r.h.ah = 0; /* re-set video mode (to whatever is set in AL) */
706
  int86(0x10, &r, &r);
751
  int86(0x10, &r, &r);
707
  }
752
  }
708
}
753
}
709
 
754
 
-
 
755
 
710
/* checks that drive drv contains SvarDOS packages
756
/* checks that drive drv contains SvarDOS packages
711
 * returns 0 if found, non-zero otherwise */
757
 * returns 0 if found, non-zero otherwise */
712
static int checkinstsrc(char drv) {
758
static int checkinstsrc(char drv) {
713
  FILE *fd;
-
 
714
  char fname[16];
759
  char fname[16];
715
  snprintf(fname, sizeof(fname), "%c:\\ATTRIB.ZIP", drv);
760
  snprintf(fname, sizeof(fname), "%c:\\ATTRIB.ZIP", drv);
716
  fd = fopen(fname, "rb");
761
  return(fileexists(fname));
717
  if (fd == NULL) return(-1);
-
 
718
  fclose(fd);
-
 
719
  return(0);
-
 
720
}
762
}
721
 
763
 
722
 
764
 
723
int main(void) {
765
int main(void) {
724
  struct slocales locales;
766
  struct slocales locales;
Line 763... Line 805...
763
  if (action == MENUQUIT) goto Quit;
805
  if (action == MENUQUIT) goto Quit;
764
  if (action == MENUPREV) goto SelectLang;
806
  if (action == MENUPREV) goto SelectLang;
765
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
807
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
766
  if (targetdrv == MENUQUIT) goto Quit;
808
  if (targetdrv == MENUQUIT) goto Quit;
767
  if (targetdrv == MENUPREV) goto WelcomeScreen;
809
  if (targetdrv == MENUPREV) goto WelcomeScreen;
768
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
-
 
769
  if (installpackages(targetdrv, sourcedrv) != 0) goto Quit;    /* install packages */
-
 
770
  bootfilesgen(targetdrv, &locales, sourcedrv); /* generate boot files and other configurations */
810
  bootfilesgen(targetdrv, &locales, sourcedrv); /* generate boot files and other configurations */
-
 
811
  if (installpackages(targetdrv, sourcedrv) != 0) goto Quit;    /* install packages */
771
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
812
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
772
  /*netcfg();*/ /* basic networking config */
813
  /*netcfg();*/ /* basic networking config */
773
  finalreboot(); /* remove the CD and reboot */
814
  finalreboot(); /* remove the CD and reboot */
774
 
815
 
775
 Quit:
816
 Quit: