ReactOS 0.4.16-dev-1946-g52006dd
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 588 of file wpp.c.

589{
590 char *p;
591 char *str = xstrdup(value);
592
593 p = strchr( str, '=' );
594 if (p) *p++ = 0;
595 wpp_add_define( str, p );
596 free( str );
597}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
char * xstrdup(const char *s)
Definition: uimain.c:768
#define free
Definition: debug_ros.c:5
GLfloat GLfloat p
Definition: glext.h:8902
const WCHAR * str
Definition: pdh_main.c:96
static void wpp_add_define(const char *name, const char *value)
Definition: wpp.c:547

Referenced by add_widl_version_define(), main(), and option_callback().

◆ 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
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66
struct define * next
Definition: compiler.c:65
Definition: name.c:39

Referenced by preprocess_shader().

◆ wpp_add_include_path()

int wpp_add_include_path ( const char path)

Definition at line 298 of file wpp.c.

299{
300 char *dir = xstrdup(path);
301 char *cptr;
302
303 for(cptr = dir; *cptr; cptr++)
304 {
305 /* Convert to forward slash */
306 if(*cptr == '\\')
307 *cptr = '/';
308 }
309 /* Kill eventual trailing '/' */
310 if(*(cptr = dir + strlen(dir)-1) == '/') *cptr = '\0';
311
313}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int dir
Definition: maze.c:112
static void strarray_add(struct strarray *array, const char *str)
Definition: tools.h:183
static struct strarray includes
Definition: wpp.c:57

Referenced by main(), and option_callback().

◆ 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}
#define NULL
Definition: types.h:112

◆ wpp_find_include()

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

Definition at line 315 of file wpp.c.

316{
317 return wpp_lookup(name, !!parent_name, parent_name);
318}
static char * wpp_lookup(const char *name, int type, const char *parent_name)
Definition: wpp.c:59

Referenced by find_input_file().

◆ 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
return ret
Definition: mutex.c:146
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

◆ wpp_set_callbacks()

void wpp_set_callbacks ( const struct wpp_callbacks callbacks)

◆ wpp_set_debug()

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

Definition at line 601 of file wpp.c.

602{
603 pp_flex_debug = lex_debug;
605 pp_status.debug = msg_debug;
606}
int parser_debug
Definition: widl.c:95
int pp_flex_debug
Definition: wpp.c:47
int ppy_debug
Definition: wpp.c:47

Referenced by main().

◆ wpp_set_pedantic()

void wpp_set_pedantic ( int  on)