/* $Id: ps_main.c,v 1.1.1.1 90/11/28 16:45:10 altenhof Exp $ */

/*
 * Copyright (C) 1990 by Digital Equipment Corporation.
 * 
 * Author: Michael P. Altenhofen, CEC Karlsruhe e-mail:
 * Altenhofen@kampus.enet.dec.com
 * 
 * This file ist part of Shared X
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation without fee is hereby granted, but only for non-profit  use
 * and distribution,  and provided  that the copyright notice and this notice
 * is preserved on all copies.
 * 
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#define PUBLIC extern

#include "initialize.h"
#include "osinit.h"
#include "cleanup.h"
#include "dispatch.h"

#undef PUBLIC

static int restart = 0;

main (argc, argv)
  int argc;
  char *argv[];
{
  int looping;
  long alwaysCheckForInput[2];

  /*
   * Notice if we're restart.  Probably this is because we jumped through
   * uninitialized pointer
   */
  if (restart)
    FatalError ("server restarted. Jumped through uninitialized pointer?\n");
  else
    restart = 1;

  /*
   * These are needed by some routines which are called from interrupt
   * handlers, thus have no direct calling path back to main and thus can't
   * be passed argc, argv as parameters
   */

  alwaysCheckForInput[0] = 0;
  alwaysCheckForInput[1] = 1;
  looping = 0;
  OsInit ();

  while (1) {
    Initialize (looping, argv, argc);
    Dispatch ();

    /* Now free up whatever must be freed */
    CleanUp ();

    looping = 1;
  }
}
