/*  
   List functions -- these just maintain simple lists.
   something more funky needs to be done with the memory
   allocation.   This is all covered under the GNU General
   Public License.  Its free.
*/


#include "tr.h"
#include "li.h"
#include <stdio.h>

extern char *comment_buffer;
extern int comment_counter;

LInode *li_tail = (LInode *) 0;
LInode *li_head = (LInode *) 0;

void
LIadd (decl_spec, decl, decl_list)
     TRnode *decl_spec;
     TRnode *decl;
     TRnode *decl_list;
{
  LInode *linode;
  
  linode = (LInode *) malloc (sizeof (LInode));
  if (0 == linode)
    {
      fprintf (stderr, "Problem with memory in LIadd.\n");
      exit (4);
    }
  linode->decl_spec = decl_spec;
  linode->decl = decl;
  linode->decl_list = decl_list;

#ifdef nada
printf ("DELC_SPEC: "); output_tree (decl_spec);
printf ("\nDECL: "); output_tree (decl);
printf ("\nDECL_LIST: "); output_tree (decl_list);
#endif

  /*  Link it into the main list.  */
  if (li_tail == 0)
    {
      li_tail = linode;
      li_head = linode;
    }
  else
    {
      li_tail->next = linode;
      li_tail = linode;
    }

  if (comment_counter != 0)
    linode->comment = make_string (comment_buffer);
  else
    linode->comment = 0;

  linode->next = 0;
  return;
}
