ReactOS 0.4.16-dev-336-gb667d82
wpp.h File Reference
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for wpp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wpp_callbacks
 

Functions

int wpp_add_define (const char *name, const char *value)
 
void wpp_del_define (const char *name)
 
int wpp_add_cmdline_define (const char *value)
 
void wpp_set_debug (int lex_debug, int parser_debug, int msg_debug)
 
void wpp_set_pedantic (int on)
 
int wpp_add_include_path (const char *path)
 
charwpp_find_include (const char *name, const char *parent_name)
 
int wpp_parse (const char *input, FILE *output)
 
void wpp_set_callbacks (const struct wpp_callbacks *callbacks)
 

Function Documentation

◆ wpp_add_cmdline_define()

int wpp_add_cmdline_define ( const char value)

Definition at line 153 of file wpp.c.

154{
155 char *p;
156 char *str = pp_xstrdup(value);
157 if(!str)
158 return 1;
159 p = strchr( str, '=' );
160 if (p) *p++ = 0;
161 wpp_add_define( str, p );
162 free( str );
163 return 0;
164}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define free
Definition: debug_ros.c:5
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
GLfloat GLfloat p
Definition: glext.h:8902
const WCHAR * str
Definition: pdh_main.c:94
int wpp_add_define(const char *name, const char *value)
Definition: wpp.c:93

Referenced by main().

◆ wpp_add_define()

int wpp_add_define ( const char name,
const char value 
)

Definition at line 377 of file compiler.c.

378{
379 struct define *def;
380
381 if (!value) value = "";
382
383 for (def = cmdline_defines; def; def = def->next)
384 {
385 if (!strcmp( def->name, name ))
386 {
387 char *new_value = pp_xstrdup(value);
388 if(!new_value)
389 return 1;
390 free( def->value );
391 def->value = new_value;
392
393 return 0;
394 }
395 }
396
397 def = pp_xmalloc( sizeof(*def) );
398 if(!def)
399 return 1;
400 def->next = cmdline_defines;
401 def->name = pp_xstrdup(name);
402 if(!def->name)
403 {
404 free(def);
405 return 1;
406 }
407 def->value = pp_xstrdup(value);
408 if(!def->value)
409 {
410 free(def->name);
411 free(def);
412 return 1;
413 }
414 cmdline_defines = def;
415 return 0;
416}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static struct define * cmdline_defines
Definition: compiler.c:70
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
struct define * next
Definition: compiler.c:65
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66
Definition: name.c:39

Referenced by add_widl_version_define(), main(), preprocess_shader(), and wpp_add_cmdline_define().

◆ wpp_add_include_path()

int wpp_add_include_path ( const char path)

Definition at line 460 of file preproc.c.

461{
462 char *tok;
463 char *cpy = pp_xstrdup(path);
464 if(!cpy)
465 return 1;
466
467 tok = strtok(cpy, INCLUDESEPARATOR);
468 while(tok)
469 {
470 if(*tok) {
471 char *dir;
472 char *cptr;
473 char **new_path;
474
475 dir = pp_xstrdup(tok);
476 if(!dir)
477 {
478 free(cpy);
479 return 1;
480 }
481 for(cptr = dir; *cptr; cptr++)
482 {
483 /* Convert to forward slash */
484 if(*cptr == '\\')
485 *cptr = '/';
486 }
487 /* Kill eventual trailing '/' */
488 if(*(cptr = dir + strlen(dir)-1) == '/')
489 *cptr = '\0';
490
491 /* Add to list */
492 new_path = pp_xrealloc(includepath, (nincludepath+1) * sizeof(*includepath));
493 if(!new_path)
494 {
495 free(dir);
496 free(cpy);
497 return 1;
498 }
499 includepath = new_path;
501 nincludepath++;
502 }
504 }
505 free(cpy);
506 return 0;
507}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
unsigned int dir
Definition: maze.c:112
#define NULL
Definition: types.h:112
char * pp_xstrdup(const char *str)
Definition: preproc.c:105
#define INCLUDESEPARATOR
Definition: preproc.c:454
void * pp_xrealloc(void *p, size_t size)
Definition: preproc.c:91
static int nincludepath
Definition: preproc.c:458
static char ** includepath
Definition: preproc.c:457

Referenced by main().

◆ wpp_del_define()

void wpp_del_define ( const char name)

Definition at line 420 of file compiler.c.

421{
422 struct define *def;
423
424 for (def = cmdline_defines; def; def = def->next)
425 {
426 if (!strcmp( def->name, name ))
427 {
428 free( def->value );
429 def->value = NULL;
430 return;
431 }
432 }
433}

Referenced by preprocess_shader().

◆ wpp_find_include()

char * wpp_find_include ( const char name,
const char parent_name 
)

Definition at line 509 of file preproc.c.

510{
511 return wpp_default_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
512}
static char * wpp_default_lookup(const char *name, int type, const char *parent_name, char **include_path, int include_path_count)
Definition: preproc.c:118

Referenced by open_typelib().

◆ wpp_parse()

int wpp_parse ( const char input,
FILE output 
)

Definition at line 437 of file compiler.c.

438{
439 int ret;
440
444 pp_status.state = 0;
445
447 if(ret)
448 return ret;
451
452 if (!input) pp_status.file = stdin;
453 else if (!(pp_status.file = wpp_open(input, 1)))
454 {
455 ppy_error("Could not open %s\n", input);
459 return 2;
460 }
461
463
464 ppy_out = output;
465 pp_writestring("# 1 \"%s\" 1\n", input ? input : "");
466
467 ret = ppy_parse();
468 /* If there were errors during processing, return an error code */
470
471 if (input)
472 {
475 }
476 /* Clean if_stack, it could remain dirty on errors */
477 while (pp_get_if_depth()) pp_pop_if();
481 return ret;
482}
static void del_special_defines(void)
Definition: compiler.c:367
void * wpp_open(const char *filename, int type)
Definition: compiler.c:195
int WINAPIV ppy_error(const char *msg,...)
Definition: compiler.c:135
static void add_special_defines(void)
Definition: compiler.c:346
void wpp_close(void *file)
Definition: compiler.c:258
static void add_cmdline_defines(void)
Definition: compiler.c:326
static void del_cmdline_defines(void)
Definition: compiler.c:336
int pp_get_if_depth(void)
Definition: preproc.c:433
int pp_push_define_state(void)
Definition: preproc.c:148
void pp_pop_define_state(void)
Definition: preproc.c:161
pp_if_state_t pp_pop_if(void)
Definition: preproc.c:380
void WINAPIV int ppy_parse(void)
FILE * ppy_out
void WINAPIV pp_writestring(const char *format,...) __attribute__((format(printf
GLenum GLenum GLenum input
Definition: glext.h:9031
#define stdin
Definition: stdio.h:98
void * file
Definition: wpp_private.h:221
int char_number
Definition: wpp_private.h:223
char * input
Definition: wpp_private.h:220
int line_number
Definition: wpp_private.h:222
int ret

Referenced by main(), and preprocess_shader().

◆ wpp_set_callbacks()

void wpp_set_callbacks ( const struct wpp_callbacks callbacks)

Definition at line 232 of file wpp.c.

233{
235}
static int callbacks
Definition: xmllint.c:838

◆ wpp_set_debug()

void wpp_set_debug ( int  lex_debug,
int  parser_debug,
int  msg_debug 
)

Definition at line 168 of file wpp.c.

169{
170 pp_flex_debug = lex_debug;
172 pp_status.debug = msg_debug;
173}
int parser_debug
Definition: widl.c:111
int pp_flex_debug
Definition: wpp.c:31
int ppy_debug
Definition: wpp.c:31

Referenced by main().

◆ wpp_set_pedantic()

void wpp_set_pedantic ( int  on)

Definition at line 177 of file wpp.c.

178{
179 pp_status.pedantic = on;
180}
int pedantic
Definition: wpp_private.h:225