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, char *len)
31 struct type *r = malloc (sizeof *r);
40 free_type (struct type *t)
50 new_decl (enum decl_type decl_type, struct type *type,
51 char *ident, char *len)
53 struct decl *r = malloc (sizeof *r);
54 r->decl_type = decl_type;
62 free_decl (struct decl *d)
73 new_enum_value (char *ident, char *value)
75 struct enum_value *r = malloc (sizeof *r);
82 free_enum_value (struct enum_value *v)
92 new_union_case (enum union_case_type type, char *const_, struct decl *decl)
94 struct union_case *r = malloc (sizeof *r);
102 free_union_case (struct union_case *c)
112 new_cons (struct cons *next, void *ptr, free_fn free)
114 struct cons *r = malloc (sizeof *r);
122 list_rev_append (struct cons *xs1, struct cons *xs2)
124 if (!xs1) return xs2;
126 struct cons *tail = xs1->next;
128 return list_rev_append (tail, xs1);
133 list_rev (struct cons *xs)
135 return list_rev_append (xs, NULL);
139 list_free (struct cons *xs)
142 struct cons *next = xs->next;
143 if (xs->free) xs->free (xs->ptr);