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.
26 #include "rpcgen_int.h"
29 new_type (enum type_enum type, int sgn, char *ident)
31 struct type *r = malloc (sizeof *r);
39 free_type (struct type *t)
48 new_decl (enum decl_type decl_type, struct type *type,
49 char *ident, char *len)
51 struct decl *r = malloc (sizeof *r);
52 r->decl_type = decl_type;
60 free_decl (struct decl *d)
71 new_enum_value (char *ident, char *value)
73 struct enum_value *r = malloc (sizeof *r);
80 free_enum_value (struct enum_value *v)
90 new_union_case (enum union_case_type type, char *const_, struct decl *decl)
92 struct union_case *r = malloc (sizeof *r);
100 free_union_case (struct union_case *c)
110 new_cons (struct cons *next, void *ptr, free_fn free)
112 struct cons *r = malloc (sizeof *r);
120 list_rev_append (struct cons *xs1, struct cons *xs2)
122 if (!xs1) return xs2;
124 struct cons *tail = xs1->next;
126 return list_rev_append (tail, xs1);
131 list_rev (struct cons *xs)
133 return list_rev_append (xs, NULL);
137 list_free (struct cons *xs)
140 struct cons *next = xs->next;
141 if (xs->free) xs->free (xs->ptr);