/* * UBF(A) C writer data representation * Hal Snyder * $Id: ubf_a.h,v 1.7 2003/11/13 20:16:37 hal Exp $ */ #ifndef UBF_A_H #define UBF_A_H #if 0 #define ubfprintf(x) printf x #else #define ubfprintf(x) #endif #ifdef __cplusplus extern "C" { #endif typedef struct ubfa_term ubfa_term_t; /* * "ubfa_tag" and "ubfa_bin_data" are for internal use only, * between scanner and parser */ enum ubfa_type { ubfa_integer, ubfa_string, ubfa_binary, ubfa_const, ubfa_struct, ubfa_list, ubfa_empty, ubfa_tag, ubfa_bin_data }; typedef enum ubfa_type ubfa_type_t; /* data part is doubly linked list */ typedef struct ubfa_list_node ubfa_list_node_t; typedef struct ubfa_list ubfa_list_t; struct ubfa_list { ubfa_list_node_t * first; ubfa_list_node_t * last; }; union ubfa_data { long i; unsigned char *buf; ubfa_list_t list; }; typedef union ubfa_data ubfa_data_t; typedef unsigned char * ubfa_tag_t; /* * len is * number of octets for string, constant, tag, binary, bin_data * arity for struct and list */ struct ubfa_term { ubfa_type_t t; ubfa_tag_t g; ubfa_data_t d; unsigned int len; }; struct ubfa_list_node { ubfa_term_t term; ubfa_list_node_t * next; ubfa_list_node_t * prev; }; #ifdef __cplusplus } #endif /* ubf_a.c */ ubfa_term_t * new_ubfa_term_buf(ubfa_type_t t, int buf_len); ubfa_term_t * new_ubfa_term(ubfa_type_t t); ubfa_term_t * new_ubfa_empty(void); void ubfa_print(ubfa_term_t * u); ubfa_list_node_t * new_ubfa_list_node(void); #endif