home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / misc / b186_1 / Source / c / main < prev    next >
Text File  |  1994-02-15  |  2KB  |  110 lines

  1. /*
  2.  
  3.        This file is part of the PDP software package.
  4.          
  5.        Copyright 1987 by James L. McClelland and David E. Rumelhart.
  6.        
  7.        Please refer to licensing information in the file license.txt,
  8.        which is in the same directory with this source file and is
  9.        included here by reference.
  10. */
  11.  
  12. /*
  13.     Just defines main() -- try command.c for the command interface.
  14.     
  15.     First version implemented by Elliot Jaffe.
  16.     
  17.     Date of last revision:  8-12-87/JLM.
  18. */
  19.  
  20. #include "general.h"
  21. #include "variable.h"
  22. #include "command.h"
  23. #include "patterns.h"
  24. #include "curses.h"
  25.  
  26. boolean    start_up = 1;
  27.  
  28. char    err_string[LINE_SIZE];
  29. char    prog_name[10];
  30. char  version[10] = "1.1";
  31.  
  32. main(argc, argv)
  33. int     argc;
  34. char  **argv;
  35. {
  36.  
  37.     char   *get_command ();
  38.     
  39.     get_progname();
  40.  
  41.     (void) srand(time(0));
  42.     random_seed = rand();
  43.     (void) srand(random_seed); /* we now have a restartable random seed */
  44.     init_general();
  45.     init_display();
  46.     init_system();
  47.  
  48.     start_up = 1;
  49.  
  50.     if (argc-- > 1) {
  51.         ++argv;
  52.     if (argv[0][0] == '-'){
  53.         /* user wants to skip the template file */
  54.     }
  55.     else if ((in_stream = fopen(*argv, "r")) == NULL) {
  56.         sprintf(err_string,"cannot open %s\n", *argv);
  57.         put_error(err_string);
  58.     }
  59.     else {
  60.         read_template();
  61.         fclose(in_stream);
  62.     }
  63.     if (argc-- > 1) {
  64.         if ((in_stream = fopen(*++argv, "r")) == NULL) {
  65.         sprintf(err_string,"cannot open %s\n", *argv);
  66.         put_error(err_string);
  67.         }
  68.         else {
  69.         while(! feof(in_stream))
  70.           do_command(Prompt, (int *) BASEMENU);
  71.         }
  72.         fclose(in_stream);
  73.     }
  74.     }
  75.  
  76.     if (!System_Defined && nunits > 0) {
  77.         (void) define_system();
  78.     }
  79.     
  80.     redisplay();    /* tests templates for validity */
  81.  
  82.     in_stream = stdin;
  83.  
  84.     start_up = 0;
  85.     
  86.     io_initscr();        /* initialize the screen */
  87.     printw("      Welcome to %s, a PDP program (Version %s).\n",
  88.             prog_name,version);
  89.     printw("Copyright 1987 by J. L. McClelland and D. E. Rumelhart.\n");
  90.     refresh();
  91.     sleep(3);
  92.     redisplay();        /* put up initial display */
  93.  
  94.     while (TRUE) {
  95.       do_command(Prompt, (int *) BASEMENU);
  96.     }
  97. }     
  98.  
  99. get_progname() {
  100.     int i;
  101.     
  102.     i = 0;
  103.     
  104.     while (Prompt[i] && Prompt[i] != ':') {
  105.         prog_name[i] = Prompt[i];
  106.     i++;
  107.     }
  108.     prog_name[i] = '\0';
  109. }
  110.