/**********************************************************************
 * tty lucy client using SS library
 *
 * $Author: brlewis $
 * $Source: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/main.c,v $
 * $Header: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/main.c,v 1.1 91/09/24 14:48:36 brlewis Exp Locker: brlewis $
 *
 * Copyright 1991 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 **********************************************************************/
#include <mit-copyright.h>

#ifndef lint
static char rcsid_main_c[] = "$Header: /afs/athena.mit.edu/astaff/project/lucydev/src/tty/main.c,v 1.1 91/09/24 14:48:36 brlewis Exp Locker: brlewis $";
#endif /* lint */

#include <stdio.h>
#include <ss/ss.h>
#include "lucy/lucy.h"
#include "config.h"

/*ARGSUSED*/
ignore_warning(code, buf)
     int code;
     char *buf;
{
  return;
}

main(argc, argv)
     int argc;
     char *argv[];
{
  long code;
  extern ss_request_table lucy_ct;
  int lucy_idx;

  if (getenv("XLOGIN")) set_warning_hook(ignore_warning);

  code = luc_init();
  if (code) {
    com_err(argv[0], code, "(%s)", luv_context);
    /* exit(1); except dsc_get_mtg_info returns bogus error? */
  }

  lucy_idx = ss_create_invocation("lucy", "", NULL, &lucy_ct, &code);
  if (code) {
    com_err(argv[0], code, "while initializing menu");
    exit(1);
  }

#ifdef LOG_USAGE
  log_startup(luv_curmtgp->info.long_name);
#endif

  if (argc > 1) {
    code = ss_execute_command(lucy_idx, &argv[1]);
  } else {
    printf("lucy version %s\n", LUCY_VERSION);

    /* check if non-lucy user */
    if (luv_curmtgp == &luv_bmtg)
      {
	printf("To browse lucy's answers, type this:  browse\n");
	printf("To ask a question, type this:         ask\n");
	printf("To quit, type this:                   quit\n");
      }

    ss_listen(lucy_idx, &code);
  }

  if (code) com_err(argv[0], code, "");
  exit(0);
}
