WINGs: Added 'const' attribute to function 'WMCreateHashTable'
[wmaker-crm.git] / WINGs / menuparser.h
blobdbf78f99e358ac07a310f35b55de7ce6e219752e
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 struct {
48 /* Conditional text parsing is implemented using a stack of the
49 skip states for each nested #if */
50 int depth;
51 struct {
52 Bool skip;
53 char name[8];
54 int line;
55 } stack[32];
56 } cond;
57 char *rd;
58 char line_buffer[MAXLINE];
61 struct w_parser_macro {
62 WParserMacro *next;
63 char name[64];
64 WParserMacroFunction *function;
65 int arg_count;
66 #ifdef DEBUG
67 int usage_count;
68 #endif
69 unsigned char value[MAXLINE * 4];
72 Bool menu_parser_skip_spaces_and_comments(WMenuParser parser);
74 void menu_parser_register_preset_macros(WMenuParser parser);
76 void menu_parser_define_macro(WMenuParser parser);
78 void menu_parser_free_macros(WMenuParser parser);
80 WParserMacro *menu_parser_find_macro(WMenuParser parser, const char *name);
82 void menu_parser_expand_macro(WMenuParser parser, WParserMacro *macro);
84 int isnamechr(char ch); // Check if char is valid character for a macro name
86 #endif /* _MENUPARSER_H_INCLUDED */