ws2_32/tests: Test calling ConnectEx() on a socket which is being accepted into.
[wine.git] / libs / wpp / wpp_private.h
blobfbcd3c00da7aba696c46adc6282bf584862d8e24
1 /*
2 * Copyright 1998 Bertho A. Stultiens (BS)
3 * Copyright 2002 Alexandre Julliard
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_WPP_PRIVATE_H
21 #define __WINE_WPP_PRIVATE_H
23 #include <stdio.h>
24 #include <string.h>
25 #include "wine/list.h"
27 struct pp_entry; /* forward */
29 * Include logic
30 * A stack of files which are already included and
31 * are protected in the #ifndef/#endif way.
33 typedef struct includelogicentry {
34 struct list entry;
35 struct pp_entry *ppp; /* The define which protects the file */
36 char *filename; /* The filename of the include */
37 } includelogicentry_t;
40 * The expansiontext of a macro
42 typedef enum {
43 exp_text, /* Simple text substitution */
44 exp_concat, /* Concat (##) operator requested */
45 exp_stringize, /* Stringize (#) operator requested */
46 exp_subst /* Substitute argument */
47 } def_exp_t;
49 typedef struct mtext {
50 struct mtext *next;
51 struct mtext *prev;
52 def_exp_t type;
53 union {
54 char *text;
55 int argidx; /* For exp_subst and exp_stringize reference */
56 } subst;
57 } mtext_t;
60 * The define descriptor
62 typedef enum {
63 def_none, /* Not-a-define; used as return value */
64 def_define, /* Simple defines */
65 def_macro, /* Macro defines */
66 def_special /* Special expansions like __LINE__ and __FILE__ */
67 } def_type_t;
69 typedef struct pp_entry {
70 struct list entry;
71 def_type_t type; /* Define or macro */
72 char *ident; /* The key */
73 char **margs; /* Macro arguments array or NULL if none */
74 int nargs;
75 union {
76 mtext_t *mtext; /* The substitution sequence or NULL if none */
77 char *text;
78 } subst;
79 int expanding; /* Set when feeding substitution into the input */
80 char *filename; /* Filename where it was defined */
81 int linenumber; /* Linenumber where it was defined */
82 includelogicentry_t *iep; /* Points to the include it protects */
83 } pp_entry_t;
87 * If logic
89 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
91 typedef enum {
92 if_false,
93 if_true,
94 if_elif,
95 if_elsefalse,
96 if_elsetrue,
97 if_ignore,
98 if_error
99 } pp_if_state_t;
103 * Trace the include files to prevent double reading.
104 * This save 20..30% of processing time for most stuff
105 * that uses complex includes.
106 * States:
107 * -1 Don't track or seen junk
108 * 0 New include, waiting for "#ifndef __xxx_h"
109 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
110 * 2 Seen #endif, waiting for EOF
112 typedef struct
114 int state;
115 char *ppp; /* The define to be set from the #ifndef */
116 int ifdepth; /* The level of ifs at the #ifdef */
117 int seen_junk; /* Set when junk is seen */
118 } include_state_t;
120 #define SIZE_INT 1
121 #define SIZE_LONG 2
122 #define SIZE_LONGLONG 3
123 #define SIZE_MASK 0x00ff
124 #define FLAG_SIGNED 0x0100
126 typedef enum {
127 cv_sint = SIZE_INT + FLAG_SIGNED,
128 cv_uint = SIZE_INT,
129 cv_slong = SIZE_LONG + FLAG_SIGNED,
130 cv_ulong = SIZE_LONG,
131 cv_sll = SIZE_LONGLONG + FLAG_SIGNED,
132 cv_ull = SIZE_LONGLONG
133 } ctype_t;
135 typedef struct cval {
136 ctype_t type;
137 union {
138 int si;
139 unsigned int ui;
140 long sl;
141 unsigned long ul;
142 __int64 sll;
143 unsigned __int64 ull;
144 } val;
145 } cval_t;
149 void *pp_xmalloc(size_t);
150 void *pp_xrealloc(void *, size_t);
151 char *pp_xstrdup(const char *str);
152 pp_entry_t *pplookup(const char *ident);
153 void pp_init_define_state(void);
154 void pp_free_define_state(void);
155 pp_entry_t *pp_add_define(const char *def, const char *text);
156 pp_entry_t *pp_add_macro(char *ident, char *args[], int nargs, mtext_t *exp);
157 void pp_del_define(const char *name);
158 void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
159 void pp_push_if(pp_if_state_t s);
160 void pp_next_if_state(int);
161 pp_if_state_t pp_pop_if(void);
162 pp_if_state_t pp_if_state(void);
163 int pp_get_if_depth(void);
164 char *wpp_lookup(const char *name, int type, const char *parent_name,
165 char **include_path, int include_path_count);
167 #ifndef __GNUC__
168 #define __attribute__(x) /*nothing*/
169 #endif
171 int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
172 int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
173 void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
175 /* current preprocessor state */
176 /* everything is in this structure to avoid polluting the global symbol space */
177 struct pp_status
179 char *input; /* current input file name */
180 FILE *file; /* current input file descriptor */
181 int line_number; /* current line number */
182 int char_number; /* current char number in line */
183 int pedantic; /* pedantic option */
184 int debug; /* debug messages flag */
187 extern struct pp_status pp_status;
188 extern include_state_t pp_incl_state;
189 extern struct list pp_includelogiclist;
192 * From ppl.l
194 extern FILE *ppy_in;
195 extern FILE *ppy_out;
196 extern char *ppy_text;
197 extern int pp_flex_debug;
198 int ppy_lex(void);
200 void pp_do_include(char *fname, int type);
201 void pp_push_ignore_state(void);
202 void pp_pop_ignore_state(void);
204 void pp_writestring(const char *format, ...) __attribute__((format (printf, 1, 2)));
207 * From ppy.y
209 int ppy_parse(void);
210 extern int ppy_debug;
212 #endif /* __WINE_WPP_PRIVATE_H */