fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / rsc / source / rscpp / cpp.h
blobe27a64d81246d0b3a5cc5b5bb87c194cd4d16309
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef TRUE
22 #define TRUE 1
23 #define FALSE 0
24 #endif
26 /* in cpp1.c: file-pointer auf stdout oder file */
27 extern FILE *pCppOut; /* BP */
28 #define PUTCHAR( d ) fprintf( pCppOut, "%c", (d) ) /* BP */
29 #if OSL_DEBUG_LEVEL > 1
30 extern FILE *pDefOut; /* ER */
31 #ifdef EVALDEFS
32 #define NEVALBUF 2048
33 #endif
34 #endif
36 /* limit for reading commandfiles */
37 #define PARALIMIT 100
39 #ifndef EOS
41 * This is predefined in Decus C
43 #define EOS '\0' /* End of string */
44 #endif
45 #define EOF_CHAR 0 /* Returned by get() on eof */
46 #define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
47 #define DEF_NOARGS (-1) /* #define foo vs #define foo() */
50 * The following may need to change if the host system doesn't use ASCII.
52 #define DEF_MAGIC 0x1D /* Magic for #defines */
53 #define TOK_SEP 0x1E /* Token concatenation delim. */
54 #define COM_SEP 0x1F /* Magic comment separator */
56 #ifdef EBCDIC
57 #define HT 0x05 /* horizontal tab */
58 #define NL 0x15 /* new line */
59 #define CR 0x0D /* carriage return */
60 #define DEL 0x07
61 #else
62 #define HT 0x09 /* horizontal tab */
63 #define NL 0x0A /* new line */
64 #define CR 0x0D /* carriage return */
65 #define DEL 0x7F
66 #endif
69 #ifdef SOLAR
70 #define MAC_PARM 0x01 /* Macro formals start here */
71 #else
73 * Note -- in Ascii, the following will map macro formals onto DEL + the
74 * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
75 * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
76 * value is reserved for string substitution.
79 #define MAC_PARM DEL /* Macro formals start here */
80 #if PAR_MAC >= 33
81 assertion fails -- PAR_MAC is not less than 33
82 #endif
83 #endif
84 #define LASTPARM (PAR_MAC - 1)
87 * Character type codes.
90 #define INV 0 /* Invalid, must be zero */
91 #define OP_EOE INV /* End of expression */
92 #define DIG 1 /* Digit */
93 #define LET 2 /* Identifier start */
94 #define FIRST_BINOP OP_ADD
95 #define OP_ADD 3
96 #define OP_SUB 4
97 #define OP_MUL 5
98 #define OP_DIV 6
99 #define OP_MOD 7
100 #define OP_ASL 8
101 #define OP_ASR 9
102 #define OP_AND 10 /* &, not && */
103 #define OP_OR 11 /* |, not || */
104 #define OP_XOR 12
105 #define OP_EQ 13
106 #define OP_NE 14
107 #define OP_LT 15
108 #define OP_LE 16
109 #define OP_GE 17
110 #define OP_GT 18
111 #define OP_ANA 19 /* && */
112 #define OP_ORO 20 /* || */
113 #define OP_QUE 21 /* ? */
114 #define OP_COL 22 /* : */
115 #define OP_CMA 23 /* , (relevant?) */
116 #define LAST_BINOP OP_CMA /* Last binary operand */
118 * The following are unary.
120 #define FIRST_UNOP OP_PLU /* First Unary operand */
121 #define OP_PLU 24 /* + (draft ANSI standard) */
122 #define OP_NEG 25 /* - */
123 #define OP_COM 26 /* ~ */
124 #define OP_NOT 27 /* ! */
125 #define LAST_UNOP OP_NOT
126 #define OP_LPA 28 /* ( */
127 #define OP_RPA 29 /* ) */
128 #define OP_END 30 /* End of expression marker */
129 #define OP_MAX (OP_END + 1) /* Number of operators */
130 #define OP_FAIL (OP_END + 1) /* For error returns */
133 * The following are for lexical scanning only.
136 #define QUO 65 /* Both flavors of quotation */
137 #define DOT 66 /* . might start a number */
138 #define SPA 67 /* Space and tab */
139 #define BSH 68 /* Just a backslash */
140 #define END 69 /* EOF */
143 * These bits are set in ifstack[]
145 #define WAS_COMPILING 1 /* TRUE if compile set at entry */
146 #define ELSE_SEEN 2 /* TRUE when #else processed */
147 #define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
150 * Define bits for the basic types and their adjectives
153 #define T_CHAR 1
154 #define T_INT 2
155 #define T_FLOAT 4
156 #define T_DOUBLE 8
157 #define T_SHORT 16
158 #define T_LONG 32
159 #define T_SIGNED 64
160 #define T_UNSIGNED 128
161 #define T_PTR 256 /* Pointer */
162 #define T_FPTR 512 /* Pointer to functions */
165 * The DEFBUF structure stores information about #defined
166 * macros. Note that the defbuf->repl information is always
167 * in malloc storage.
170 typedef struct defbuf {
171 struct defbuf *link; /* Next define in chain */
172 char *repl; /* -> replacement */
173 int hash; /* Symbol table hash */
174 int nargs; /* For define(args) */
175 char name[1]; /* #define name */
176 } DEFBUF;
179 * The FILEINFO structure stores information about open files
180 * and macros being expanded.
183 typedef struct fileinfo {
184 char *bptr; /* Buffer pointer */
185 int line; /* for include or macro */
186 FILE *fp; /* File if non-null */
187 struct fileinfo *parent; /* Link to includer */
188 char *filename; /* File/macro name */
189 char *progname; /* From #line statement */
190 unsigned int unrecur; /* For macro recursion */
191 char buffer[1]; /* current input line */
192 } FILEINFO;
195 * The SIZES structure is used to store the values for #if sizeof
198 typedef struct sizes {
199 short bits; /* If this bit is set, */
200 int size; /* this is the datum size value */
201 int psize; /* this is the pointer size */
202 } SIZES;
204 * nomacarg is a built-in #define on Decus C.
207 #ifdef nomacarg
208 #define cput output /* cput concatenates tokens */
209 #else
210 #if COMMENT_INVISIBLE
211 #define cput(c) { if (c != TOK_SEP && c != COM_SEP) PUTCHAR(c); }
212 #else
213 #define cput(c) { if (c != TOK_SEP) PUTCHAR(c); }
214 #endif
215 #endif
217 #ifndef nomacarg
218 #define streq(s1, s2) (strcmp(s1, s2) == 0)
219 #endif
222 * Error codes. VMS uses system definitions.
223 * Decus C codes are defined in stdio.h.
224 * Others are cooked to order.
227 #if HOST == SYS_VMS
228 #include <ssdef.h>
229 #include <stsdef.h>
230 #define IO_NORMAL (SS$_NORMAL | STS$M_INHIB_MSG)
231 #define IO_ERROR SS$_ABORT
232 #endif
234 * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
236 #ifndef IO_NORMAL
237 #define IO_NORMAL 0
238 #endif
239 #ifndef IO_ERROR
240 #define IO_ERROR 1
241 #endif
244 * Externs
247 extern int line; /* Current line number */
248 extern int wrongline; /* Force #line to cc pass 1 */
249 extern char type[]; /* Character classifier */
250 extern char token[IDMAX + 1]; /* Current input token */
251 extern int instring; /* TRUE if scanning string */
252 extern int inmacro; /* TRUE if scanning #define */
253 extern int errors; /* Error counter */
254 extern int recursion; /* Macro depth counter */
255 extern char ifstack[BLK_NEST]; /* #if information */
256 #define compiling ifstack[0]
257 extern char *ifptr; /* -> current ifstack item */
258 extern char *incdir[NINCLUDE]; /* -i directories */
259 extern char **incend; /* -> active end of incdir */
260 extern int cflag; /* -C option (keep comments) */
261 extern int eflag; /* -E option (ignore errors) */
262 extern int nflag; /* -N option (no pre-defines) */
263 extern int rec_recover; /* unwind recursive macros */
264 extern char *preset[]; /* Standard predefined symbols */
265 extern char *magic[]; /* Magic predefined symbols */
266 extern FILEINFO *infile; /* Current input file */
267 extern char work[NWORK + 1]; /* #define scratch */
268 extern char *workp; /* Free space in work */
269 #if OSL_DEBUG_LEVEL > 1
270 extern int debug; /* Debug level */
271 /* ER dump & evaluate #define's */
272 extern int bDumpDefs; /* TRUE if #define's dump req. */
273 extern int bIsInEval; /* TRUE if #define dumping now */
274 #ifdef EVALDEFS
275 extern char EvalBuf[NEVALBUF + 1]; /* evaluation buffer */
276 extern int nEvalOff; /* offset to free buffer pos */
277 #endif
278 #endif
279 extern int keepcomments; /* Don't remove comments if set */
280 extern SIZES size_table[]; /* For #if sizeof sizes */
282 #ifdef NOMAIN /* BP */
283 #ifndef _NO_PROTO
284 int rscpp_main( int argc, char **argv );
285 #endif
286 #define MAIN rscpp_main /* fuer die cpp.lib muss main() geandert werden */
287 #else
288 #ifdef WNT
289 #define MAIN __cdecl main
290 #else
291 #define MAIN main
292 #endif
293 #endif
296 void InitCpp1();
297 void InitCpp2();
298 void InitCpp3();
299 void InitCpp4();
300 void InitCpp5();
301 void InitCpp6();
303 #define HELLO() fprintf( stderr, "[Hello at %s, %d] ", __FILE__, __LINE__ )
305 #include <stdio.h>
306 #include <stdlib.h>
307 #include <string.h>
309 /* cpp1.c */
310 void output( int c );
311 void sharp();
312 void cppmain();
313 #if OSL_DEBUG_LEVEL > 1
314 #ifdef EVALDEFS
315 int outputEval( int c );
316 #endif
317 #endif
320 /* cpp2.c */
321 int control( int counter );
322 void doinclude();
323 void dodefine();
324 void doif( int hash );
325 int openinclude( char *, int );
326 int hasdirectory(char *, char * );
327 int openfile( char * );
329 /* cpp3.c */
330 int openfiles( char *filename );
331 void addfile( FILE *fp, char *filename );
332 void setincdirs();
333 int AddInclude( char *pIncStr );
334 int getredirection( int argc, char **argv );
335 void zap_uc( char *ap );
337 void initdefines();
338 int dooptions( int argc, char *argv[] );
339 int readoptions(char* filename, char*** pfargv);
341 /* cpp4.c */
342 void dodefines();
343 void checkparm( int c, DEFBUF *dp );
344 int expcollect();
345 void expstuff( DEFBUF *dp );
347 #if STRING_FORMAL
348 void stparmscan( int delim, DEFBUF *dp);
349 #else
350 void stparmscan( int delim);
351 #endif
352 #if OSL_DEBUG_LEVEL > 1
353 void dumpparm( char *why );
354 #endif
356 void doundef();
357 void textput( char *text );
358 void charput( int c );
359 void expand( DEFBUF *tokenp );
361 /* cpp5.c */
362 int eval();
363 int evallex(int);
364 int *evaleval(int *, int, int );
365 int evalchar(int);
366 int dosizeof();
367 int evalnum( int c );
368 int bittest( int );
370 /* cpp6.c */
372 void skipnl();
373 int skipws();
374 void scanid( int c );
375 int macroid( int c );
376 int catenate();
377 int scanstring( int c, void (*outfun)( int c ) );
378 void scannumber( int c, void (*outfun)( int c ) );
379 void save( int c );
380 char *savestring( char *text );
381 FILEINFO *getfile( int bufsize, char *name);
382 char *getmem( int size );
383 DEFBUF *lookid( int c );
384 DEFBUF *defendel( char *name, int delete );
385 void dunpdef( char *why );
386 void dumpadef( char *why, DEFBUF *dp);
387 int get();
388 int cget();
389 void unget();
390 void ungetstring( char *text );
391 void cerror( char *format, char *sarg);
392 void cwarn( char *format, char *sarg);
393 void cfatal( char *format, char *sarg);
394 void cierror( char *format, int n);
395 void ciwarn( char *format, int n);
396 #if OSL_DEBUG_LEVEL > 1
397 void dumpdef( char *why );
398 void dumpadef( char *why, DEFBUF *dp );
399 #endif
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */