Remove dependency to CPP: support for #define macros
[wmaker-crm.git] / WINGs / menuparser.h
blobe7d101d18046abe80747c50b813de93934eaa313
1 /* menuparser.h
3 * Copyright (c) 2012 Christophe Curis
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef _MENUPARSER_H_INCLUDED
21 #define _MENUPARSER_H_INCLUDED
24 * This file is not part of WINGs public API
26 * It defines internal things for the Menu Parser, the public API is
27 * located in WINGs/WUtil.h as usual
30 #define MAXLINE 1024
31 #define MAX_NESTED_INCLUDES 16 // To avoid infinite includes case
32 #define MAX_NESTED_MACROS 24 // To avoid infinite loop inside macro expansions
33 #define MAX_MACRO_ARG_COUNT 32 // Limited by design
35 typedef struct w_parser_macro WParserMacro;
37 typedef void WParserMacroFunction(WParserMacro *this, WMenuParser parser);
39 struct w_menu_parser {
40 WMenuParser include_file;
41 WMenuParser parent_file;
42 const char *include_default_paths;
43 const char *file_name;
44 FILE *file_handle;
45 int line_number;
46 WParserMacro *macros;
47 char *rd;
48 char line_buffer[MAXLINE];
51 struct w_parser_macro {
52 WParserMacro *next;
53 char name[64];
54 WParserMacroFunction *function;
55 int arg_count;
56 #ifdef DEBUG
57 int usage_count;
58 #endif
59 unsigned char value[MAXLINE * 4];
62 Bool menu_parser_skip_spaces_and_comments(WMenuParser parser);
64 void menu_parser_define_macro(WMenuParser parser);
66 void menu_parser_free_macros(WMenuParser parser);
68 WParserMacro *menu_parser_find_macro(WMenuParser parser, const char *name);
70 void menu_parser_expand_macro(WMenuParser parser, WParserMacro *macro,
71 char *write_buf, int write_buf_size);
73 int isnamechr(char ch); // Check if char is valid character for a macro name
75 #endif /* _MENUPARSER_H_INCLUDED */