/* dawg_challenge.c - use a dawg file to resolve a word game challenge */

/* Copyright (C) 1994 by John J. Chew, III <jjchew@math.utoronto.ca>
 * All rights reserved.
 * 
 * Usage: dawg_challenge dict.dawg word1 word2 ...
 *
 * Exits with status 0 if all words are acceptable, status 1 if at least
 * one is not, status 2 if an error occurs.
 */

/* based on Graham Toal's DAWG package, as posted to alt.sources */

/* Manadatory header files */
#include <stdio.h>
#include "splib.h"

int main(argc, argv)
  unsigned argc;
  char *argv[];
  {
  NODE *dawg;
  INDEX nedges;
  int i;

  if (argc < 3) exit(2);
  if (!dawg_init(argv[1], &dawg, &nedges)) exit(2);
  for (i=2; i<argc; i++)
    if (!dawg_check(dawg, argv[i])) exit(1);
  exit(0);
  }
