2 * rpcgen - Generate XDR bindings automatically.
3 * Copyright (C) 2008 Red Hat Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /* Current input file (updated by # line directives in the source). */
24 extern char *input_filename;
26 /* Current output file. */
27 extern const char *output_filename;
29 /* Current output mode. */
34 extern enum output_mode output_mode;
36 /* Abstract syntax tree types. */
38 type_char, type_short, type_int, type_hyper,
40 type_string, type_opaque, type_bool,
46 int sgn; /* true if signed, false if unsigned */
48 char *len; /* length (only for strings) */
51 extern struct type *new_type (enum type_enum, int, char *, char *);
52 extern void free_type (struct type *);
55 decl_type_simple, /* type ident; */
56 decl_type_fixed_array, /* type ident[len]; */
57 decl_type_variable_array, /* type ident<len>; (len is optional) */
58 decl_type_pointer, /* type *ident; */
62 enum decl_type decl_type;
68 extern struct decl *new_decl (enum decl_type, struct type *, char *, char *);
69 extern void free_decl (struct decl *);
76 extern struct enum_value *new_enum_value (char *, char *);
77 extern void free_enum_value (struct enum_value *);
79 enum union_case_type {
80 union_case_normal, /* case const: decl; */
81 union_case_default_void, /* default: void; */
82 union_case_default_decl, /* default: decl; */
86 enum union_case_type type;
91 extern struct union_case *new_union_case (enum union_case_type, char *, struct decl *);
92 extern void free_union_case (struct union_case *);
94 typedef void (*free_fn) (void *);
97 struct cons *next; /* cdr/tail */
98 void *ptr; /* car/head */
99 free_fn free; /* free the head element */
102 extern struct cons *new_cons (struct cons *, void *, free_fn);
103 extern struct cons *list_rev (struct cons *);
104 extern void list_free (struct cons *);
106 /* Code generator functions. */
107 extern void gen_prologue (const char *filename);
108 extern void gen_epilogue (void);
109 extern void gen_const (const char *name, const char *value);
110 extern void gen_enum (const char *name, const struct cons *enum_values);
111 extern void gen_struct (const char *name, const struct cons *decls);
112 extern void gen_union (const char *name, const struct decl *discrim, const struct cons *union_cases);
113 extern void gen_typedef (const struct decl *decl);
115 /* Global functions used by the scanner. */
116 extern void start_string (void);
117 extern char *end_string (void);
118 extern void add_char (int);
119 extern void add_string (const char *);
121 /* These functions print an error and then exit. */
122 extern void error (const char *, ...)
123 __attribute__((noreturn, format(printf,1,2)));
124 extern void perrorf (const char *, ...)
125 __attribute__((noreturn, format(printf,1,2)));
127 /* Symbols exported from the scanner and parser. */
128 extern FILE *yyin, *yyout;
129 extern int yyparse (void);
133 #endif /* RPCGEN_INT_H */