2 Copyright (C) Andrew Tridgell <genstruct@tridgell.net> 2002
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* these macros are needed for genstruct auto-parsers */
27 automatic marshalling/unmarshalling system for C structures
30 enum parse_type {T_INT, T_UNSIGNED, T_CHAR,
31 T_FLOAT, T_DOUBLE, T_ENUM, T_STRUCT,
32 T_TIME_T, T_LONG, T_ULONG};
34 /* flag to mark a fixed size array as actually being null terminated */
35 #define FLAG_NULLTERM 1
43 /* intermediate dumps are stored in one of these */
50 typedef int (*gen_dump_fn)(struct parse_string *, const char *ptr, unsigned indent);
51 typedef int (*gen_parse_fn)(char *ptr, const char *str);
53 /* genstruct.pl generates arrays of these */
60 const char *dynamic_len;
63 gen_parse_fn parse_fn;
66 char *gen_dump(const struct parse_struct *pinfo,
69 int gen_parse(const struct parse_struct *pinfo, char *data, const char *str0);
71 int gen_addgen(struct parse_string *p, const char *fmt, ...);
73 int gen_dump_enum(const struct enum_struct *einfo,
74 struct parse_string *p,
77 int gen_parse_enum(const struct enum_struct *einfo,
81 int gen_dump_struct(const struct parse_struct *pinfo,
82 struct parse_string *p,
85 int gen_parse_struct(const struct parse_struct *pinfo,
89 #define DUMP_PARSE_DECL(type) \
90 int gen_dump_ ## type(struct parse_string *, const char *, unsigned); \
91 int gen_parse_ ## type(char *, const char *);
95 DUMP_PARSE_DECL(unsigned)
96 DUMP_PARSE_DECL(double)
97 DUMP_PARSE_DECL(float)
99 #define gen_dump_unsigned_char gen_dump_char
100 #define gen_parse_unsigned_char gen_parse_char