X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=rpcgen_int.h;h=92713263b180b71a91f87924d2da41ae5f3d389c;hb=1b9cc11ece64ac12f63e6c96e32b404b32fb0f32;hp=e37229581f97a01ac811f735e49e239e8da52f84;hpb=e9558f1dd242f2eb6a528c5509f1f8911fffe5d7;p=portablexdr.git diff --git a/rpcgen_int.h b/rpcgen_int.h index e372295..9271326 100644 --- a/rpcgen_int.h +++ b/rpcgen_int.h @@ -20,8 +20,98 @@ #ifndef RPCGEN_INT_H #define RPCGEN_INT_H +/* Current input file (updated by # line directives in the source). */ extern char *input_filename; +/* Current output file. */ +extern const char *output_filename; + +/* Current output mode. */ +enum output_mode { + output_c = 0, + output_h = 1, +}; +extern enum output_mode output_mode; + +/* Abstract syntax tree types. */ +enum type_enum { + type_char, type_short, type_int, type_hyper, + type_double, + type_string, type_opaque, type_bool, + type_ident, +}; + +struct type { + enum type_enum type; + int sgn; /* true if signed, false if unsigned */ + char *ident; + char *len; /* length (only for strings) */ +}; + +extern struct type *new_type (enum type_enum, int, char *, char *); +extern void free_type (struct type *); + +enum decl_type { + decl_type_simple, /* type ident; */ + decl_type_fixed_array, /* type ident[len]; */ + decl_type_variable_array, /* type ident; (len is optional) */ + decl_type_pointer, /* type *ident; */ +}; + +struct decl { + enum decl_type decl_type; + struct type *type; + char *ident; + char *len; +}; + +extern struct decl *new_decl (enum decl_type, struct type *, char *, char *); +extern void free_decl (struct decl *); + +struct enum_value { + char *ident; + char *value; +}; + +extern struct enum_value *new_enum_value (char *, char *); +extern void free_enum_value (struct enum_value *); + +enum union_case_type { + union_case_normal, /* case const: decl; */ + union_case_default_void, /* default: void; */ + union_case_default_decl, /* default: decl; */ +}; + +struct union_case { + enum union_case_type type; + char *const_; + struct decl *decl; +}; + +extern struct union_case *new_union_case (enum union_case_type, char *, struct decl *); +extern void free_union_case (struct union_case *); + +typedef void (*free_fn) (void *); + +struct cons { + struct cons *next; /* cdr/tail */ + void *ptr; /* car/head */ + free_fn free; /* free the head element */ +}; + +extern struct cons *new_cons (struct cons *, void *, free_fn); +extern struct cons *list_rev (struct cons *); +extern void list_free (struct cons *); + +/* Code generator functions. */ +extern void gen_prologue (const char *filename); +extern void gen_epilogue (void); +extern void gen_const (const char *name, const char *value); +extern void gen_enum (const char *name, const struct cons *enum_values); +extern void gen_struct (const char *name, const struct cons *decls); +extern void gen_union (const char *name, const struct decl *discrim, const struct cons *union_cases); +extern void gen_typedef (const struct decl *decl); + /* Global functions used by the scanner. */ extern void start_string (void); extern char *end_string (void); @@ -34,4 +124,10 @@ extern void error (const char *, ...) extern void perrorf (const char *, ...) __attribute__((noreturn, format(printf,1,2))); +/* Symbols exported from the scanner and parser. */ +extern FILE *yyin, *yyout; +extern int yyparse (void); +extern int yylineno; +extern int yydebug; + #endif /* RPCGEN_INT_H */