ReactOS 0.4.15-dev-7924-g5949c20
wpp.c File Reference
#include "config.h"
#include "wine/port.h"
#include <time.h>
#include <stdlib.h>
#include "wpp_private.h"
#include "wine/wpp.h"
Include dependency graph for wpp.c:

Go to the source code of this file.

Classes

struct  define
 

Functions

static void add_cmdline_defines (void)
 
static void del_cmdline_defines (void)
 
static void add_special_defines (void)
 
static void del_special_defines (void)
 
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_parse (const char *input, FILE *output)
 
void wpp_set_callbacks (const struct wpp_callbacks *callbacks)
 

Variables

int ppy_debug
 
int pp_flex_debug
 
static struct definecmdline_defines
 

Function Documentation

◆ add_cmdline_defines()

static void add_cmdline_defines ( void  )
static

Definition at line 42 of file wpp.c.

43{
44 struct define *def;
45
46 for (def = cmdline_defines; def; def = def->next)
47 {
48 if (def->value) pp_add_define( def->name, def->value );
49 }
50}
pp_entry_t * pp_add_define(const char *def, const char *text)
Definition: preproc.c:194
struct define * next
Definition: compiler.c:65
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66
static struct define * cmdline_defines
Definition: wpp.c:40

Referenced by wpp_parse().

◆ add_special_defines()

static void add_special_defines ( void  )
static

Definition at line 62 of file wpp.c.

63{
65 pp_entry_t *ppp;
66 char buf[32];
67
68 strftime(buf, sizeof(buf), "\"%b %d %Y\"", localtime(&now));
69 pp_add_define( "__DATE__", buf );
70
71 strftime(buf, sizeof(buf), "\"%H:%M:%S\"", localtime(&now));
72 pp_add_define( "__TIME__", buf );
73
74 ppp = pp_add_define( "__FILE__", "" );
75 if(ppp)
76 ppp->type = def_special;
77
78 ppp = pp_add_define( "__LINE__", "" );
79 if(ppp)
80 ppp->type = def_special;
81}
#define NULL
Definition: types.h:112
@ def_special
Definition: wpp_private.h:92
__kernel_time_t time_t
Definition: linux.h:252
time_t now
Definition: finger.c:65
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__u16 time
Definition: mkdosfs.c:8
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:293
Definition: wpp_private.h:95
def_type_t type
Definition: wpp_private.h:98

Referenced by wpp_parse().

◆ del_cmdline_defines()

static void del_cmdline_defines ( void  )
static

Definition at line 52 of file wpp.c.

53{
54 struct define *def;
55
56 for (def = cmdline_defines; def; def = def->next)
57 {
58 if (def->value) pp_del_define( def->name );
59 }
60}
void pp_del_define(const char *name)
Definition: preproc.c:176

Referenced by wpp_parse().

◆ del_special_defines()

static void del_special_defines ( void  )
static

Definition at line 83 of file wpp.c.

84{
85 pp_del_define( "__DATE__" );
86 pp_del_define( "__TIME__" );
87 pp_del_define( "__FILE__" );
88 pp_del_define( "__LINE__" );
89}

Referenced by wpp_parse().

◆ 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 93 of file wpp.c.

94{
95 struct define *def;
96
97 if (!value) value = "";
98
99 for (def = cmdline_defines; def; def = def->next)
100 {
101 if (!strcmp( def->name, name ))
102 {
103 char *new_value = pp_xstrdup(value);
104 if(!new_value)
105 return 1;
106 free( def->value );
107 def->value = new_value;
108
109 return 0;
110 }
111 }
112
113 def = pp_xmalloc( sizeof(*def) );
114 if(!def)
115 return 1;
116 def->next = cmdline_defines;
117 def->name = pp_xstrdup(name);
118 if(!def->name)
119 {
120 free(def);
121 return 1;
122 }
123 def->value = pp_xstrdup(value);
124 if(!def->value)
125 {
126 free(def->name);
127 free(def);
128 return 1;
129 }
130 cmdline_defines = def;
131 return 0;
132}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
Definition: name.c:39

Referenced by wpp_add_cmdline_define().

◆ wpp_del_define()

void wpp_del_define ( const char name)

Definition at line 136 of file wpp.c.

137{
138 struct define *def;
139
140 for (def = cmdline_defines; def; def = def->next)
141 {
142 if (!strcmp( def->name, name ))
143 {
144 free( def->value );
145 def->value = NULL;
146 return;
147 }
148 }
149}

◆ wpp_parse()

int wpp_parse ( const char input,
FILE output 
)

Definition at line 184 of file wpp.c.

185{
186 int ret;
187
191 pp_status.state = 0;
192
194 if(ret)
195 return ret;
198
199 if (!input) pp_status.file = stdin;
200 else if (!(pp_status.file = wpp_callbacks->open(input, 1)))
201 {
202 ppy_error("Could not open %s\n", input);
206 return 2;
207 }
208
210
211 ppy_out = output;
212 pp_writestring("# 1 \"%s\" 1\n", input ? input : "");
213
214 ret = ppy_parse();
215 /* If there were errors during processing, return an error code */
217
218 if (input)
219 {
222 }
223 /* Clean if_stack, it could remain dirty on errors */
224 while (pp_get_if_depth()) pp_pop_if();
228 return ret;
229}
int WINAPIV ppy_error(const char *msg,...)
Definition: compiler.c:135
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
void *(* open)(const char *filename, int type)
Definition: wpp.h:38
void(* close)(void *file)
Definition: wpp.h:40
int ret
static void del_special_defines(void)
Definition: wpp.c:83
static void add_special_defines(void)
Definition: wpp.c:62
static void add_cmdline_defines(void)
Definition: wpp.c:42
static void del_cmdline_defines(void)
Definition: wpp.c:52

◆ 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

Variable Documentation

◆ cmdline_defines

struct define* cmdline_defines
static

Definition at line 40 of file wpp.c.

Referenced by add_cmdline_defines(), del_cmdline_defines(), wpp_add_define(), and wpp_del_define().

◆ pp_flex_debug

int pp_flex_debug

Definition at line 31 of file wpp.c.

Referenced by pp_pop_if(), pp_push_if(), and wpp_set_debug().

◆ ppy_debug

int ppy_debug

Definition at line 31 of file wpp.c.

Referenced by wpp_set_debug().