diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-05-25 15:19:52 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-05-25 15:19:52 +0000 |
commit | d5b24ddcc57857d9db5751c2f6e51f55633459e7 (patch) | |
tree | 1ee27a146004aed6788d38f688718783822cf1c1 /utils/themeeditor/skin_scan.c | |
parent | fd9d7d0ac103dc27ac4c79bcd715c2985b0bc559 (diff) | |
download | rockbox-d5b24ddcc57857d9db5751c2f6e51f55633459e7.tar.gz rockbox-d5b24ddcc57857d9db5751c2f6e51f55633459e7.zip |
Adding the new WPS parser, code works but need to build the tag table
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26281 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/skin_scan.c')
-rw-r--r-- | utils/themeeditor/skin_scan.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/utils/themeeditor/skin_scan.c b/utils/themeeditor/skin_scan.c new file mode 100644 index 0000000000..92ee521176 --- /dev/null +++ b/utils/themeeditor/skin_scan.c | |||
@@ -0,0 +1,137 @@ | |||
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 | |||
26 | #include "skin_scan.h" | ||
27 | #include "skin_debug.h" | ||
28 | #include "symbols.h" | ||
29 | #include "skin_parser.h" | ||
30 | |||
31 | /* Scanning Functions */ | ||
32 | |||
33 | /* Simple function to advance a char* past a comment */ | ||
34 | void skip_comment(char** document) | ||
35 | { | ||
36 | for(/*NO INIT*/;**document != '\n' && **document != '\0'; (*document)++); | ||
37 | if(**document == '\n') | ||
38 | (*document)++; | ||
39 | } | ||
40 | |||
41 | void skip_whitespace(char** document) | ||
42 | { | ||
43 | for(/*NO INIT*/; **document == ' ' || **document == '\t'; (*document)++); | ||
44 | } | ||
45 | |||
46 | char* scan_string(char** document) | ||
47 | { | ||
48 | |||
49 | char* cursor = *document; | ||
50 | int length = 0; | ||
51 | char* buffer = NULL; | ||
52 | int i; | ||
53 | |||
54 | while(*cursor != ARGLISTSEPERATESYM && *cursor != ARGLISTCLOSESYM && | ||
55 | *cursor != '\0') | ||
56 | { | ||
57 | if(*cursor == COMMENTSYM) | ||
58 | { | ||
59 | skip_comment(&cursor); | ||
60 | continue; | ||
61 | } | ||
62 | |||
63 | if(*cursor == '\n') | ||
64 | { | ||
65 | skin_error(UNEXPECTED_NEWLINE); | ||
66 | return NULL; | ||
67 | } | ||
68 | |||
69 | length++; | ||
70 | cursor++; | ||
71 | } | ||
72 | |||
73 | /* Copying the string */ | ||
74 | cursor = *document; | ||
75 | buffer = skin_alloc_string(length); | ||
76 | for(i = 0; i < length; i++) | ||
77 | { | ||
78 | if(*cursor == COMMENTSYM) | ||
79 | { | ||
80 | skip_comment(&cursor); | ||
81 | i--; | ||
82 | continue; | ||
83 | } | ||
84 | |||
85 | buffer[i] = *cursor; | ||
86 | cursor++; | ||
87 | } | ||
88 | |||
89 | *document = cursor; | ||
90 | return buffer; | ||
91 | } | ||
92 | |||
93 | int scan_int(char** document) | ||
94 | { | ||
95 | |||
96 | char* cursor = *document; | ||
97 | int length = 0; | ||
98 | char* buffer = NULL; | ||
99 | int retval; | ||
100 | int i; | ||
101 | |||
102 | while(isdigit(*cursor) || *cursor == COMMENTSYM) | ||
103 | { | ||
104 | if(*cursor == COMMENTSYM) | ||
105 | { | ||
106 | skip_comment(&cursor); | ||
107 | continue; | ||
108 | } | ||
109 | |||
110 | length++; | ||
111 | cursor++; | ||
112 | } | ||
113 | |||
114 | buffer = skin_alloc_string(length); | ||
115 | |||
116 | /* Copying to the buffer while avoiding comments */ | ||
117 | cursor = *document; | ||
118 | buffer[length] = '\0'; | ||
119 | for(i = 0; i < length; i++) | ||
120 | { | ||
121 | if(*cursor == COMMENTSYM) | ||
122 | { | ||
123 | skip_comment(&cursor); | ||
124 | i--; | ||
125 | continue; | ||
126 | } | ||
127 | |||
128 | buffer[i] = *cursor; | ||
129 | cursor++; | ||
130 | |||
131 | } | ||
132 | retval = atoi(buffer); | ||
133 | free(buffer); | ||
134 | |||
135 | *document = cursor; | ||
136 | return retval; | ||
137 | } | ||