/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1987, 1991 by Mike Parker.			    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <stdio.h>

#if defined(vax) || defined(sgi) || defined(_AIX) || \
    (defined(VXWORKS_CFG) && !defined(VXWORKS_V5))
#define SIG_RETURN int
#else
#define SIG_RETURN void
#endif

#ifdef VXWORKS_CFG
#undef min
#undef max
#include "threaded-malloc.h"
#endif

char *malloc();
char *realloc();
#define NEW(t) ((t *) malloc(sizeof(t)))
#define OLD(x) free((char *)x)
#define free_if(x) if(x)free(x)

struct _tree {
  struct _tree *link;
  char *name;
  int n_recent;
  struct _key {
    struct _key *link;
    struct _tree *subtree;
    int number;
    char type;
#define KEY_NORMAL 1
#define KEY_I 2
#define KEY_R 3
#define KEY_S 4
#define KEY_V 5
#define KEY_X 6
#define KEY_O 7
#define KEY_D 8
    union {
      char c;
      struct {
	unsigned int min_addr : 1;
	unsigned int max_addr : 1;
	unsigned int isshort : 1;
	unsigned int islong : 1;
	unsigned int swept : 1; } s; } flags;
    union _key_limit {
      int i;
      int *ip;
      float f;
      float *fp; } min;
    union _key_limit max;
    int (*match_routine)();
    char *name;
    char *help;
    char *prompt; } *keys; };

struct _ind_chain {
  struct _ind_chain *link;
#ifdef VXWORKS_CFG
  /* VxWorks sometimes destroys stdin for us (how helpful).... */
  unsigned int noclose : 1;
#endif
  FILE *file; };

union _i_f {
  int i;
  double f; };

typedef struct _key KEY;
typedef union _key_limit KEY_LIMIT;
typedef struct _tree TREE;
typedef struct _ind_chain IND_CHAIN;
typedef union _i_f I_F;

extern TREE *_TMP_current_tree;
extern TREE *_TMP_named_tree_chain;
extern TREE *_TMP_tree_stack[64];
extern int _TMP_trees_stacked;

#if defined(vax)
#define MIN_INT 0x80000000
#define MAX_INT 0x7fffffff
#define MIN_FLOAT 0xffffffff
#define MAX_FLOAT 0xffff7fff
#endif
#if defined(sun) || defined(sgi) || defined(_AIX) || defined(linux)
#define MIN_INT 0x80000000
#define MAX_INT 0x7fffffff
#define MIN_FLOAT 0xff800000 /* IEEE -Inf */
#define MAX_FLOAT 0x7f800000 /* IEEE +Inf */
#endif
#define FtoI(f) (*(int *)&(f))
