Add deployment script for Theme Editor.
[kugel-rb.git] / lib / skin_parser / skin_parser.h
blobad10f901253aaf35d169ccd02ff5a846a96148fc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Robert Bieber
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef GENERIC_PARSER_H
23 #define GENERIC_PARSER_H
25 #ifdef __cplusplus
26 extern "C"
28 #endif
29 #include <stdlib.h>
31 /********************************************************************
32 ****** Data Structures *********************************************
33 *******************************************************************/
35 /* Possible types of element in a WPS file */
36 enum skin_element_type
38 UNKNOWN = -1,
39 VIEWPORT,
40 LINE_ALTERNATOR,
41 LINE,
42 CONDITIONAL,
43 TAG,
44 TEXT,
45 COMMENT,
48 enum skin_errorcode
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 DECIMAL_EXPECTED,
60 SEPERATOR_EXPECTED,
61 CLOSE_EXPECTED,
62 MULTILINE_EXPECTED
65 /* Holds a tag parameter, either numeric or text */
66 struct skin_tag_parameter
68 enum
70 INTEGER,
71 DECIMAL, /* stored in data.number as (whole*10)+part */
72 STRING,
73 CODE,
74 DEFAULT
75 } type;
77 union
79 int number;
80 char* text;
81 struct skin_element* code;
82 } data;
84 char type_code;
88 /* Defines an element of a SKIN file */
89 struct skin_element
91 /* Defines what type of element it is */
92 enum skin_element_type type;
94 /* The line on which it's defined in the source file */
95 int line;
97 /* Placeholder for element data
98 * TEXT and COMMENT uses it for the text string
99 * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage
101 void* data;
103 /* The tag or conditional name */
104 struct tag_info *tag;
106 /* Pointer to and size of an array of parameters */
107 int params_count;
108 struct skin_tag_parameter* params;
110 /* Pointer to and size of an array of children */
111 int children_count;
112 struct skin_element** children;
114 /* Link to the next element */
115 struct skin_element* next;
118 /***********************************************************************
119 ***** Functions *******************************************************
120 **********************************************************************/
122 /* Parses a WPS document and returns a list of skin_element
123 structures. */
124 struct skin_element* skin_parse(const char* document);
126 /* Memory management functions */
127 struct skin_element* skin_alloc_element(void);
128 struct skin_element** skin_alloc_children(int count);
129 struct skin_tag_parameter* skin_alloc_params(int count);
130 char* skin_alloc_string(int length);
132 void skin_free_tree(struct skin_element* root);
135 #ifdef __cplusplus
137 #endif
139 #endif /* GENERIC_PARSER_H */