
/* 
 * $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: tbu.c 1.1 90/01/19 $@(#)tbu.c	1.1 89/12/01"
#include <stdio.h>
#include "xsld.h"
#include <malloc.h>

extern char *gettxt();

/*
 * 'To be used' list processing
 */
typedef struct tbu {
  MODULE tbu_mo;
  struct tbu *tbu_next;
} TBU;

TBU *tbu_start;
TBU *tbu_end;

void
add_to_be_used(s)
  SYMBOL s;
{
  TBU *new;
  MODULE mo;
  
  mo = mo_defines(s);
  if ((new = (TBU *)malloc(sizeof(TBU))) == 0){
    fprintf(stderr, gettxt("xsld:42","Out of memory (tbu.c)\n"));
    fatal();
  }
  
  new->tbu_mo = mo;
  new->tbu_next = 0;
  
  if (tbu_end == 0)
    tbu_start = tbu_end = new;
  else {
    tbu_end->tbu_next = new;
    tbu_end = new;
  }
}

void
load_to_be_used()
{
  TBU *aux;
  
  while (tbu_start != 0){
    if (!mo_used(tbu_start->tbu_mo))
      use_module(tbu_start->tbu_mo);
    aux = tbu_start->tbu_next;
    free((char *)tbu_start);
    tbu_start = aux;
  }
  tbu_end = 0;
}
