/*
 *                   DATA STRUCTURES
 *                   ==== ==========
 *
 *                       FOR THE
 *                       === ===
 *
 *               DATA DECLARATION BUILDER
 *               ==== =========== =======
 *
 *      This module provides the internal structures needed
 *      for the data declaration builder.  It is itself the
 *      sort of output generated by the program.
 */


typedef char BOOL;

#define FALSE 0
#define TRUE  1

#define streq(a,b)	(strcmp((a),(b))==0)

struct declnlist;
typedef struct declnlist *declnlist;

struct shapelist;
typedef struct shapelist *shapelist;

struct paramlist;
typedef struct paramlist *paramlist;

struct printlist;
typedef struct printlist *printlist;

struct printitem;
typedef struct printitem *printitem;


#define printitem_is_str 0
#define printitem_is_num 1

struct printitem {
	int	tag;
	int	num;
	char	*str;
};


struct printlist {
	printlist	next;
	printitem	item;
};


struct paramlist {
        paramlist next;
        char      *type;
        char      *name;
	BOOL      dontfree;	/* exclude from freeing - eg shared ptr */
};


struct shapelist {
        shapelist next;
        char      *name;
        paramlist params;
	printlist pl;
};


struct declnlist {
        declnlist next;
        char      *name;
        shapelist shapes;
	BOOL	  ManyShapes, TagField, Struct, Union, UseNull, PutLoop;
};


typedef declnlist decln;		/* JUST THE FIRST */
typedef shapelist shape;		/* JUST THE FIRST */
typedef paramlist param;		/* JUST THE FIRST */


extern declnlist build_declnlist( char * name, shapelist s, declnlist next );
extern void print_declnlist( declnlist d );
extern shapelist build_shapelist( char * id, paramlist p, printlist pl, shapelist next );
extern void print_shape( shapelist s );
extern void print_shapelist( shapelist s );
extern paramlist build_paramlist( BOOL dontfree, char * type, char * id, paramlist next );
extern void print_paramlist( paramlist p );
extern printitem build_printitem_str( char * s );
extern printitem build_printitem_num( int n );
extern void print_printitem( printitem i );
extern printlist build_printlist( printitem h, printlist t );
extern void print_printlist( printlist p );
extern param findnthparam( int n, paramlist p, char * sname, char * dname );
