clean up the "mess that was autoconf" so that various SAM backend's
[Samba.git] / source / aparser / parser.h
blob28317b9e0074d68caabb9e7823290b21ab3e5cd0
1 #include <ctype.h>
2 #include <stdio.h>
3 #include <malloc.h>
4 #include <unistd.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include "../include/byteorder.h"
9 #define PARSE_SCALARS (1<<0)
10 #define PARSE_BUFFERS (1<<1)
12 #ifndef MIN
13 #define MIN(a,b) ((a)<(b)?(a):(b))
14 #endif
16 #ifndef MAX
17 #define MAX(a,b) ((a)>(b)?(a):(b))
18 #endif
20 #define DEBUG(lvl, str) printf str;
21 #define DEBUGADD(lvl, str) printf str;
23 #define MARSHALL 0
24 #define UNMARSHALL 1
26 #define MARSHALLING(ps) (!(ps)->io)
27 #define UNMARSHALLING(ps) ((ps)->io)
29 typedef int BOOL;
30 typedef unsigned char uint8;
31 typedef unsigned char uchar;
32 typedef unsigned short uint16;
33 typedef unsigned short wchar;
34 typedef unsigned uint32;
35 typedef char *SMBSTR;
37 /* a null terminated unicode string */
38 typedef uint16 ZUSTRING;
40 #ifndef _PSTRING
42 #define PSTRING_LEN 1024
43 #define FSTRING_LEN 256
45 typedef char pstring[PSTRING_LEN];
46 typedef char fstring[FSTRING_LEN];
48 #define _PSTRING
50 #endif
51 #define False 0
52 #define True 1
54 /* zero a structure given a pointer to the structure */
55 #define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); }
57 #define MAX_UNISTRLEN 256
58 #define MAX_STRINGLEN 256
59 #define MAX_BUFFERLEN 512
61 typedef struct _io_struct
63 BOOL io; /* parsing in or out of data stream */
64 /*
65 * If the (incoming) data is big-endian. On output we are
66 * always little-endian.
67 */
68 BOOL bigendian_data;
69 BOOL is_dynamic; /* Do we own this memory or not ? */
70 BOOL autoalign; /* should we auto-align all elements? */
71 uint32 data_offset; /* Current working offset into data. */
72 uint32 buffer_size; /* Current size of the buffer. */
73 uint32 grow_size; /* size requested via io_grow() calls */
74 char *data_p; /* The buffer itself. */
75 } io_struct;
78 char *io_mem_get(io_struct *ps, uint32 extra_size);
79 BOOL io_init(io_struct *ps, uint32 size, BOOL io);
80 void io_debug(io_struct *ps, int depth, char *desc, char *fn_name);
81 BOOL io_align(io_struct *ps, int align);
82 BOOL io_align4(io_struct *ps, int align);
83 BOOL io_align2(io_struct *ps, int align);
84 BOOL io_read(io_struct *ps, int fd, size_t len, int timeout);
85 void dump_data(int level,char *buf1,int len);
86 BOOL io_alloc(char *name, io_struct *ps, void **ptr, unsigned size);
87 BOOL io_uint32(char *name, io_struct *ps, int depth, uint32 *data32, unsigned flags);
88 BOOL io_uint16(char *name, io_struct *ps, int depth, uint16 *data16, unsigned flags);
89 BOOL io_uint8(char *name, io_struct *ps, int depth, uint8 *data8, unsigned flags);
90 BOOL io_pointer(char *desc, io_struct *ps, int depth, void **p, unsigned flags);
91 BOOL io_SMBSTR(char *name, io_struct *ps, int depth, char **str, unsigned flags);
92 BOOL io_io_struct(char *name, io_struct *ps, int depth, io_struct *io, unsigned flags);
93 BOOL io_wstring(char *name, io_struct *ps, int depth, uint16 *data16s, int len, unsigned flags);
94 BOOL io_uint8s_fixed(char *name, io_struct *ps, int depth, uint8 *data8s, int len, unsigned flags);
95 BOOL io_uint8s(char *name, io_struct *ps, int depth, uint8 **data8s, int len, unsigned flags);
97 char *tab_depth(int depth);
98 void *Realloc(void *p,size_t size);
99 void dump_data(int level,char *buf1,int len);
100 void print_asc(int level, uchar const *buf, int len);
101 BOOL io_ZUSTRING(char *name, io_struct *ps, int depth, uint16 **ustr, unsigned flags);
102 size_t strlen_w(void *src);