#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dir.h>

void main(void)
{
  char drive, s[256];
  FILE *f;

  drive=getdisk()+'A';

  if ((f=fopen("\\emtex\\cctinit.ini","w+t"))==NULL) {
    fprintf(stderr,"\nError: cannot create \"\\emtex\\cctinit.ini\"!\n");
  } else {
    fprintf(f,"-T%c:\\emtex\\tfm\n",drive);
    fprintf(f,"-H%c:\\emtex\\texinput\n",drive);
    fclose(f);
  }

  printf("\n---------------------------------------------------------------\n");
#if 0
  printf("Don't forget to add the following lines to C:\\AUTOEXEC.BAT:\n\n");
  printf("\tset EMTEXDIR=%c:\\EMTEX\n",drive);
  printf("\tset EMX=%c:\\EMTEX\\EMX.EXE\n",drive);
  printf("\tset RSX=%c:\\EMTEX\\RSX.EXE\n",drive);
  printf("and append %c:\\EMTEX to your PATH (see \\EMTEX\\SETENV.BAT)!\n",
         drive);
#else
  printf("Please add the following line to C:\\AUTOEXEC.BAT:\n\n");
  printf("\tcall %c:\\EMTEX\\SETENV.BAT\n", drive);
#endif
  printf("\nafter installation.\n");
  printf("---------------------------------------------------------------\n");

  if ((f=fopen("\\EMTEX\\SETENV.BAT","w+t"))==NULL) {
    fprintf(stderr,"\nError: cannot create \"\\EMTEX\\SETENV.BAT\"!\n");
  } else {
#if 0
    fprintf(f,"set PATH=%s;%c:\\EMTEX\n",getenv("PATH"),drive);
#else
    fprintf(f,"set PATH=%c:\\EMTEX;%%PATH%%\n", drive);
#endif
    fprintf(f,"set EMTEXDIR=%c:\\EMTEX\n",drive);
    fprintf(f,"set EMX=%c:\\EMTEX\\EMX.EXE\n",drive);
    fprintf(f,"set RSX=%c:\\EMTEX\\RSX.EXE\n",drive);
    fclose(f);
  }
  printf("Press Enter to continue...");
  gets(s);
}
