# include "opihi.h"

/******************/
int main (int argc, char **argv) {

  int i, Nbad, Nlist, status;
  char **list, *line, *outline, *prompt, *history;

  initialize (argc, argv);
  startup (argc, argv);
  prompt = get_variable("PROMPT");
  history = get_variable("HISTORY");
  welcome ();

  Nbad = 0;
  while (1) {  /** must exit with command "exit" or "quit" */
    if (Nbad == 10) exit (3);

    line = readline (prompt);
    if (line == NULL) {
      fprintf (stdout, "Use \"quit\" to exit\n");
      Nbad ++;
      continue;
    }
    Nbad = 0;

    stripwhite (line);
    if (*line) {
      list = multicommand (line, &Nlist);
      for (i = 0; i < Nlist; i++) {
	status = command (list[i], &outline);
	if (outline != NULL) free (outline);
      }
      add_history (line);
      append_history (1, history);
      free (line);
      free (list);
    }
    line = (char *) NULL;
  }
}

  /* this needs some work to use multicommand correctly 
     multicommand is currently a do-nothing function.  
     if we want multicommand to interact with the list/macro style commands, 
     we need a command to push all the elements of the line onto the command stack.
   */
