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,
46 int sgn; /* true if signed, false if unsigned */
50 extern struct type *new_type (enum type_enum, int, char *);
51 extern void free_type (struct type *);
54 decl_type_string, /* string foo<len>; (len is optional) */
55 decl_type_opaque_fixed, /* opaque foo[len]; */
56 decl_type_opaque_variable, /* opaque foo<len>; */
57 decl_type_simple, /* type ident; */
58 decl_type_fixed_array, /* type ident[len]; */
59 decl_type_variable_array, /* type ident<len>; (len is optional) */
60 decl_type_pointer, /* type *ident; */
64 enum decl_type decl_type;
65 struct type *type; /* NULL for string & opaque types. */
70 extern struct decl *new_decl (enum decl_type, struct type *, char *, char *);
71 extern void free_decl (struct decl *);
78 extern struct enum_value *new_enum_value (char *, char *);
79 extern void free_enum_value (struct enum_value *);
81 enum union_case_type {
82 union_case_normal, /* case const: decl; */
83 union_case_default_void, /* default: void; */
84 union_case_default_decl, /* default: decl; */
88 enum union_case_type type;
93 extern struct union_case *new_union_case (enum union_case_type, char *, struct decl *);
94 extern void free_union_case (struct union_case *);
96 typedef void (*free_fn) (void *);
99 struct cons *next; /* cdr/tail */
100 void *ptr; /* car/head */
101 free_fn free; /* free the head element */
104 extern struct cons *new_cons (struct cons *, void *, free_fn);
105 extern struct cons *list_rev (struct cons *);
106 extern void list_free (struct cons *);
108 /* Code generator functions. */
109 extern void gen_prologue (const char *filename);
110 extern void gen_epilogue (void);
111 extern void gen_const (const char *name, const char *value);
112 extern void gen_enum (const char *name, const struct cons *enum_values);
113 extern void gen_struct (const char *name, const struct cons *decls);
114 extern void gen_union (const char *name, const struct decl *discrim, const struct cons *union_cases);
115 extern void gen_typedef (const struct decl *decl);
117 /* Global functions used by the scanner. */
118 extern void start_string (void);
119 extern char *end_string (void);
120 extern void add_char (int);
121 extern void add_string (const char *);
123 /* These functions print an error and then exit. */
124 extern void error (const char *, ...)
125 __attribute__((noreturn, format(printf,1,2)));
126 extern void perrorf (const char *, ...)
127 __attribute__((noreturn, format(printf,1,2)));
129 /* Symbols exported from the scanner and parser. */
130 extern FILE *yyin, *yyout;
131 extern int yyparse (void);
135 #endif /* RPCGEN_INT_H */