
/* 
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/
#ident "$Header: desc.c 1.1 90/01/19 $@(#)desc.c	1.1 89/12/01"
#include "xs.h"
#include "names.h"
#include "stack.h"
#include "types.h"
#include "anal.h"
#include "xdefs.h"
#include "catalog.h"
#include "mfile1.h"
#include "desc.h"

/*
 * Description file handling : Load contents and return TRUE if a name is
 * in the file
 */
static TYPEP FAKE; /* A NON null type */
static NAMETAB *desc_tab;

void
load_desc_file()
{
  FILE *fd;
  char buf[80];
  char *ptr;

  if (desc_file == 0)
    return;
    
  if ((fd = fopen(desc_file, "r")) == 0){
    perror(desc_file);
    desc_file = 0;
    return;
  }
  desc_tab = na_creat();

  while (fgets(buf, 80, fd) != NULL){
    if ((ptr = strchr(buf, ' ')) != 0)
      *ptr = '\0';
    else
      buf[strlen(buf) - 1] = '\0';
    (void)na_add(na_store(buf), desc_tab, FAKE);
  }
  fclose(fd);
}

bool
isin_desc(name)
  char *name;
{
  if (desc_file == 0)
    return FALSE;
  return !is_null_type(na_isin(desc_tab, name));
}
