/* Declarations for native C objects used by HAPI */

/* These refer to temporary string values which may be deallocated as
/* soon as the "receiving" program is through with them. */
typedef char *tmp_string;
typedef char bool; 

enum HAPI_TYPES {LIST=0, VERSION, SOURCE_ID, STRING, SYMBOL,
		     INFO_TUPLE=9, DELETE_TUPLE};

struct hapi_object {
    enum HAPI_TYPES type_tag;		/* == ? */
    int ref_count;
    int index;
};

struct hapi_list {
    enum HAPI_TYPES type_tag;		/* == 0 */
    int ref_count;
    int index;

    struct hapi_object *car;
    struct hapi_list *cdr;
};

struct version {
    enum HAPI_TYPES type_tag;		/* == 1 */
    int ref_count;
    int index;

    struct hapi_string *name;
    struct hapi_list *predecessors; /* a list of versions */
    int depth;
    struct hapi_list *tuples; /* every tuple directly defined in this
				 version */
};

struct source_id {
    enum HAPI_TYPES type_tag;		/* == 2 */
    int ref_count;
    int index;
};

struct hapi_string {
    enum HAPI_TYPES type_tag;		/* == 3 */
    int ref_count;
    int index;
    
    char *str;
};

struct hapi_symbol {
    /* This is just like a hapi_string, except that the string portions
       are much more likely to be == */
    enum HAPI_TYPES type_tag;		/* == 4 */
    int ref_count;
    int index;

    char *str;
};

struct info_tuple {
    enum HAPI_TYPES type_tag;		/* == 9 */
    int ref_count;
    int index;
    
    struct version *version;	/* not included in ref count */
    struct hapi_list *field_names;
    struct hapi_list *fields;
    int key_count;
};

struct delete_tuple {
    enum HAPI_TYPES type_tag;		/* == 10 */
    int ref_count;
    int index;
    
    struct version *version;	/* not included in ref count */
    struct hapi_list *field_names;
    struct hapi_list *fields;
    int key_count;
};

struct hapi_root {
    struct hapi_list *all_versions;
    struct hapi_list *all_symbols;
    int max_index;
};

extern bool ancestor_p (struct version *vers1, struct version *vers2);
extern bool hapi_eq (struct hapi_object *value1, struct hapi_object *value2);

