diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-17 06:52:02 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-17 06:52:02 +0000 |
commit | 36b934d241d2560be6693f90c9aba501a1ec0ae7 (patch) | |
tree | 39b57aa3bc373a967e4d1f7d29671226307294c8 /utils | |
parent | ca564287ee3f48945d45c7d92be7a83452f53745 (diff) | |
download | rockbox-36b934d241d2560be6693f90c9aba501a1ec0ae7.tar.gz rockbox-36b934d241d2560be6693f90c9aba501a1ec0ae7.zip |
Move the skin parser to a seperate library
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26877 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/parser/skin_debug.c | 262 | ||||
-rw-r--r-- | utils/themeeditor/parser/skin_debug.h | 48 | ||||
-rw-r--r-- | utils/themeeditor/parser/skin_parser.c | 923 | ||||
-rw-r--r-- | utils/themeeditor/parser/skin_parser.h | 138 | ||||
-rw-r--r-- | utils/themeeditor/parser/skin_scan.c | 218 | ||||
-rw-r--r-- | utils/themeeditor/parser/skin_scan.h | 44 | ||||
-rw-r--r-- | utils/themeeditor/parser/symbols.h | 49 | ||||
-rw-r--r-- | utils/themeeditor/parser/tag_table.c | 256 | ||||
-rw-r--r-- | utils/themeeditor/parser/tag_table.h | 307 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 29 |
10 files changed, 17 insertions, 2257 deletions
diff --git a/utils/themeeditor/parser/skin_debug.c b/utils/themeeditor/parser/skin_debug.c deleted file mode 100644 index 549f7b9e6c..0000000000 --- a/utils/themeeditor/parser/skin_debug.c +++ /dev/null | |||
@@ -1,262 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | #include "skin_parser.h" | ||
27 | #include "skin_debug.h" | ||
28 | #include "tag_table.h" | ||
29 | |||
30 | /* Global variables for debug output */ | ||
31 | int debug_indent_level = 0; | ||
32 | extern int skin_line; | ||
33 | |||
34 | /* Global error variables */ | ||
35 | int error_line; | ||
36 | char* error_message; | ||
37 | |||
38 | /* Debugging functions */ | ||
39 | void skin_error(enum skin_errorcode error) | ||
40 | { | ||
41 | |||
42 | error_line = skin_line; | ||
43 | |||
44 | switch(error) | ||
45 | { | ||
46 | case MEMORY_LIMIT_EXCEEDED: | ||
47 | error_message = "Memory limit exceeded"; | ||
48 | break; | ||
49 | case NEWLINE_EXPECTED: | ||
50 | error_message = "Newline expected"; | ||
51 | break; | ||
52 | case ILLEGAL_TAG: | ||
53 | error_message = "Illegal tag"; | ||
54 | break; | ||
55 | case ARGLIST_EXPECTED: | ||
56 | error_message = "Argument list expected"; | ||
57 | break; | ||
58 | case TOO_MANY_ARGS: | ||
59 | error_message = "Too many arguments given"; | ||
60 | break; | ||
61 | case DEFAULT_NOT_ALLOWED: | ||
62 | error_message = "Argument can not be set to default"; | ||
63 | break; | ||
64 | case UNEXPECTED_NEWLINE: | ||
65 | error_message = "Unexpected newline"; | ||
66 | break; | ||
67 | case INSUFFICIENT_ARGS: | ||
68 | error_message = "Not enough arguments"; | ||
69 | break; | ||
70 | case INT_EXPECTED: | ||
71 | error_message = "Expected integer"; | ||
72 | break; | ||
73 | case SEPERATOR_EXPECTED: | ||
74 | error_message = "Expected argument seperator"; | ||
75 | break; | ||
76 | case CLOSE_EXPECTED: | ||
77 | error_message = "Expected list close"; | ||
78 | break; | ||
79 | case MULTILINE_EXPECTED: | ||
80 | error_message = "Expected subline seperator"; | ||
81 | break; | ||
82 | }; | ||
83 | |||
84 | } | ||
85 | |||
86 | int skin_error_line() | ||
87 | { | ||
88 | return error_line; | ||
89 | } | ||
90 | |||
91 | char* skin_error_message() | ||
92 | { | ||
93 | return error_message; | ||
94 | } | ||
95 | |||
96 | void skin_clear_errors() | ||
97 | { | ||
98 | error_line = 0; | ||
99 | error_message = NULL; | ||
100 | } | ||
101 | |||
102 | void skin_debug_tree(struct skin_element* root) | ||
103 | { | ||
104 | int i; | ||
105 | char *text; | ||
106 | |||
107 | struct skin_element* current = root; | ||
108 | |||
109 | while(current) | ||
110 | { | ||
111 | skin_debug_indent(); | ||
112 | |||
113 | switch(current->type) | ||
114 | { | ||
115 | case UNKNOWN: | ||
116 | printf("[ Unknown element.. error\n]"); | ||
117 | break; | ||
118 | |||
119 | case VIEWPORT: | ||
120 | printf("[ Viewport \n"); | ||
121 | |||
122 | debug_indent_level++; | ||
123 | skin_debug_tree(current->children[0]); | ||
124 | debug_indent_level--; | ||
125 | |||
126 | printf("]"); | ||
127 | break; | ||
128 | |||
129 | case TEXT: | ||
130 | text = current->data; | ||
131 | printf("[ Plain text on line %d : %s ]\n", current->line, text); | ||
132 | break; | ||
133 | |||
134 | case COMMENT: | ||
135 | text = current->data; | ||
136 | printf("[ Comment on line %d: ", current->line); | ||
137 | for(i = 0; i < (int)strlen(text); i++) | ||
138 | { | ||
139 | if(text[i] == '\n') | ||
140 | printf("\\n"); | ||
141 | else | ||
142 | printf("%c", text[i]); | ||
143 | } | ||
144 | printf(" ]\n"); | ||
145 | break; | ||
146 | |||
147 | case TAG: | ||
148 | printf("[ %s tag on line %d with %d arguments\n", | ||
149 | current->tag->name, | ||
150 | current->line, current->params_count); | ||
151 | debug_indent_level++; | ||
152 | skin_debug_params(current->params_count, current->params); | ||
153 | debug_indent_level--; | ||
154 | skin_debug_indent(); | ||
155 | printf("]\n"); | ||
156 | |||
157 | break; | ||
158 | |||
159 | case SUBLINES: | ||
160 | printf("[ Alternator on line %d with %d sublines \n", current->line, | ||
161 | current->children_count); | ||
162 | debug_indent_level++; | ||
163 | for(i = 0; i < current->children_count; i++) | ||
164 | { | ||
165 | skin_debug_tree(current->children[i]); | ||
166 | } | ||
167 | debug_indent_level--; | ||
168 | |||
169 | skin_debug_indent(); | ||
170 | printf("]\n"); | ||
171 | break; | ||
172 | |||
173 | case CONDITIONAL: | ||
174 | printf("[ Conditional tag on line %d with %d enumerations \n", | ||
175 | current->line, current->children_count - 1); | ||
176 | debug_indent_level++; | ||
177 | |||
178 | skin_debug_indent(); | ||
179 | printf("[ Condition tag \n"); | ||
180 | debug_indent_level++; | ||
181 | skin_debug_tree(current->children[0]); | ||
182 | debug_indent_level--; | ||
183 | skin_debug_indent(); | ||
184 | printf("]\n"); | ||
185 | |||
186 | for(i = 1; i < current->children_count; i++) | ||
187 | { | ||
188 | skin_debug_indent(); | ||
189 | printf("[ Enumeration %d\n", i - 1); | ||
190 | debug_indent_level++; | ||
191 | skin_debug_tree(current->children[i]); | ||
192 | debug_indent_level--; | ||
193 | skin_debug_indent(); | ||
194 | printf("]\n"); | ||
195 | } | ||
196 | |||
197 | debug_indent_level--; | ||
198 | skin_debug_indent(); | ||
199 | printf("]\n"); | ||
200 | |||
201 | |||
202 | break; | ||
203 | |||
204 | case LINE: | ||
205 | printf("[ Logical line on line %d\n", current->line); | ||
206 | |||
207 | debug_indent_level++; | ||
208 | skin_debug_tree(current->children[0]); | ||
209 | debug_indent_level--; | ||
210 | |||
211 | skin_debug_indent(); | ||
212 | printf("]\n"); | ||
213 | break; | ||
214 | } | ||
215 | |||
216 | current = current->next; | ||
217 | } | ||
218 | |||
219 | } | ||
220 | |||
221 | void skin_debug_params(int count, struct skin_tag_parameter params[]) | ||
222 | { | ||
223 | int i; | ||
224 | for(i = 0; i < count; i++) | ||
225 | { | ||
226 | |||
227 | skin_debug_indent(); | ||
228 | switch(params[i].type) | ||
229 | { | ||
230 | case DEFAULT: | ||
231 | printf("[-]"); | ||
232 | break; | ||
233 | |||
234 | case STRING: | ||
235 | printf("[%s]", params[i].data.text); | ||
236 | break; | ||
237 | |||
238 | case NUMERIC: | ||
239 | printf("[%d]", params[i].data.numeric); | ||
240 | break; | ||
241 | |||
242 | case CODE: | ||
243 | printf("[ WPS Code: \n"); | ||
244 | debug_indent_level++; | ||
245 | skin_debug_tree(params[i].data.code); | ||
246 | debug_indent_level--; | ||
247 | skin_debug_indent(); | ||
248 | printf("]"); | ||
249 | break; | ||
250 | } | ||
251 | |||
252 | printf("\n"); | ||
253 | |||
254 | } | ||
255 | } | ||
256 | |||
257 | void skin_debug_indent() | ||
258 | { | ||
259 | int i; | ||
260 | for(i = 0; i < debug_indent_level; i++) | ||
261 | printf(" "); | ||
262 | } | ||
diff --git a/utils/themeeditor/parser/skin_debug.h b/utils/themeeditor/parser/skin_debug.h deleted file mode 100644 index a550dc4c7b..0000000000 --- a/utils/themeeditor/parser/skin_debug.h +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #ifndef SKIN_DEBUG_H | ||
24 | #define SKIN_DEBUG_H | ||
25 | |||
26 | #ifdef __cplusplus | ||
27 | extern "C" | ||
28 | { | ||
29 | #endif | ||
30 | |||
31 | #include "skin_parser.h" | ||
32 | |||
33 | /* Debugging functions */ | ||
34 | void skin_error(enum skin_errorcode error); | ||
35 | int skin_error_line(); | ||
36 | char* skin_error_message(); | ||
37 | void skin_clear_errors(); | ||
38 | void skin_debug_tree(struct skin_element* root); | ||
39 | |||
40 | /* Auxiliary debug functions */ | ||
41 | void skin_debug_params(int count, struct skin_tag_parameter params[]); | ||
42 | void skin_debug_indent(); | ||
43 | |||
44 | #ifdef __cplusplus | ||
45 | } | ||
46 | #endif | ||
47 | |||
48 | #endif // SKIN_DEBUG_H | ||
diff --git a/utils/themeeditor/parser/skin_parser.c b/utils/themeeditor/parser/skin_parser.c deleted file mode 100644 index 93a71919bf..0000000000 --- a/utils/themeeditor/parser/skin_parser.c +++ /dev/null | |||
@@ -1,923 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <stdio.h> | ||
24 | #include <string.h> | ||
25 | #include <ctype.h> | ||
26 | |||
27 | #include "skin_parser.h" | ||
28 | #include "skin_debug.h" | ||
29 | #include "tag_table.h" | ||
30 | #include "symbols.h" | ||
31 | #include "skin_scan.h" | ||
32 | |||
33 | #ifdef ROCKBOX | ||
34 | /* Declaration of parse tree buffer */ | ||
35 | #define SKIN_MAX_MEMORY (30*1024) | ||
36 | static char skin_parse_tree[SKIN_MAX_MEMORY]; | ||
37 | static char *skin_buffer; | ||
38 | #endif | ||
39 | |||
40 | /* Global variables for the parser */ | ||
41 | int skin_line = 0; | ||
42 | |||
43 | /* Auxiliary parsing functions (not visible at global scope) */ | ||
44 | static struct skin_element* skin_parse_viewport(char** document); | ||
45 | static struct skin_element* skin_parse_line(char** document); | ||
46 | static struct skin_element* skin_parse_line_optional(char** document, | ||
47 | int conditional); | ||
48 | static struct skin_element* skin_parse_sublines(char** document); | ||
49 | static struct skin_element* skin_parse_sublines_optional(char** document, | ||
50 | int conditional); | ||
51 | |||
52 | static int skin_parse_tag(struct skin_element* element, char** document); | ||
53 | static int skin_parse_text(struct skin_element* element, char** document, | ||
54 | int conditional); | ||
55 | static int skin_parse_conditional(struct skin_element* element, | ||
56 | char** document); | ||
57 | static int skin_parse_comment(struct skin_element* element, char** document); | ||
58 | static struct skin_element* skin_parse_code_as_arg(char** document); | ||
59 | |||
60 | struct skin_element* skin_parse(const char* document) | ||
61 | { | ||
62 | |||
63 | struct skin_element* root = NULL; | ||
64 | struct skin_element* last = NULL; | ||
65 | |||
66 | struct skin_element** to_write = 0; | ||
67 | |||
68 | char* cursor = (char*)document; /*Keeps track of location in the document*/ | ||
69 | #ifdef ROCKBOX | ||
70 | /* FIXME */ | ||
71 | skin_buffer = &skin_parse_tree[0]; | ||
72 | #endif | ||
73 | |||
74 | skin_line = 1; | ||
75 | |||
76 | skin_clear_errors(); | ||
77 | |||
78 | while(*cursor != '\0') | ||
79 | { | ||
80 | |||
81 | if(!root) | ||
82 | to_write = &root; | ||
83 | else | ||
84 | to_write = &(last->next); | ||
85 | |||
86 | |||
87 | *to_write = skin_parse_viewport(&cursor); | ||
88 | last = *to_write; | ||
89 | if(!last) | ||
90 | { | ||
91 | skin_free_tree(root); /* Clearing any memory already used */ | ||
92 | return NULL; | ||
93 | } | ||
94 | |||
95 | /* Making sure last is at the end */ | ||
96 | while(last->next) | ||
97 | last = last->next; | ||
98 | |||
99 | } | ||
100 | |||
101 | return root; | ||
102 | |||
103 | } | ||
104 | |||
105 | static struct skin_element* skin_parse_viewport(char** document) | ||
106 | { | ||
107 | |||
108 | struct skin_element* root = NULL; | ||
109 | struct skin_element* last = NULL; | ||
110 | struct skin_element* retval = NULL; | ||
111 | |||
112 | retval = skin_alloc_element(); | ||
113 | retval->type = VIEWPORT; | ||
114 | retval->children_count = 1; | ||
115 | retval->line = skin_line; | ||
116 | |||
117 | struct skin_element** to_write = 0; | ||
118 | |||
119 | char* cursor = *document; /* Keeps track of location in the document */ | ||
120 | char* bookmark; /* Used when we need to look ahead */ | ||
121 | |||
122 | int sublines = 0; /* Flag for parsing sublines */ | ||
123 | |||
124 | /* Parsing out the viewport tag if there is one */ | ||
125 | if(check_viewport(cursor)) | ||
126 | { | ||
127 | skin_parse_tag(retval, &cursor); | ||
128 | if(*cursor == '\n') | ||
129 | { | ||
130 | cursor++; | ||
131 | skin_line++; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | retval->children_count = 1; | ||
136 | retval->children = skin_alloc_children(1); | ||
137 | |||
138 | |||
139 | do | ||
140 | { | ||
141 | |||
142 | /* First, we check to see if this line will contain sublines */ | ||
143 | bookmark = cursor; | ||
144 | sublines = 0; | ||
145 | while(*cursor != '\n' && *cursor != '\0' | ||
146 | && !(check_viewport(cursor) && cursor != *document)) | ||
147 | { | ||
148 | if(*cursor == MULTILINESYM) | ||
149 | { | ||
150 | sublines = 1; | ||
151 | break; | ||
152 | } | ||
153 | else if(*cursor == TAGSYM) | ||
154 | { | ||
155 | /* A ';' directly after a '%' doesn't count */ | ||
156 | cursor ++; | ||
157 | |||
158 | if(*cursor == '\0') | ||
159 | break; | ||
160 | |||
161 | cursor++; | ||
162 | } | ||
163 | else if(*cursor == COMMENTSYM) | ||
164 | { | ||
165 | skip_comment(&cursor); | ||
166 | } | ||
167 | else if(*cursor == ARGLISTOPENSYM) | ||
168 | { | ||
169 | skip_arglist(&cursor); | ||
170 | } | ||
171 | else if(*cursor == ENUMLISTOPENSYM) | ||
172 | { | ||
173 | skip_enumlist(&cursor); | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | /* Advancing the cursor as normal */ | ||
178 | cursor++; | ||
179 | } | ||
180 | } | ||
181 | cursor = bookmark; | ||
182 | |||
183 | if(!root) | ||
184 | to_write = &root; | ||
185 | else | ||
186 | to_write = &(last->next); | ||
187 | |||
188 | if(sublines) | ||
189 | { | ||
190 | *to_write = skin_parse_sublines(&cursor); | ||
191 | last = *to_write; | ||
192 | if(!last) | ||
193 | return NULL; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | |||
198 | *to_write = skin_parse_line(&cursor); | ||
199 | last = *to_write; | ||
200 | if(!last) | ||
201 | return NULL; | ||
202 | |||
203 | } | ||
204 | |||
205 | /* Making sure last is at the end */ | ||
206 | while(last->next) | ||
207 | last = last->next; | ||
208 | |||
209 | if(*cursor == '\n') | ||
210 | { | ||
211 | cursor++; | ||
212 | skin_line++; | ||
213 | } | ||
214 | } | ||
215 | while(*cursor != '\0' && !(check_viewport(cursor) && cursor != *document)); | ||
216 | |||
217 | *document = cursor; | ||
218 | |||
219 | retval->children[0] = root; | ||
220 | return retval; | ||
221 | |||
222 | } | ||
223 | |||
224 | /* Auxiliary Parsing Functions */ | ||
225 | |||
226 | static struct skin_element* skin_parse_line(char**document) | ||
227 | { | ||
228 | |||
229 | return skin_parse_line_optional(document, 0); | ||
230 | |||
231 | } | ||
232 | |||
233 | |||
234 | /* | ||
235 | * If conditional is set to true, then this will break upon encountering | ||
236 | * SEPERATESYM. This should only be used when parsing a line inside a | ||
237 | * conditional, otherwise just use the wrapper function skin_parse_line() | ||
238 | */ | ||
239 | static struct skin_element* skin_parse_line_optional(char** document, | ||
240 | int conditional) | ||
241 | { | ||
242 | char* cursor = *document; | ||
243 | |||
244 | struct skin_element* root = NULL; | ||
245 | struct skin_element* current = NULL; | ||
246 | struct skin_element* retval = NULL; | ||
247 | |||
248 | /* A wrapper for the line */ | ||
249 | retval = skin_alloc_element(); | ||
250 | retval->type = LINE; | ||
251 | retval->line = skin_line; | ||
252 | if(*cursor != '\0' && *cursor != '\n' | ||
253 | && !(conditional && (*cursor == ARGLISTSEPERATESYM | ||
254 | || *cursor == ARGLISTCLOSESYM | ||
255 | || *cursor == ENUMLISTSEPERATESYM | ||
256 | || *cursor == ENUMLISTCLOSESYM))) | ||
257 | { | ||
258 | retval->children_count = 1; | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | retval->children_count = 0; | ||
263 | } | ||
264 | |||
265 | if(retval->children_count > 0) | ||
266 | retval->children = skin_alloc_children(1); | ||
267 | |||
268 | while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM | ||
269 | && !((*cursor == ARGLISTSEPERATESYM | ||
270 | || *cursor == ARGLISTCLOSESYM | ||
271 | || *cursor == ENUMLISTSEPERATESYM | ||
272 | || *cursor == ENUMLISTCLOSESYM) | ||
273 | && conditional) | ||
274 | && !(check_viewport(cursor) && cursor != *document)) | ||
275 | { | ||
276 | /* Allocating memory if necessary */ | ||
277 | if(root) | ||
278 | { | ||
279 | current->next = skin_alloc_element(); | ||
280 | current = current->next; | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | current = skin_alloc_element(); | ||
285 | root = current; | ||
286 | } | ||
287 | |||
288 | /* Parsing the current element */ | ||
289 | if(*cursor == TAGSYM && cursor[1] == CONDITIONSYM) | ||
290 | { | ||
291 | if(!skin_parse_conditional(current, &cursor)) | ||
292 | return NULL; | ||
293 | } | ||
294 | else if(*cursor == TAGSYM && !find_escape_character(cursor[1])) | ||
295 | { | ||
296 | if(!skin_parse_tag(current, &cursor)) | ||
297 | return NULL; | ||
298 | } | ||
299 | else if(*cursor == COMMENTSYM) | ||
300 | { | ||
301 | if(!skin_parse_comment(current, &cursor)) | ||
302 | return NULL; | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | if(!skin_parse_text(current, &cursor, conditional)) | ||
307 | return NULL; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | /* Moving up the calling function's pointer */ | ||
312 | *document = cursor; | ||
313 | |||
314 | if(root) | ||
315 | retval->children[0] = root; | ||
316 | return retval; | ||
317 | } | ||
318 | |||
319 | static struct skin_element* skin_parse_sublines(char** document) | ||
320 | { | ||
321 | return skin_parse_sublines_optional(document, 0); | ||
322 | } | ||
323 | |||
324 | static struct skin_element* skin_parse_sublines_optional(char** document, | ||
325 | int conditional) | ||
326 | { | ||
327 | struct skin_element* retval; | ||
328 | char* cursor = *document; | ||
329 | int sublines = 1; | ||
330 | int i; | ||
331 | |||
332 | retval = skin_alloc_element(); | ||
333 | retval->type = SUBLINES; | ||
334 | retval->next = NULL; | ||
335 | retval->line = skin_line; | ||
336 | |||
337 | /* First we count the sublines */ | ||
338 | while(*cursor != '\0' && *cursor != '\n' | ||
339 | && !((*cursor == ARGLISTSEPERATESYM | ||
340 | || *cursor == ARGLISTCLOSESYM | ||
341 | || *cursor == ENUMLISTSEPERATESYM | ||
342 | || *cursor == ENUMLISTCLOSESYM) | ||
343 | && conditional) | ||
344 | && !(check_viewport(cursor) && cursor != *document)) | ||
345 | { | ||
346 | if(*cursor == COMMENTSYM) | ||
347 | { | ||
348 | skip_comment(&cursor); | ||
349 | } | ||
350 | else if(*cursor == ENUMLISTOPENSYM) | ||
351 | { | ||
352 | skip_enumlist(&cursor); | ||
353 | } | ||
354 | else if(*cursor == ARGLISTOPENSYM) | ||
355 | { | ||
356 | skip_arglist(&cursor); | ||
357 | } | ||
358 | else if(*cursor == TAGSYM) | ||
359 | { | ||
360 | cursor++; | ||
361 | if(*cursor == '\0' || *cursor == '\n') | ||
362 | break; | ||
363 | cursor++; | ||
364 | } | ||
365 | else if(*cursor == MULTILINESYM) | ||
366 | { | ||
367 | sublines++; | ||
368 | cursor++; | ||
369 | } | ||
370 | else | ||
371 | { | ||
372 | cursor++; | ||
373 | } | ||
374 | } | ||
375 | |||
376 | /* ...and then we parse them */ | ||
377 | retval->children_count = sublines; | ||
378 | retval->children = skin_alloc_children(sublines); | ||
379 | |||
380 | cursor = *document; | ||
381 | for(i = 0; i < sublines; i++) | ||
382 | { | ||
383 | retval->children[i] = skin_parse_line_optional(&cursor, conditional); | ||
384 | skip_whitespace(&cursor); | ||
385 | |||
386 | if(*cursor != MULTILINESYM && i != sublines - 1) | ||
387 | { | ||
388 | skin_error(MULTILINE_EXPECTED); | ||
389 | return NULL; | ||
390 | } | ||
391 | else if(i != sublines - 1) | ||
392 | { | ||
393 | cursor++; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | *document = cursor; | ||
398 | |||
399 | return retval; | ||
400 | } | ||
401 | |||
402 | static int skin_parse_tag(struct skin_element* element, char** document) | ||
403 | { | ||
404 | |||
405 | char* cursor = *document + 1; | ||
406 | char* bookmark; | ||
407 | |||
408 | char tag_name[3]; | ||
409 | char* tag_args; | ||
410 | struct tag_info *tag; | ||
411 | |||
412 | int num_args = 1; | ||
413 | int i; | ||
414 | int star = 0; /* Flag for the all-or-none option */ | ||
415 | int req_args; /* To mark when we enter optional arguments */ | ||
416 | |||
417 | int optional = 0; | ||
418 | |||
419 | /* Checking the tag name */ | ||
420 | tag_name[0] = cursor[0]; | ||
421 | tag_name[1] = cursor[1]; | ||
422 | tag_name[2] = '\0'; | ||
423 | |||
424 | /* First we check the two characters after the '%', then a single char */ | ||
425 | tag = find_tag(tag_name); | ||
426 | |||
427 | if(!tag) | ||
428 | { | ||
429 | tag_name[1] = '\0'; | ||
430 | tag = find_tag(tag_name); | ||
431 | cursor++; | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | cursor += 2; | ||
436 | } | ||
437 | |||
438 | if(!tag) | ||
439 | { | ||
440 | skin_error(ILLEGAL_TAG); | ||
441 | return 0; | ||
442 | } | ||
443 | |||
444 | /* Copying basic tag info */ | ||
445 | if(element->type != CONDITIONAL && element->type != VIEWPORT) | ||
446 | element->type = TAG; | ||
447 | element->tag = tag; | ||
448 | tag_args = tag->params; | ||
449 | element->line = skin_line; | ||
450 | |||
451 | /* Checking for the * flag */ | ||
452 | if(tag_args[0] == '*') | ||
453 | { | ||
454 | star = 1; | ||
455 | tag_args++; | ||
456 | } | ||
457 | |||
458 | /* If this tag has no arguments, we can bail out now */ | ||
459 | if(strlen(tag_args) == 0 | ||
460 | || (tag_args[0] == '|' && *cursor != ARGLISTOPENSYM) | ||
461 | || (star && *cursor != ARGLISTOPENSYM)) | ||
462 | { | ||
463 | *document = cursor; | ||
464 | return 1; | ||
465 | } | ||
466 | |||
467 | /* Checking the number of arguments and allocating args */ | ||
468 | if(*cursor != ARGLISTOPENSYM && tag_args[0] != '|') | ||
469 | { | ||
470 | skin_error(ARGLIST_EXPECTED); | ||
471 | return 0; | ||
472 | } | ||
473 | else | ||
474 | { | ||
475 | cursor++; | ||
476 | } | ||
477 | |||
478 | bookmark = cursor; | ||
479 | while(*cursor != '\n' && *cursor != '\0' && *cursor != ARGLISTCLOSESYM) | ||
480 | { | ||
481 | /* Skipping over escaped characters */ | ||
482 | if(*cursor == TAGSYM) | ||
483 | { | ||
484 | cursor++; | ||
485 | if(*cursor == '\0') | ||
486 | break; | ||
487 | cursor++; | ||
488 | } | ||
489 | else if(*cursor == COMMENTSYM) | ||
490 | { | ||
491 | skip_comment(&cursor); | ||
492 | } | ||
493 | else if(*cursor == ARGLISTOPENSYM) | ||
494 | { | ||
495 | skip_arglist(&cursor); | ||
496 | } | ||
497 | else if(*cursor == ARGLISTSEPERATESYM) | ||
498 | { | ||
499 | num_args++; | ||
500 | cursor++; | ||
501 | } | ||
502 | else | ||
503 | { | ||
504 | cursor++; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | cursor = bookmark; /* Restoring the cursor */ | ||
509 | element->params_count = num_args; | ||
510 | element->params = skin_alloc_params(num_args); | ||
511 | |||
512 | /* Now we have to actually parse each argument */ | ||
513 | for(i = 0; i < num_args; i++) | ||
514 | { | ||
515 | /* Making sure we haven't run out of arguments */ | ||
516 | if(*tag_args == '\0') | ||
517 | { | ||
518 | skin_error(TOO_MANY_ARGS); | ||
519 | return 0; | ||
520 | } | ||
521 | |||
522 | /* Checking for the optional bar */ | ||
523 | if(*tag_args == '|') | ||
524 | { | ||
525 | optional = 1; | ||
526 | req_args = i; | ||
527 | tag_args++; | ||
528 | } | ||
529 | |||
530 | /* Scanning the arguments */ | ||
531 | skip_whitespace(&cursor); | ||
532 | |||
533 | |||
534 | /* Checking for comments */ | ||
535 | if(*cursor == COMMENTSYM) | ||
536 | skip_comment(&cursor); | ||
537 | |||
538 | /* Storing the type code */ | ||
539 | element->params[i].type_code = *tag_args; | ||
540 | |||
541 | /* Checking a nullable argument for null */ | ||
542 | if(*cursor == DEFAULTSYM && !isdigit(cursor[1])) | ||
543 | { | ||
544 | if(islower(*tag_args)) | ||
545 | { | ||
546 | element->params[i].type = DEFAULT; | ||
547 | cursor++; | ||
548 | } | ||
549 | else | ||
550 | { | ||
551 | skin_error(DEFAULT_NOT_ALLOWED); | ||
552 | return 0; | ||
553 | } | ||
554 | } | ||
555 | else if(tolower(*tag_args) == 'i') | ||
556 | { | ||
557 | /* Scanning an int argument */ | ||
558 | if(!isdigit(*cursor) && *cursor != '-') | ||
559 | { | ||
560 | skin_error(INT_EXPECTED); | ||
561 | return 0; | ||
562 | } | ||
563 | |||
564 | element->params[i].type = NUMERIC; | ||
565 | element->params[i].data.numeric = scan_int(&cursor); | ||
566 | } | ||
567 | else if(tolower(*tag_args) == 'n' || | ||
568 | tolower(*tag_args) == 's' || tolower(*tag_args) == 'f') | ||
569 | { | ||
570 | /* Scanning a string argument */ | ||
571 | element->params[i].type = STRING; | ||
572 | element->params[i].data.text = scan_string(&cursor); | ||
573 | |||
574 | } | ||
575 | else if(tolower(*tag_args) == 'c') | ||
576 | { | ||
577 | /* Recursively parsing a code argument */ | ||
578 | element->params[i].type = CODE; | ||
579 | element->params[i].data.code = skin_parse_code_as_arg(&cursor); | ||
580 | if(!element->params[i].data.code) | ||
581 | return 0; | ||
582 | } | ||
583 | |||
584 | skip_whitespace(&cursor); | ||
585 | |||
586 | if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1) | ||
587 | { | ||
588 | skin_error(SEPERATOR_EXPECTED); | ||
589 | return 0; | ||
590 | } | ||
591 | else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1) | ||
592 | { | ||
593 | skin_error(CLOSE_EXPECTED); | ||
594 | return 0; | ||
595 | } | ||
596 | else | ||
597 | { | ||
598 | cursor++; | ||
599 | } | ||
600 | |||
601 | if (*tag_args != 'N') | ||
602 | tag_args++; | ||
603 | |||
604 | /* Checking for the optional bar */ | ||
605 | if(*tag_args == '|') | ||
606 | { | ||
607 | optional = 1; | ||
608 | req_args = i + 1; | ||
609 | tag_args++; | ||
610 | } | ||
611 | |||
612 | } | ||
613 | |||
614 | /* Checking for a premature end */ | ||
615 | if(*tag_args != '\0' && !optional) | ||
616 | { | ||
617 | skin_error(INSUFFICIENT_ARGS); | ||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | *document = cursor; | ||
622 | |||
623 | return 1; | ||
624 | } | ||
625 | |||
626 | /* | ||
627 | * If the conditional flag is set true, then parsing text will stop at an | ||
628 | * ARGLISTSEPERATESYM. Only set that flag when parsing within a conditional | ||
629 | */ | ||
630 | static int skin_parse_text(struct skin_element* element, char** document, | ||
631 | int conditional) | ||
632 | { | ||
633 | char* cursor = *document; | ||
634 | int length = 0; | ||
635 | int dest; | ||
636 | char *text = NULL; | ||
637 | |||
638 | /* First figure out how much text we're copying */ | ||
639 | while(*cursor != '\0' && *cursor != '\n' && *cursor != MULTILINESYM | ||
640 | && *cursor != COMMENTSYM | ||
641 | && !((*cursor == ARGLISTSEPERATESYM | ||
642 | || *cursor == ARGLISTCLOSESYM | ||
643 | || *cursor == ENUMLISTSEPERATESYM | ||
644 | || *cursor == ENUMLISTCLOSESYM) | ||
645 | && conditional)) | ||
646 | { | ||
647 | /* Dealing with possibility of escaped characters */ | ||
648 | if(*cursor == TAGSYM) | ||
649 | { | ||
650 | if(find_escape_character(cursor[1])) | ||
651 | cursor++; | ||
652 | else | ||
653 | break; | ||
654 | } | ||
655 | |||
656 | length++; | ||
657 | cursor++; | ||
658 | } | ||
659 | |||
660 | cursor = *document; | ||
661 | |||
662 | /* Copying the text into the element struct */ | ||
663 | element->type = TEXT; | ||
664 | element->line = skin_line; | ||
665 | element->next = NULL; | ||
666 | element->data = text = skin_alloc_string(length); | ||
667 | |||
668 | for(dest = 0; dest < length; dest++) | ||
669 | { | ||
670 | /* Advancing cursor if we've encountered an escaped character */ | ||
671 | if(*cursor == TAGSYM) | ||
672 | cursor++; | ||
673 | |||
674 | text[dest] = *cursor; | ||
675 | cursor++; | ||
676 | } | ||
677 | text[length] = '\0'; | ||
678 | |||
679 | *document = cursor; | ||
680 | |||
681 | return 1; | ||
682 | } | ||
683 | |||
684 | static int skin_parse_conditional(struct skin_element* element, char** document) | ||
685 | { | ||
686 | |||
687 | char* cursor = *document + 1; /* Starting past the "%" */ | ||
688 | char* bookmark; | ||
689 | int children = 1; | ||
690 | int i; | ||
691 | |||
692 | element->type = CONDITIONAL; | ||
693 | element->line = skin_line; | ||
694 | |||
695 | /* Parsing the tag first */ | ||
696 | if(!skin_parse_tag(element, &cursor)) | ||
697 | return 0; | ||
698 | |||
699 | /* Counting the children */ | ||
700 | if(*(cursor++) != ENUMLISTOPENSYM) | ||
701 | { | ||
702 | skin_error(ARGLIST_EXPECTED); | ||
703 | return 0; | ||
704 | } | ||
705 | bookmark = cursor; | ||
706 | while(*cursor != ENUMLISTCLOSESYM && *cursor != '\n' && *cursor != '\0') | ||
707 | { | ||
708 | if(*cursor == COMMENTSYM) | ||
709 | { | ||
710 | skip_comment(&cursor); | ||
711 | } | ||
712 | else if(*cursor == ENUMLISTOPENSYM) | ||
713 | { | ||
714 | skip_enumlist(&cursor); | ||
715 | } | ||
716 | else if(*cursor == TAGSYM) | ||
717 | { | ||
718 | cursor++; | ||
719 | if(*cursor == '\0' || *cursor == '\n') | ||
720 | break; | ||
721 | cursor++; | ||
722 | } | ||
723 | else if(*cursor == ENUMLISTSEPERATESYM) | ||
724 | { | ||
725 | children++; | ||
726 | cursor++; | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | cursor++; | ||
731 | } | ||
732 | } | ||
733 | cursor = bookmark; | ||
734 | |||
735 | /* Parsing the children */ | ||
736 | element->children = skin_alloc_children(children); | ||
737 | element->children_count = children; | ||
738 | |||
739 | for(i = 0; i < children; i++) | ||
740 | { | ||
741 | element->children[i] = skin_parse_code_as_arg(&cursor); | ||
742 | skip_whitespace(&cursor); | ||
743 | |||
744 | if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM) | ||
745 | { | ||
746 | skin_error(SEPERATOR_EXPECTED); | ||
747 | return 0; | ||
748 | } | ||
749 | else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) | ||
750 | { | ||
751 | skin_error(CLOSE_EXPECTED); | ||
752 | return 0; | ||
753 | } | ||
754 | else | ||
755 | { | ||
756 | cursor++; | ||
757 | } | ||
758 | } | ||
759 | |||
760 | *document = cursor; | ||
761 | |||
762 | return 1; | ||
763 | } | ||
764 | |||
765 | static int skin_parse_comment(struct skin_element* element, char** document) | ||
766 | { | ||
767 | char* cursor = *document; | ||
768 | char* text = NULL; | ||
769 | |||
770 | int length; | ||
771 | /* | ||
772 | * Finding the index of the ending newline or null-terminator | ||
773 | * The length of the string of interest doesn't include the leading #, the | ||
774 | * length we need to reserve is the same as the index of the last character | ||
775 | */ | ||
776 | for(length = 0; cursor[length] != '\n' && cursor[length] != '\0'; length++); | ||
777 | |||
778 | element->type = COMMENT; | ||
779 | element->line = skin_line; | ||
780 | #ifdef ROCKBOX | ||
781 | element->data = NULL; | ||
782 | #else | ||
783 | element->data = text = skin_alloc_string(length); | ||
784 | /* We copy from one char past cursor to leave out the # */ | ||
785 | memcpy((void*)text, (void*)(cursor + 1), | ||
786 | sizeof(char) * (length-1)); | ||
787 | text[length - 1] = '\0'; | ||
788 | #endif | ||
789 | if(cursor[length] == '\n') | ||
790 | skin_line++; | ||
791 | |||
792 | *document += (length); /* Move cursor up past # and all text */ | ||
793 | if(**document == '\n') | ||
794 | (*document)++; | ||
795 | |||
796 | return 1; | ||
797 | } | ||
798 | |||
799 | static struct skin_element* skin_parse_code_as_arg(char** document) | ||
800 | { | ||
801 | |||
802 | int sublines = 0; | ||
803 | char* cursor = *document; | ||
804 | |||
805 | /* Checking for sublines */ | ||
806 | while(*cursor != '\n' && *cursor != '\0' | ||
807 | && *cursor != ENUMLISTSEPERATESYM && *cursor != ARGLISTSEPERATESYM | ||
808 | && *cursor != ENUMLISTCLOSESYM && *cursor != ARGLISTCLOSESYM) | ||
809 | { | ||
810 | if(*cursor == MULTILINESYM) | ||
811 | { | ||
812 | sublines = 1; | ||
813 | break; | ||
814 | } | ||
815 | else if(*cursor == TAGSYM) | ||
816 | { | ||
817 | /* A ';' directly after a '%' doesn't count */ | ||
818 | cursor ++; | ||
819 | |||
820 | if(*cursor == '\0') | ||
821 | break; | ||
822 | |||
823 | cursor++; | ||
824 | } | ||
825 | else if(*cursor == ARGLISTOPENSYM) | ||
826 | { | ||
827 | skip_arglist(&cursor); | ||
828 | } | ||
829 | else if(*cursor == ENUMLISTOPENSYM) | ||
830 | { | ||
831 | skip_enumlist(&cursor); | ||
832 | } | ||
833 | else | ||
834 | { | ||
835 | /* Advancing the cursor as normal */ | ||
836 | cursor++; | ||
837 | } | ||
838 | } | ||
839 | |||
840 | if(sublines) | ||
841 | return skin_parse_sublines_optional(document, 1); | ||
842 | else | ||
843 | return skin_parse_line_optional(document, 1); | ||
844 | } | ||
845 | |||
846 | |||
847 | /* Memory management */ | ||
848 | char* skin_alloc(size_t size) | ||
849 | { | ||
850 | #ifdef ROCKBOX | ||
851 | char *retval = skin_buffer; | ||
852 | skin_buffer = (void *)(((unsigned long)skin_buffer + 3) & ~3); | ||
853 | return retval; | ||
854 | #else | ||
855 | return malloc(size); | ||
856 | #endif | ||
857 | } | ||
858 | |||
859 | struct skin_element* skin_alloc_element() | ||
860 | { | ||
861 | struct skin_element* retval = (struct skin_element*) | ||
862 | skin_alloc(sizeof(struct skin_element)); | ||
863 | retval->type = UNKNOWN; | ||
864 | retval->next = NULL; | ||
865 | retval->tag = NULL; | ||
866 | retval->params_count = 0; | ||
867 | retval->children_count = 0; | ||
868 | |||
869 | return retval; | ||
870 | |||
871 | } | ||
872 | |||
873 | struct skin_tag_parameter* skin_alloc_params(int count) | ||
874 | { | ||
875 | size_t size = sizeof(struct skin_tag_parameter) * count; | ||
876 | return (struct skin_tag_parameter*)skin_alloc(size); | ||
877 | |||
878 | } | ||
879 | |||
880 | char* skin_alloc_string(int length) | ||
881 | { | ||
882 | return (char*)skin_alloc(sizeof(char) * (length + 1)); | ||
883 | } | ||
884 | |||
885 | struct skin_element** skin_alloc_children(int count) | ||
886 | { | ||
887 | return (struct skin_element**) | ||
888 | skin_alloc(sizeof(struct skin_element*) * count); | ||
889 | } | ||
890 | |||
891 | void skin_free_tree(struct skin_element* root) | ||
892 | { | ||
893 | #ifndef ROCKBOX | ||
894 | int i; | ||
895 | |||
896 | /* First make the recursive call */ | ||
897 | if(!root) | ||
898 | return; | ||
899 | skin_free_tree(root->next); | ||
900 | |||
901 | /* Free any text */ | ||
902 | if(root->type == TEXT || root->type == COMMENT) | ||
903 | free(root->data); | ||
904 | |||
905 | /* Then recursively free any children, before freeing their pointers */ | ||
906 | for(i = 0; i < root->children_count; i++) | ||
907 | skin_free_tree(root->children[i]); | ||
908 | if(root->children_count > 0) | ||
909 | free(root->children); | ||
910 | |||
911 | /* Free any parameters, making sure to deallocate strings */ | ||
912 | for(i = 0; i < root->params_count; i++) | ||
913 | if(root->params[i].type == STRING) | ||
914 | free(root->params[i].data.text); | ||
915 | if(root->params_count > 0) | ||
916 | free(root->params); | ||
917 | |||
918 | /* Finally, delete root's memory */ | ||
919 | free(root); | ||
920 | #else | ||
921 | (void)root; | ||
922 | #endif | ||
923 | } | ||
diff --git a/utils/themeeditor/parser/skin_parser.h b/utils/themeeditor/parser/skin_parser.h deleted file mode 100644 index 1fc4a7ae6b..0000000000 --- a/utils/themeeditor/parser/skin_parser.h +++ /dev/null | |||
@@ -1,138 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef GENERIC_PARSER_H | ||
23 | #define GENERIC_PARSER_H | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" | ||
27 | { | ||
28 | #endif | ||
29 | #include <stdlib.h> | ||
30 | |||
31 | /******************************************************************** | ||
32 | ****** Data Structures ********************************************* | ||
33 | *******************************************************************/ | ||
34 | |||
35 | /* Possible types of element in a WPS file */ | ||
36 | enum skin_element_type | ||
37 | { | ||
38 | UNKNOWN = -1, | ||
39 | VIEWPORT, | ||
40 | LINE, | ||
41 | SUBLINES, | ||
42 | CONDITIONAL, | ||
43 | TAG, | ||
44 | TEXT, | ||
45 | COMMENT, | ||
46 | }; | ||
47 | |||
48 | enum skin_errorcode | ||
49 | { | ||
50 | MEMORY_LIMIT_EXCEEDED, | ||
51 | NEWLINE_EXPECTED, | ||
52 | ILLEGAL_TAG, | ||
53 | ARGLIST_EXPECTED, | ||
54 | TOO_MANY_ARGS, | ||
55 | DEFAULT_NOT_ALLOWED, | ||
56 | UNEXPECTED_NEWLINE, | ||
57 | INSUFFICIENT_ARGS, | ||
58 | INT_EXPECTED, | ||
59 | SEPERATOR_EXPECTED, | ||
60 | CLOSE_EXPECTED, | ||
61 | MULTILINE_EXPECTED | ||
62 | }; | ||
63 | |||
64 | /* Holds a tag parameter, either numeric or text */ | ||
65 | struct skin_tag_parameter | ||
66 | { | ||
67 | enum | ||
68 | { | ||
69 | NUMERIC, | ||
70 | STRING, | ||
71 | CODE, | ||
72 | DEFAULT | ||
73 | } type; | ||
74 | |||
75 | union | ||
76 | { | ||
77 | int numeric; | ||
78 | char* text; | ||
79 | struct skin_element* code; | ||
80 | } data; | ||
81 | |||
82 | char type_code; | ||
83 | |||
84 | }; | ||
85 | |||
86 | /* Defines an element of a SKIN file */ | ||
87 | struct skin_element | ||
88 | { | ||
89 | /* Defines what type of element it is */ | ||
90 | enum skin_element_type type; | ||
91 | |||
92 | /* The line on which it's defined in the source file */ | ||
93 | int line; | ||
94 | |||
95 | /* Placeholder for element data | ||
96 | * TEXT and COMMENT uses it for the text string | ||
97 | * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage | ||
98 | */ | ||
99 | void* data; | ||
100 | |||
101 | /* The tag or conditional name */ | ||
102 | struct tag_info *tag; | ||
103 | |||
104 | /* Pointer to and size of an array of parameters */ | ||
105 | int params_count; | ||
106 | struct skin_tag_parameter* params; | ||
107 | |||
108 | /* Pointer to and size of an array of children */ | ||
109 | int children_count; | ||
110 | struct skin_element** children; | ||
111 | |||
112 | /* Link to the next element */ | ||
113 | struct skin_element* next; | ||
114 | }; | ||
115 | |||
116 | /*********************************************************************** | ||
117 | ***** Functions ******************************************************* | ||
118 | **********************************************************************/ | ||
119 | |||
120 | /* Parses a WPS document and returns a list of skin_element | ||
121 | structures. */ | ||
122 | struct skin_element* skin_parse(const char* document); | ||
123 | |||
124 | /* Memory management functions */ | ||
125 | char *skin_alloc(size_t size); | ||
126 | struct skin_element* skin_alloc_element(); | ||
127 | struct skin_element** skin_alloc_children(int count); | ||
128 | struct skin_tag_parameter* skin_alloc_params(int count); | ||
129 | char* skin_alloc_string(int length); | ||
130 | |||
131 | void skin_free_tree(struct skin_element* root); | ||
132 | |||
133 | |||
134 | #ifdef __cplusplus | ||
135 | } | ||
136 | #endif | ||
137 | |||
138 | #endif /* GENERIC_PARSER_H */ | ||
diff --git a/utils/themeeditor/parser/skin_scan.c b/utils/themeeditor/parser/skin_scan.c deleted file mode 100644 index 79f7162aab..0000000000 --- a/utils/themeeditor/parser/skin_scan.c +++ /dev/null | |||
@@ -1,218 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <ctype.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | |||
27 | #include "skin_scan.h" | ||
28 | #include "skin_debug.h" | ||
29 | #include "symbols.h" | ||
30 | #include "skin_parser.h" | ||
31 | |||
32 | /* Scanning Functions */ | ||
33 | |||
34 | /* Simple function to advance a char* past a comment */ | ||
35 | void skip_comment(char** document) | ||
36 | { | ||
37 | while(**document != '\n' && **document != '\0') | ||
38 | (*document)++; | ||
39 | if(**document == '\n') | ||
40 | (*document)++; | ||
41 | } | ||
42 | |||
43 | void skip_whitespace(char** document) | ||
44 | { | ||
45 | while(**document == ' ' || **document == '\t') | ||
46 | (*document)++; | ||
47 | } | ||
48 | |||
49 | void skip_arglist(char** document) | ||
50 | { | ||
51 | if(**document == ARGLISTOPENSYM) | ||
52 | (*document)++; | ||
53 | while(**document && **document != ARGLISTCLOSESYM) | ||
54 | { | ||
55 | if(**document == TAGSYM) | ||
56 | { | ||
57 | (*document)++; | ||
58 | if(**document == '\0') | ||
59 | break; | ||
60 | (*document)++; | ||
61 | } | ||
62 | else if(**document == ARGLISTOPENSYM) | ||
63 | skip_arglist(document); | ||
64 | else if(**document == ENUMLISTOPENSYM) | ||
65 | skip_enumlist(document); | ||
66 | else if(**document == COMMENTSYM) | ||
67 | skip_comment(document); | ||
68 | else | ||
69 | (*document)++; | ||
70 | } | ||
71 | if(**document == ARGLISTCLOSESYM) | ||
72 | (*document)++; | ||
73 | } | ||
74 | |||
75 | void skip_enumlist(char** document) | ||
76 | { | ||
77 | if(**document == ENUMLISTOPENSYM) | ||
78 | (*document)++; | ||
79 | while(**document && **document != ENUMLISTCLOSESYM) | ||
80 | { | ||
81 | if(**document == TAGSYM) | ||
82 | { | ||
83 | (*document)++; | ||
84 | if(**document == '\0') | ||
85 | break; | ||
86 | (*document)++; | ||
87 | } | ||
88 | else if(**document == ARGLISTOPENSYM) | ||
89 | skip_arglist(document); | ||
90 | else if(**document == ENUMLISTOPENSYM) | ||
91 | skip_enumlist(document); | ||
92 | else if(**document == COMMENTSYM) | ||
93 | skip_comment(document); | ||
94 | else | ||
95 | (*document)++; | ||
96 | } | ||
97 | |||
98 | if(**document == ENUMLISTCLOSESYM) | ||
99 | (*document)++; | ||
100 | } | ||
101 | |||
102 | char* scan_string(char** document) | ||
103 | { | ||
104 | |||
105 | char* cursor = *document; | ||
106 | int length = 0; | ||
107 | char* buffer = NULL; | ||
108 | int i; | ||
109 | |||
110 | while(*cursor != ARGLISTSEPERATESYM && *cursor != ARGLISTCLOSESYM && | ||
111 | *cursor != '\0') | ||
112 | { | ||
113 | if(*cursor == COMMENTSYM) | ||
114 | { | ||
115 | skip_comment(&cursor); | ||
116 | continue; | ||
117 | } | ||
118 | |||
119 | if(*cursor == TAGSYM) | ||
120 | cursor++; | ||
121 | |||
122 | if(*cursor == '\n') | ||
123 | { | ||
124 | skin_error(UNEXPECTED_NEWLINE); | ||
125 | return NULL; | ||
126 | } | ||
127 | |||
128 | length++; | ||
129 | cursor++; | ||
130 | } | ||
131 | |||
132 | /* Copying the string */ | ||
133 | cursor = *document; | ||
134 | buffer = skin_alloc_string(length); | ||
135 | buffer[length] = '\0'; | ||
136 | for(i = 0; i < length; i++) | ||
137 | { | ||
138 | if(*cursor == TAGSYM) | ||
139 | cursor++; | ||
140 | |||
141 | if(*cursor == COMMENTSYM) | ||
142 | { | ||
143 | skip_comment(&cursor); | ||
144 | i--; | ||
145 | continue; | ||
146 | } | ||
147 | |||
148 | buffer[i] = *cursor; | ||
149 | cursor++; | ||
150 | } | ||
151 | |||
152 | *document = cursor; | ||
153 | return buffer; | ||
154 | } | ||
155 | |||
156 | int scan_int(char** document) | ||
157 | { | ||
158 | |||
159 | char* cursor = *document, *end; | ||
160 | int length = 0; | ||
161 | char buffer[16]; | ||
162 | int retval; | ||
163 | int i; | ||
164 | |||
165 | while(isdigit(*cursor) || *cursor == COMMENTSYM || *cursor == '-') | ||
166 | { | ||
167 | if(*cursor == COMMENTSYM) | ||
168 | { | ||
169 | skip_comment(&cursor); | ||
170 | continue; | ||
171 | } | ||
172 | |||
173 | length++; | ||
174 | cursor++; | ||
175 | } | ||
176 | if (length > 15) | ||
177 | length = 15; | ||
178 | end = cursor; | ||
179 | /* Copying to the buffer while avoiding comments */ | ||
180 | cursor = *document; | ||
181 | buffer[length] = '\0'; | ||
182 | for(i = 0; i < length; i++) | ||
183 | { | ||
184 | if(*cursor == COMMENTSYM) | ||
185 | { | ||
186 | skip_comment(&cursor); | ||
187 | i--; | ||
188 | continue; | ||
189 | } | ||
190 | |||
191 | buffer[i] = *cursor; | ||
192 | cursor++; | ||
193 | |||
194 | } | ||
195 | retval = atoi(buffer); | ||
196 | |||
197 | *document = end; | ||
198 | return retval; | ||
199 | } | ||
200 | |||
201 | int check_viewport(char* document) | ||
202 | { | ||
203 | if(strlen(document) < 3) | ||
204 | return 0; | ||
205 | |||
206 | if(document[0] != TAGSYM) | ||
207 | return 0; | ||
208 | |||
209 | if(document[1] != 'V') | ||
210 | return 0; | ||
211 | |||
212 | if(document[2] != ARGLISTOPENSYM | ||
213 | && document[2] != 'l' | ||
214 | && document[2] != 'i') | ||
215 | return 0; | ||
216 | |||
217 | return 1; | ||
218 | } | ||
diff --git a/utils/themeeditor/parser/skin_scan.h b/utils/themeeditor/parser/skin_scan.h deleted file mode 100644 index b1d04a6e34..0000000000 --- a/utils/themeeditor/parser/skin_scan.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef SCANNING_H | ||
23 | #define SCANNING_H | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" | ||
27 | { | ||
28 | #endif | ||
29 | |||
30 | |||
31 | /* Scanning functions */ | ||
32 | void skip_comment(char** document); | ||
33 | void skip_whitespace(char** document); | ||
34 | void skip_arglist(char** document); | ||
35 | void skip_enumlist(char** document); | ||
36 | char* scan_string(char** document); | ||
37 | int scan_int(char** document); | ||
38 | int check_viewport(char* document); /* Checks for a viewport declaration */ | ||
39 | |||
40 | #ifdef __cplusplus | ||
41 | } | ||
42 | #endif | ||
43 | |||
44 | #endif // SCANNING_H | ||
diff --git a/utils/themeeditor/parser/symbols.h b/utils/themeeditor/parser/symbols.h deleted file mode 100644 index b4f31289ef..0000000000 --- a/utils/themeeditor/parser/symbols.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef SYMBOLS_H | ||
23 | #define SYMBOLS_H | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" | ||
27 | { | ||
28 | #endif | ||
29 | |||
30 | |||
31 | /* Symbol definitions for WPS parsing */ | ||
32 | |||
33 | #define TAGSYM '%' | ||
34 | #define COMMENTSYM '#' | ||
35 | #define CONDITIONSYM '?' | ||
36 | #define MULTILINESYM ';' | ||
37 | #define ARGLISTOPENSYM '(' | ||
38 | #define ARGLISTCLOSESYM ')' | ||
39 | #define ARGLISTSEPERATESYM ',' | ||
40 | #define ENUMLISTSEPERATESYM '|' | ||
41 | #define ENUMLISTOPENSYM '<' | ||
42 | #define ENUMLISTCLOSESYM '>' | ||
43 | #define DEFAULTSYM '-' | ||
44 | |||
45 | #ifdef __cplusplus | ||
46 | } | ||
47 | #endif | ||
48 | |||
49 | #endif /* SYMBOLS_H */ | ||
diff --git a/utils/themeeditor/parser/tag_table.c b/utils/themeeditor/parser/tag_table.c deleted file mode 100644 index 6d82b47cc3..0000000000 --- a/utils/themeeditor/parser/tag_table.c +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "tag_table.h" | ||
23 | |||
24 | #include <string.h> | ||
25 | #define BAR_PARAMS "*|iiiiN" | ||
26 | /* The tag definition table */ | ||
27 | struct tag_info legal_tags[] = | ||
28 | { | ||
29 | { SKIN_TOKEN_ALIGN_CENTER, "ac", "" }, | ||
30 | { SKIN_TOKEN_ALIGN_LEFT, "al", "" }, | ||
31 | { SKIN_TOKEN_ALIGN_LEFT_RTL, "aL", "" }, | ||
32 | { SKIN_TOKEN_ALIGN_RIGHT, "ar", "" }, | ||
33 | { SKIN_TOKEN_ALIGN_RIGHT_RTL, "aR", "" }, | ||
34 | { SKIN_TOKEN_ALIGN_LANGDIRECTION, "ax", "" }, | ||
35 | |||
36 | { SKIN_TOKEN_BATTERY_PERCENT, "bl" , BAR_PARAMS }, | ||
37 | { SKIN_TOKEN_BATTERY_VOLTS, "bv", "" }, | ||
38 | { SKIN_TOKEN_BATTERY_TIME, "bt", "" }, | ||
39 | { SKIN_TOKEN_BATTERY_SLEEPTIME, "bs", "" }, | ||
40 | { SKIN_TOKEN_BATTERY_CHARGING, "bc", "" }, | ||
41 | { SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, "bp", "" }, | ||
42 | { SKIN_TOKEN_USB_POWERED, "bu", "" }, | ||
43 | |||
44 | |||
45 | { SKIN_TOKEN_RTC_PRESENT, "cc", "" }, | ||
46 | { SKIN_TOKEN_RTC_DAY_OF_MONTH, "cd", "" }, | ||
47 | { SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED, "ce", "" }, | ||
48 | { SKIN_TOKEN_RTC_12HOUR_CFG, "cf", "" }, | ||
49 | { SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED, "cH", "" }, | ||
50 | { SKIN_TOKEN_RTC_HOUR_24, "ck", "" }, | ||
51 | { SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED, "cI", "" }, | ||
52 | { SKIN_TOKEN_RTC_HOUR_12, "cl", "" }, | ||
53 | { SKIN_TOKEN_RTC_MONTH, "cm", "" }, | ||
54 | { SKIN_TOKEN_RTC_MINUTE, "cM", "" }, | ||
55 | { SKIN_TOKEN_RTC_SECOND, "cS", "" }, | ||
56 | { SKIN_TOKEN_RTC_YEAR_2_DIGITS, "cy", "" }, | ||
57 | { SKIN_TOKEN_RTC_YEAR_4_DIGITS, "cY", "" }, | ||
58 | { SKIN_TOKEN_RTC_AM_PM_UPPER, "cP", "" }, | ||
59 | { SKIN_TOKEN_RTC_AM_PM_LOWER, "cp", "" }, | ||
60 | { SKIN_TOKEN_RTC_WEEKDAY_NAME, "ca", "" }, | ||
61 | { SKIN_TOKEN_RTC_MONTH_NAME, "cb", "" }, | ||
62 | { SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON, "cu", "" }, | ||
63 | { SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN, "cw", "" }, | ||
64 | |||
65 | { SKIN_TOKEN_FILE_BITRATE, "fb", "" }, | ||
66 | { SKIN_TOKEN_FILE_CODEC, "fc", "" }, | ||
67 | { SKIN_TOKEN_FILE_FREQUENCY, "ff", "" }, | ||
68 | { SKIN_TOKEN_FILE_FREQUENCY_KHZ, "fk", "" }, | ||
69 | { SKIN_TOKEN_FILE_NAME_WITH_EXTENSION, "fm", "" }, | ||
70 | { SKIN_TOKEN_FILE_NAME, "fn", "" }, | ||
71 | { SKIN_TOKEN_FILE_PATH, "fp", "" }, | ||
72 | { SKIN_TOKEN_FILE_SIZE, "fs", "" }, | ||
73 | { SKIN_TOKEN_FILE_VBR, "fv", "" }, | ||
74 | { SKIN_TOKEN_FILE_DIRECTORY, "d" , "I" }, | ||
75 | |||
76 | { SKIN_TOKEN_FILE_BITRATE, "Fb", "" }, | ||
77 | { SKIN_TOKEN_FILE_CODEC, "Fc", "" }, | ||
78 | { SKIN_TOKEN_FILE_FREQUENCY, "Ff", "" }, | ||
79 | { SKIN_TOKEN_FILE_FREQUENCY_KHZ, "Fk", "" }, | ||
80 | { SKIN_TOKEN_FILE_NAME_WITH_EXTENSION, "Fm", "" }, | ||
81 | { SKIN_TOKEN_FILE_NAME, "Fn", "" }, | ||
82 | { SKIN_TOKEN_FILE_PATH, "Fp", "" }, | ||
83 | { SKIN_TOKEN_FILE_SIZE, "Fs", "" }, | ||
84 | { SKIN_TOKEN_FILE_VBR, "Fv", "" }, | ||
85 | { SKIN_TOKEN_FILE_DIRECTORY, "D" , "I" }, | ||
86 | |||
87 | |||
88 | { SKIN_TOKEN_METADATA_ARTIST, "ia", "" }, | ||
89 | { SKIN_TOKEN_METADATA_COMPOSER, "ic", "" }, | ||
90 | { SKIN_TOKEN_METADATA_ALBUM, "id", "" }, | ||
91 | { SKIN_TOKEN_METADATA_ALBUM_ARTIST, "iA", "" }, | ||
92 | { SKIN_TOKEN_METADATA_GROUPING, "iG", "" }, | ||
93 | { SKIN_TOKEN_METADATA_GENRE, "ig", "" }, | ||
94 | { SKIN_TOKEN_METADATA_DISC_NUMBER, "ik", "" }, | ||
95 | { SKIN_TOKEN_METADATA_TRACK_NUMBER, "in", "" }, | ||
96 | { SKIN_TOKEN_METADATA_TRACK_TITLE, "it", "" }, | ||
97 | { SKIN_TOKEN_METADATA_VERSION, "iv", "" }, | ||
98 | { SKIN_TOKEN_METADATA_YEAR, "iy", "" }, | ||
99 | { SKIN_TOKEN_METADATA_COMMENT, "iC", "" }, | ||
100 | |||
101 | { SKIN_TOKEN_METADATA_ARTIST, "Ia", "" }, | ||
102 | { SKIN_TOKEN_METADATA_COMPOSER, "Ic", "" }, | ||
103 | { SKIN_TOKEN_METADATA_ALBUM, "Id", "" }, | ||
104 | { SKIN_TOKEN_METADATA_ALBUM_ARTIST, "IA", "" }, | ||
105 | { SKIN_TOKEN_METADATA_GROUPING, "IG", "" }, | ||
106 | { SKIN_TOKEN_METADATA_GENRE, "Ig", "" }, | ||
107 | { SKIN_TOKEN_METADATA_DISC_NUMBER, "Ik", "" }, | ||
108 | { SKIN_TOKEN_METADATA_TRACK_NUMBER, "In", "" }, | ||
109 | { SKIN_TOKEN_METADATA_TRACK_TITLE, "It", "" }, | ||
110 | { SKIN_TOKEN_METADATA_VERSION, "Iv", "" }, | ||
111 | { SKIN_TOKEN_METADATA_YEAR, "Iy", "" }, | ||
112 | { SKIN_TOKEN_METADATA_COMMENT, "IC", "" }, | ||
113 | |||
114 | { SKIN_TOKEN_SOUND_PITCH, "Sp", "" }, | ||
115 | { SKIN_TOKEN_SOUND_SPEED, "Ss", "" }, | ||
116 | |||
117 | { SKIN_TOKEN_VLED_HDD, "lh", "" }, | ||
118 | |||
119 | { SKIN_TOKEN_MAIN_HOLD, "mh", "" }, | ||
120 | { SKIN_TOKEN_REMOTE_HOLD, "mr", "" }, | ||
121 | { SKIN_TOKEN_REPEAT_MODE, "mm", "" }, | ||
122 | { SKIN_TOKEN_PLAYBACK_STATUS, "mp", "" }, | ||
123 | { SKIN_TOKEN_BUTTON_VOLUME, "mv", "|S" }, | ||
124 | |||
125 | { SKIN_TOKEN_PEAKMETER, "pm", "" }, | ||
126 | { SKIN_TOKEN_PLAYER_PROGRESSBAR, "pf", "" }, | ||
127 | { SKIN_TOKEN_PROGRESSBAR, "pb" , BAR_PARAMS }, | ||
128 | { SKIN_TOKEN_VOLUME, "pv" , BAR_PARAMS }, | ||
129 | |||
130 | { SKIN_TOKEN_TRACK_ELAPSED_PERCENT, "px", "" }, | ||
131 | { SKIN_TOKEN_TRACK_TIME_ELAPSED, "pc", "" }, | ||
132 | { SKIN_TOKEN_TRACK_TIME_REMAINING, "pr", "" }, | ||
133 | { SKIN_TOKEN_TRACK_LENGTH, "pt", "" }, | ||
134 | { SKIN_TOKEN_TRACK_STARTING, "pS" , "|S"}, | ||
135 | { SKIN_TOKEN_TRACK_ENDING, "pE" , "|S"}, | ||
136 | { SKIN_TOKEN_PLAYLIST_POSITION, "pp", "" }, | ||
137 | { SKIN_TOKEN_PLAYLIST_ENTRIES, "pe", "" }, | ||
138 | { SKIN_TOKEN_PLAYLIST_NAME, "pn", "" }, | ||
139 | { SKIN_TOKEN_PLAYLIST_SHUFFLE, "ps", "" }, | ||
140 | |||
141 | { SKIN_TOKEN_DATABASE_PLAYCOUNT, "rp", "" }, | ||
142 | { SKIN_TOKEN_DATABASE_RATING, "rr", "" }, | ||
143 | { SKIN_TOKEN_DATABASE_AUTOSCORE, "ra", "" }, | ||
144 | |||
145 | { SKIN_TOKEN_REPLAYGAIN, "rg", "" }, | ||
146 | { SKIN_TOKEN_CROSSFADE, "xf", "" }, | ||
147 | |||
148 | { SKIN_TOKEN_HAVE_TUNER, "tp", "" }, | ||
149 | { SKIN_TOKEN_TUNER_TUNED, "tt", "" }, | ||
150 | { SKIN_TOKEN_TUNER_SCANMODE, "tm", "" }, | ||
151 | { SKIN_TOKEN_TUNER_STEREO, "ts", "" }, | ||
152 | { SKIN_TOKEN_TUNER_MINFREQ, "ta", "" }, | ||
153 | { SKIN_TOKEN_TUNER_MAXFREQ, "tb", "" }, | ||
154 | { SKIN_TOKEN_TUNER_CURFREQ, "tf", "" }, | ||
155 | { SKIN_TOKEN_PRESET_ID, "Ti", "" }, | ||
156 | { SKIN_TOKEN_PRESET_NAME, "Tn", "" }, | ||
157 | { SKIN_TOKEN_PRESET_FREQ, "Tf", "" }, | ||
158 | { SKIN_TOKEN_PRESET_COUNT, "Tc", "" }, | ||
159 | { SKIN_TOKEN_HAVE_RDS, "tx", "" }, | ||
160 | { SKIN_TOKEN_RDS_NAME, "ty", "" }, | ||
161 | { SKIN_TOKEN_RDS_TEXT, "tz", "" }, | ||
162 | |||
163 | { SKIN_TOKEN_SUBLINE_SCROLL, "s", "" }, | ||
164 | { SKIN_TOKEN_SUBLINE_TIMEOUT, "t" , "S" }, | ||
165 | |||
166 | { SKIN_TOKEN_ENABLE_THEME, "we", "" }, | ||
167 | { SKIN_TOKEN_DISABLE_THEME, "wd", "" }, | ||
168 | { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "" }, | ||
169 | |||
170 | { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I" }, | ||
171 | { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S" }, | ||
172 | { SKIN_TOKEN_IMAGE_PRELOAD, "x", "SFII" }, | ||
173 | |||
174 | { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF"}, | ||
175 | { SKIN_TOKEN_ALBUMART_LOAD, "Cl" , "IIII|ss"}, | ||
176 | { SKIN_TOKEN_ALBUMART_DISPLAY, "Cd" , ""}, | ||
177 | { SKIN_TOKEN_ALBUMART_FOUND, "C" , ""}, | ||
178 | |||
179 | { SKIN_TOKEN_VIEWPORT_ENABLE, "Vd" , "S"}, | ||
180 | { SKIN_TOKEN_UIVIEWPORT_ENABLE, "VI" , "S"}, | ||
181 | |||
182 | { SKIN_TOKEN_VIEWPORT_CUSTOMLIST, "Vp" , "ICC"}, | ||
183 | { SKIN_TOKEN_LIST_TITLE_TEXT, "Lt" , ""}, | ||
184 | { SKIN_TOKEN_LIST_TITLE_ICON, "Li" , ""}, | ||
185 | |||
186 | { SKIN_TOKEN_VIEWPORT_FGCOLOUR, "Vf" , "S"}, | ||
187 | { SKIN_TOKEN_VIEWPORT_BGCOLOUR, "Vb" , "S"}, | ||
188 | |||
189 | { SKIN_TOKEN_VIEWPORT_CONDITIONAL, "Vl" , "SIIiii|ii"}, | ||
190 | { SKIN_TOKEN_UIVIEWPORT_LOAD, "Vi" , "sIIiii|ii"}, | ||
191 | { SKIN_TOKEN_VIEWPORT_LOAD, "V" , "IIiii|ii"}, | ||
192 | |||
193 | { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f"}, | ||
194 | |||
195 | { SKIN_TOKEN_SETTING, "St" , "S"}, | ||
196 | { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S"}, | ||
197 | { SKIN_TOKEN_LANG_IS_RTL, "Sr" , ""}, | ||
198 | |||
199 | { SKIN_TOKEN_LASTTOUCH, "Tl" , "|S"}, | ||
200 | { SKIN_TOKEN_CURRENT_SCREEN, "cs", "" }, | ||
201 | { SKIN_TOKEN_TOUCHREGION, "T" , "IIiiS"}, | ||
202 | |||
203 | { SKIN_TOKEN_HAVE_RECORDING, "Rp" , ""}, | ||
204 | { SKIN_TOKEN_IS_RECORDING, "Rr" , ""}, | ||
205 | { SKIN_TOKEN_REC_FREQ, "Rf" , ""}, | ||
206 | { SKIN_TOKEN_REC_ENCODER, "Re" , ""}, | ||
207 | { SKIN_TOKEN_REC_BITRATE, "Rb" , ""}, | ||
208 | { SKIN_TOKEN_REC_MONO, "Rm" , ""}, | ||
209 | { SKIN_TOKEN_REC_SECONDS, "Rs" , ""}, | ||
210 | { SKIN_TOKEN_REC_MINUTES, "Rn" , ""}, | ||
211 | { SKIN_TOKEN_REC_HOURS, "Rh" , ""}, | ||
212 | |||
213 | { SKIN_TOKEN_UNKNOWN, "" , ""} | ||
214 | /* Keep this here to mark the end of the table */ | ||
215 | }; | ||
216 | |||
217 | /* A table of legal escapable characters */ | ||
218 | char legal_escape_characters[] = "%(,);#<|>"; | ||
219 | |||
220 | /* | ||
221 | * Just does a straight search through the tag table to find one by | ||
222 | * the given name | ||
223 | */ | ||
224 | struct tag_info* find_tag(char* name) | ||
225 | { | ||
226 | |||
227 | struct tag_info* current = legal_tags; | ||
228 | |||
229 | /* | ||
230 | * Continue searching so long as we have a non-empty name string | ||
231 | * and the name of the current element doesn't match the name | ||
232 | * we're searching for | ||
233 | */ | ||
234 | |||
235 | while(strcmp(current->name, name) && current->name[0] != '\0') | ||
236 | current++; | ||
237 | |||
238 | if(current->name[0] == '\0') | ||
239 | return NULL; | ||
240 | else | ||
241 | return current; | ||
242 | |||
243 | } | ||
244 | |||
245 | /* Searches through the legal escape characters string */ | ||
246 | int find_escape_character(char lookup) | ||
247 | { | ||
248 | char* current = legal_escape_characters; | ||
249 | while(*current != lookup && *current != '\0') | ||
250 | current++; | ||
251 | |||
252 | if(*current == lookup && *current) | ||
253 | return 1; | ||
254 | else | ||
255 | return 0; | ||
256 | } | ||
diff --git a/utils/themeeditor/parser/tag_table.h b/utils/themeeditor/parser/tag_table.h deleted file mode 100644 index ec9a1021ab..0000000000 --- a/utils/themeeditor/parser/tag_table.h +++ /dev/null | |||
@@ -1,307 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef TAG_TABLE_H | ||
23 | #define TAG_TABLE_H | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" | ||
27 | { | ||
28 | #endif | ||
29 | |||
30 | |||
31 | enum skin_token_type { | ||
32 | |||
33 | TOKEN_MARKER_CONTROL_TOKENS = -1, | ||
34 | SKIN_TOKEN_UNKNOWN, | ||
35 | |||
36 | /* Markers */ | ||
37 | SKIN_TOKEN_CHARACTER, | ||
38 | SKIN_TOKEN_STRING, | ||
39 | SKIN_TOKEN_TRANSLATEDSTRING, | ||
40 | |||
41 | /* Alignment */ | ||
42 | SKIN_TOKEN_ALIGN_LEFT, | ||
43 | SKIN_TOKEN_ALIGN_LEFT_RTL, | ||
44 | SKIN_TOKEN_ALIGN_CENTER, | ||
45 | SKIN_TOKEN_ALIGN_RIGHT, | ||
46 | SKIN_TOKEN_ALIGN_RIGHT_RTL, | ||
47 | SKIN_TOKEN_ALIGN_LANGDIRECTION, | ||
48 | |||
49 | |||
50 | /* Sublines */ | ||
51 | SKIN_TOKEN_SUBLINE_TIMEOUT, | ||
52 | SKIN_TOKEN_SUBLINE_SCROLL, | ||
53 | |||
54 | /* Conditional */ | ||
55 | SKIN_TOKEN_CONDITIONAL, | ||
56 | SKIN_TOKEN_CONDITIONAL_START, | ||
57 | SKIN_TOKEN_CONDITIONAL_OPTION, | ||
58 | SKIN_TOKEN_CONDITIONAL_END, | ||
59 | |||
60 | /* Viewport display */ | ||
61 | SKIN_TOKEN_VIEWPORT_LOAD, | ||
62 | SKIN_TOKEN_VIEWPORT_CONDITIONAL, | ||
63 | SKIN_TOKEN_VIEWPORT_ENABLE, | ||
64 | SKIN_TOKEN_VIEWPORT_CUSTOMLIST, | ||
65 | SKIN_TOKEN_UIVIEWPORT_ENABLE, | ||
66 | SKIN_TOKEN_UIVIEWPORT_LOAD, | ||
67 | SKIN_TOKEN_VIEWPORT_FGCOLOUR, | ||
68 | SKIN_TOKEN_VIEWPORT_BGCOLOUR, | ||
69 | |||
70 | /* Battery */ | ||
71 | TOKEN_MARKER_BATTERY, | ||
72 | SKIN_TOKEN_BATTERY_PERCENT, | ||
73 | SKIN_TOKEN_BATTERY_PERCENTBAR, | ||
74 | SKIN_TOKEN_BATTERY_VOLTS, | ||
75 | SKIN_TOKEN_BATTERY_TIME, | ||
76 | SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, | ||
77 | SKIN_TOKEN_BATTERY_CHARGING, | ||
78 | SKIN_TOKEN_BATTERY_SLEEPTIME, | ||
79 | SKIN_TOKEN_USB_POWERED, | ||
80 | |||
81 | /* Sound */ | ||
82 | TOKEN_MARKER_SOUND, | ||
83 | SKIN_TOKEN_SOUND_PITCH, | ||
84 | SKIN_TOKEN_SOUND_SPEED, | ||
85 | SKIN_TOKEN_REPLAYGAIN, | ||
86 | SKIN_TOKEN_CROSSFADE, | ||
87 | |||
88 | /* Time */ | ||
89 | TOKEN_MARKER_RTC, | ||
90 | SKIN_TOKEN_RTC_PRESENT, | ||
91 | |||
92 | /* The begin/end values allow us to know if a token is an RTC one. | ||
93 | New RTC tokens should be added between the markers. */ | ||
94 | |||
95 | SKIN_TOKENs_RTC_BEGIN, /* just the start marker, not an actual token */ | ||
96 | |||
97 | SKIN_TOKEN_RTC_DAY_OF_MONTH, | ||
98 | SKIN_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED, | ||
99 | SKIN_TOKEN_RTC_12HOUR_CFG, | ||
100 | SKIN_TOKEN_RTC_HOUR_24_ZERO_PADDED, | ||
101 | SKIN_TOKEN_RTC_HOUR_24, | ||
102 | SKIN_TOKEN_RTC_HOUR_12_ZERO_PADDED, | ||
103 | SKIN_TOKEN_RTC_HOUR_12, | ||
104 | SKIN_TOKEN_RTC_MONTH, | ||
105 | SKIN_TOKEN_RTC_MINUTE, | ||
106 | SKIN_TOKEN_RTC_SECOND, | ||
107 | SKIN_TOKEN_RTC_YEAR_2_DIGITS, | ||
108 | SKIN_TOKEN_RTC_YEAR_4_DIGITS, | ||
109 | SKIN_TOKEN_RTC_AM_PM_UPPER, | ||
110 | SKIN_TOKEN_RTC_AM_PM_LOWER, | ||
111 | SKIN_TOKEN_RTC_WEEKDAY_NAME, | ||
112 | SKIN_TOKEN_RTC_MONTH_NAME, | ||
113 | SKIN_TOKEN_RTC_DAY_OF_WEEK_START_MON, | ||
114 | SKIN_TOKEN_RTC_DAY_OF_WEEK_START_SUN, | ||
115 | |||
116 | SKIN_TOKENS_RTC_END, /* just the end marker, not an actual token */ | ||
117 | |||
118 | /* Database */ | ||
119 | TOKEN_MARKER_DATABASE, | ||
120 | SKIN_TOKEN_DATABASE_PLAYCOUNT, | ||
121 | SKIN_TOKEN_DATABASE_RATING, | ||
122 | SKIN_TOKEN_DATABASE_AUTOSCORE, | ||
123 | |||
124 | /* File */ | ||
125 | TOKEN_MARKER_FILE, | ||
126 | SKIN_TOKEN_FILE_BITRATE, | ||
127 | SKIN_TOKEN_FILE_CODEC, | ||
128 | SKIN_TOKEN_FILE_FREQUENCY, | ||
129 | SKIN_TOKEN_FILE_FREQUENCY_KHZ, | ||
130 | SKIN_TOKEN_FILE_NAME, | ||
131 | SKIN_TOKEN_FILE_NAME_WITH_EXTENSION, | ||
132 | SKIN_TOKEN_FILE_PATH, | ||
133 | SKIN_TOKEN_FILE_SIZE, | ||
134 | SKIN_TOKEN_FILE_VBR, | ||
135 | SKIN_TOKEN_FILE_DIRECTORY, | ||
136 | |||
137 | /* Image */ | ||
138 | TOKEN_MARKER_IMAGES, | ||
139 | SKIN_TOKEN_IMAGE_BACKDROP, | ||
140 | SKIN_TOKEN_IMAGE_PROGRESS_BAR, | ||
141 | SKIN_TOKEN_IMAGE_PRELOAD, | ||
142 | SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, | ||
143 | SKIN_TOKEN_IMAGE_DISPLAY, | ||
144 | |||
145 | /* Albumart */ | ||
146 | SKIN_TOKEN_ALBUMART_LOAD, | ||
147 | SKIN_TOKEN_ALBUMART_DISPLAY, | ||
148 | SKIN_TOKEN_ALBUMART_FOUND, | ||
149 | |||
150 | /* Metadata */ | ||
151 | TOKEN_MARKER_METADATA, | ||
152 | SKIN_TOKEN_METADATA_ARTIST, | ||
153 | SKIN_TOKEN_METADATA_COMPOSER, | ||
154 | SKIN_TOKEN_METADATA_ALBUM_ARTIST, | ||
155 | SKIN_TOKEN_METADATA_GROUPING, | ||
156 | SKIN_TOKEN_METADATA_ALBUM, | ||
157 | SKIN_TOKEN_METADATA_GENRE, | ||
158 | SKIN_TOKEN_METADATA_DISC_NUMBER, | ||
159 | SKIN_TOKEN_METADATA_TRACK_NUMBER, | ||
160 | SKIN_TOKEN_METADATA_TRACK_TITLE, | ||
161 | SKIN_TOKEN_METADATA_VERSION, | ||
162 | SKIN_TOKEN_METADATA_YEAR, | ||
163 | SKIN_TOKEN_METADATA_COMMENT, | ||
164 | |||
165 | TOKEN_MARKER_PLAYBACK_INFO, | ||
166 | /* Mode */ | ||
167 | SKIN_TOKEN_REPEAT_MODE, | ||
168 | SKIN_TOKEN_PLAYBACK_STATUS, | ||
169 | /* Progressbar */ | ||
170 | SKIN_TOKEN_PROGRESSBAR, | ||
171 | SKIN_TOKEN_PLAYER_PROGRESSBAR, | ||
172 | /* Peakmeter */ | ||
173 | SKIN_TOKEN_PEAKMETER, | ||
174 | |||
175 | /* Current track */ | ||
176 | SKIN_TOKEN_TRACK_ELAPSED_PERCENT, | ||
177 | SKIN_TOKEN_TRACK_TIME_ELAPSED, | ||
178 | SKIN_TOKEN_TRACK_TIME_REMAINING, | ||
179 | SKIN_TOKEN_TRACK_LENGTH, | ||
180 | SKIN_TOKEN_TRACK_STARTING, | ||
181 | SKIN_TOKEN_TRACK_ENDING, | ||
182 | |||
183 | /* Playlist */ | ||
184 | TOKEN_MARKER_PLAYLIST, | ||
185 | SKIN_TOKEN_PLAYLIST_ENTRIES, | ||
186 | SKIN_TOKEN_PLAYLIST_NAME, | ||
187 | SKIN_TOKEN_PLAYLIST_POSITION, | ||
188 | SKIN_TOKEN_PLAYLIST_SHUFFLE, | ||
189 | |||
190 | |||
191 | TOKEN_MARKER_MISC, | ||
192 | SKIN_TOKEN_ENABLE_THEME, | ||
193 | SKIN_TOKEN_DISABLE_THEME, | ||
194 | SKIN_TOKEN_DRAW_INBUILTBAR, | ||
195 | SKIN_TOKEN_LIST_TITLE_TEXT, | ||
196 | SKIN_TOKEN_LIST_TITLE_ICON, | ||
197 | |||
198 | SKIN_TOKEN_LOAD_FONT, | ||
199 | |||
200 | /* buttons */ | ||
201 | SKIN_TOKEN_BUTTON_VOLUME, | ||
202 | SKIN_TOKEN_LASTTOUCH, | ||
203 | SKIN_TOKEN_TOUCHREGION, | ||
204 | /* Virtual LED */ | ||
205 | SKIN_TOKEN_VLED_HDD, | ||
206 | /* Volume level */ | ||
207 | SKIN_TOKEN_VOLUME, | ||
208 | SKIN_TOKEN_VOLUMEBAR, | ||
209 | /* hold */ | ||
210 | SKIN_TOKEN_MAIN_HOLD, | ||
211 | SKIN_TOKEN_REMOTE_HOLD, | ||
212 | |||
213 | /* Setting option */ | ||
214 | SKIN_TOKEN_SETTING, | ||
215 | SKIN_TOKEN_CURRENT_SCREEN, | ||
216 | SKIN_TOKEN_LANG_IS_RTL, | ||
217 | |||
218 | /* Recording Tokens */ | ||
219 | TOKEN_MARKER_RECORDING, | ||
220 | SKIN_TOKEN_HAVE_RECORDING, | ||
221 | SKIN_TOKEN_IS_RECORDING, | ||
222 | SKIN_TOKEN_REC_FREQ, | ||
223 | SKIN_TOKEN_REC_ENCODER, | ||
224 | SKIN_TOKEN_REC_BITRATE, /* SWCODEC: MP3 bitrate, HWCODEC: MP3 "quality" */ | ||
225 | SKIN_TOKEN_REC_MONO, | ||
226 | SKIN_TOKEN_REC_SECONDS, | ||
227 | SKIN_TOKEN_REC_MINUTES, | ||
228 | SKIN_TOKEN_REC_HOURS, | ||
229 | |||
230 | |||
231 | /* Radio Tokens */ | ||
232 | TOKEN_MARKER_TUNER, | ||
233 | SKIN_TOKEN_HAVE_TUNER, | ||
234 | SKIN_TOKEN_TUNER_TUNED, | ||
235 | SKIN_TOKEN_TUNER_SCANMODE, | ||
236 | SKIN_TOKEN_TUNER_STEREO, | ||
237 | SKIN_TOKEN_TUNER_MINFREQ, /* changes based on "region" */ | ||
238 | SKIN_TOKEN_TUNER_MAXFREQ, /* changes based on "region" */ | ||
239 | SKIN_TOKEN_TUNER_CURFREQ, | ||
240 | SKIN_TOKEN_PRESET_ID, /* "id" of this preset.. really the array element number */ | ||
241 | SKIN_TOKEN_PRESET_NAME, | ||
242 | SKIN_TOKEN_PRESET_FREQ, | ||
243 | SKIN_TOKEN_PRESET_COUNT, | ||
244 | /* RDS tokens */ | ||
245 | SKIN_TOKEN_HAVE_RDS, | ||
246 | SKIN_TOKEN_RDS_NAME, | ||
247 | SKIN_TOKEN_RDS_TEXT, | ||
248 | |||
249 | |||
250 | TOKEN_MARKER_END, /* this needs to be the last value in this enum */ | ||
251 | }; | ||
252 | |||
253 | /* | ||
254 | * Struct for tag parsing information | ||
255 | * name - The name of the tag, i.e. V for %V | ||
256 | * params - A string specifying all of the tags parameters, each | ||
257 | * character representing a single parameter. Valid | ||
258 | * characters for parameters are: | ||
259 | * I - Required integer | ||
260 | * i - Nullable integer | ||
261 | * S - Required string | ||
262 | * s - Nullable string | ||
263 | * F - Required file name | ||
264 | * f - Nullable file name | ||
265 | * C - Required skin code | ||
266 | * N - any amount of strings.. must be the last param in the list | ||
267 | * Any nullable parameter may be replaced in the WPS file | ||
268 | * with a '-'. To specify that parameters may be left off | ||
269 | * altogether, place a '|' in the parameter string. For | ||
270 | * instance, with the parameter string... | ||
271 | * Ii|Ss | ||
272 | * one integer must be specified, one integer can be | ||
273 | * specified or set to default with '-', and the user can | ||
274 | * stop providing parameters at any time after that. | ||
275 | * To specify multiple instances of the same type, put a | ||
276 | * number before the character. For instance, the string... | ||
277 | * 2s | ||
278 | * will specify two strings. An asterisk (*) at the beginning of the | ||
279 | * string will specify that you may choose to omit all arguments | ||
280 | * | ||
281 | */ | ||
282 | struct tag_info | ||
283 | { | ||
284 | enum skin_token_type type; | ||
285 | char* name; | ||
286 | char* params; | ||
287 | |||
288 | }; | ||
289 | |||
290 | /* | ||
291 | * Finds a tag by name and returns its parameter list, or an empty | ||
292 | * string if the tag is not found in the table | ||
293 | */ | ||
294 | struct tag_info* find_tag(char* name); | ||
295 | |||
296 | /* | ||
297 | * Determines whether a character is legal to escape or not. If | ||
298 | * lookup is not found in the legal escape characters string, returns | ||
299 | * false, otherwise returns true | ||
300 | */ | ||
301 | int find_escape_character(char lookup); | ||
302 | |||
303 | #ifdef __cplusplus | ||
304 | } | ||
305 | #endif | ||
306 | |||
307 | #endif /* TAG_TABLE_H */ | ||
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index 213bcd82d3..bf48bda7f2 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -5,17 +5,26 @@ UI_DIR = $$MYBUILDDIR/ui | |||
5 | MOC_DIR = $$MYBUILDDIR/moc | 5 | MOC_DIR = $$MYBUILDDIR/moc |
6 | RCC_DIR = $$MYBUILDDIR/rcc | 6 | RCC_DIR = $$MYBUILDDIR/rcc |
7 | 7 | ||
8 | RBBASE_DIR = $$_PRO_FILE_PWD_ | ||
9 | RBBASE_DIR = $$replace(RBBASE_DIR,/utils/themeeditor,) | ||
10 | |||
8 | #Include directories | 11 | #Include directories |
9 | INCLUDEPATH += gui | 12 | INCLUDEPATH += gui |
10 | INCLUDEPATH += parser | ||
11 | INCLUDEPATH += models | 13 | INCLUDEPATH += models |
12 | 14 | ||
13 | HEADERS += parser/tag_table.h \ | 15 | |
14 | parser/symbols.h \ | 16 | # Stuff for the parse lib |
15 | parser/skin_parser.h \ | 17 | libskin_parser.commands = @$(MAKE) \ |
16 | parser/skin_scan.h \ | 18 | BUILDDIR=$$OBJECTS_DIR -C $$RBBASE_DIR/lib/skin_parser CC=\"$$QMAKE_CC\" |
17 | parser/skin_debug.h \ | 19 | QMAKE_EXTRA_TARGETS += libskin_parser |
18 | models/parsetreemodel.h \ | 20 | PRE_TARGETDEPS += libskin_parser |
21 | INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser | ||
22 | LIBS += -L$$OBJECTS_DIR -lskin_parser | ||
23 | |||
24 | |||
25 | DEPENDPATH = $$INCLUDEPATH | ||
26 | |||
27 | HEADERS += models/parsetreemodel.h \ | ||
19 | models/parsetreenode.h \ | 28 | models/parsetreenode.h \ |
20 | gui/editorwindow.h \ | 29 | gui/editorwindow.h \ |
21 | gui/skinhighlighter.h \ | 30 | gui/skinhighlighter.h \ |
@@ -26,11 +35,7 @@ HEADERS += parser/tag_table.h \ | |||
26 | gui/tabcontent.h \ | 35 | gui/tabcontent.h \ |
27 | gui/configdocument.h \ | 36 | gui/configdocument.h \ |
28 | gui/skinviewer.h | 37 | gui/skinviewer.h |
29 | SOURCES += parser/tag_table.c \ | 38 | SOURCES += main.cpp \ |
30 | parser/skin_parser.c \ | ||
31 | parser/skin_scan.c \ | ||
32 | parser/skin_debug.c \ | ||
33 | main.cpp \ | ||
34 | models/parsetreemodel.cpp \ | 39 | models/parsetreemodel.cpp \ |
35 | models/parsetreenode.cpp \ | 40 | models/parsetreenode.cpp \ |
36 | gui/editorwindow.cpp \ | 41 | gui/editorwindow.cpp \ |