diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-05-02 17:51:01 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-05-02 17:51:01 +0000 |
commit | aa220d5acdbfd8178580e7eb503c205406e2be74 (patch) | |
tree | 00b576acd86a120c371ab7257787e173d08970c0 /apps/gui | |
parent | 2a20bfe15325a2a94f49e0cec49f20b3c2aecc18 (diff) | |
download | rockbox-aa220d5acdbfd8178580e7eb503c205406e2be74.tar.gz rockbox-aa220d5acdbfd8178580e7eb503c205406e2be74.zip |
Trim a bunch of long lines and fix an infinite loop and buffer overrun in the impossible case that a WPS line ends with a litteral string but without a newline char (wps_parser.c:774).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 17 | ||||
-rw-r--r-- | apps/gui/wps_debug.c | 61 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 76 |
3 files changed, 94 insertions, 60 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 14a0d565f4..ddfddc5ec7 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -769,8 +769,8 @@ static char *get_token_value(struct gui_wps *gwps, | |||
769 | #if CONFIG_RTC | 769 | #if CONFIG_RTC |
770 | struct tm* tm = NULL; | 770 | struct tm* tm = NULL; |
771 | 771 | ||
772 | /* if the token is an RTC one, update the time and do the necessary checks */ | 772 | /* if the token is an RTC one, update the time |
773 | 773 | and do the necessary checks */ | |
774 | if (token->type >= WPS_TOKENS_RTC_BEGIN | 774 | if (token->type >= WPS_TOKENS_RTC_BEGIN |
775 | && token->type <= WPS_TOKENS_RTC_END) | 775 | && token->type <= WPS_TOKENS_RTC_END) |
776 | { | 776 | { |
@@ -1313,7 +1313,7 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index) | |||
1313 | /* intval is now the number of the enum option we want to read, | 1313 | /* intval is now the number of the enum option we want to read, |
1314 | starting from 1. If intval is -1, we check if value is empty. */ | 1314 | starting from 1. If intval is -1, we check if value is empty. */ |
1315 | if (intval == -1) | 1315 | if (intval == -1) |
1316 | intval = value && strlen(value) ? 1 : num_options; | 1316 | intval = (value && *value) ? 1 : num_options; |
1317 | else if (intval > num_options || intval < 1) | 1317 | else if (intval > num_options || intval < 1) |
1318 | intval = num_options; | 1318 | intval = num_options; |
1319 | 1319 | ||
@@ -1543,12 +1543,14 @@ static bool update_curr_subline(struct gui_wps *gwps, int line) | |||
1543 | 1543 | ||
1544 | /* if back where we started after search or | 1544 | /* if back where we started after search or |
1545 | only one subline is defined on the line */ | 1545 | only one subline is defined on the line */ |
1546 | if (((search > 0) && (data->lines[line].curr_subline == search_start)) || | 1546 | if (((search > 0) && |
1547 | (data->lines[line].curr_subline == search_start)) || | ||
1547 | only_one_subline) | 1548 | only_one_subline) |
1548 | { | 1549 | { |
1549 | /* no other subline with a time > 0 exists */ | 1550 | /* no other subline with a time > 0 exists */ |
1550 | data->lines[line].subline_expire_time = (reset_subline ? | 1551 | data->lines[line].subline_expire_time = (reset_subline ? |
1551 | current_tick : data->lines[line].subline_expire_time) + 100 * HZ; | 1552 | current_tick : |
1553 | data->lines[line].subline_expire_time) + 100 * HZ; | ||
1552 | break; | 1554 | break; |
1553 | } | 1555 | } |
1554 | else | 1556 | else |
@@ -1565,7 +1567,7 @@ static bool update_curr_subline(struct gui_wps *gwps, int line) | |||
1565 | new_subline_refresh = true; | 1567 | new_subline_refresh = true; |
1566 | data->lines[line].subline_expire_time = (reset_subline ? | 1568 | data->lines[line].subline_expire_time = (reset_subline ? |
1567 | current_tick : data->lines[line].subline_expire_time) + | 1569 | current_tick : data->lines[line].subline_expire_time) + |
1568 | BASE_SUBLINE_TIME * data->sublines[subline_idx].time_mult; | 1570 | BASE_SUBLINE_TIME*data->sublines[subline_idx].time_mult; |
1569 | break; | 1571 | break; |
1570 | } | 1572 | } |
1571 | } | 1573 | } |
@@ -1820,7 +1822,8 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1820 | /* get current subline for the line */ | 1822 | /* get current subline for the line */ |
1821 | new_subline_refresh = update_curr_subline(gwps, line); | 1823 | new_subline_refresh = update_curr_subline(gwps, line); |
1822 | 1824 | ||
1823 | subline_idx = wps_subline_index(data, line, data->lines[line].curr_subline); | 1825 | subline_idx = wps_subline_index(data, line, |
1826 | data->lines[line].curr_subline); | ||
1824 | flags = data->sublines[subline_idx].line_type; | 1827 | flags = data->sublines[subline_idx].line_type; |
1825 | 1828 | ||
1826 | if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode) | 1829 | if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode) |
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index a5f0e2128d..767f296cdd 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c | |||
@@ -149,7 +149,8 @@ static void dump_wps_tokens(struct wps_data *data) | |||
149 | snprintf(buf, sizeof(buf), "rtc: day of month (01..31)"); | 149 | snprintf(buf, sizeof(buf), "rtc: day of month (01..31)"); |
150 | break; | 150 | break; |
151 | case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED: | 151 | case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED: |
152 | snprintf(buf, sizeof(buf), "rtc: day of month, blank padded ( 1..31)"); | 152 | snprintf(buf, sizeof(buf), |
153 | "rtc: day of month, blank padded ( 1..31)"); | ||
153 | break; | 154 | break; |
154 | case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED: | 155 | case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED: |
155 | snprintf(buf, sizeof(buf), "rtc: hour (00..23)"); | 156 | snprintf(buf, sizeof(buf), "rtc: hour (00..23)"); |
@@ -173,28 +174,35 @@ static void dump_wps_tokens(struct wps_data *data) | |||
173 | snprintf(buf, sizeof(buf), "rtc: second (00..59)"); | 174 | snprintf(buf, sizeof(buf), "rtc: second (00..59)"); |
174 | break; | 175 | break; |
175 | case WPS_TOKEN_RTC_YEAR_2_DIGITS: | 176 | case WPS_TOKEN_RTC_YEAR_2_DIGITS: |
176 | snprintf(buf, sizeof(buf), "rtc: last two digits of year (00..99)"); | 177 | snprintf(buf, sizeof(buf), |
178 | "rtc: last two digits of year (00..99)"); | ||
177 | break; | 179 | break; |
178 | case WPS_TOKEN_RTC_YEAR_4_DIGITS: | 180 | case WPS_TOKEN_RTC_YEAR_4_DIGITS: |
179 | snprintf(buf, sizeof(buf), "rtc: year (1970...)"); | 181 | snprintf(buf, sizeof(buf), "rtc: year (1970...)"); |
180 | break; | 182 | break; |
181 | case WPS_TOKEN_RTC_AM_PM_UPPER: | 183 | case WPS_TOKEN_RTC_AM_PM_UPPER: |
182 | snprintf(buf, sizeof(buf), "rtc: upper case AM or PM indicator"); | 184 | snprintf(buf, sizeof(buf), |
185 | "rtc: upper case AM or PM indicator"); | ||
183 | break; | 186 | break; |
184 | case WPS_TOKEN_RTC_AM_PM_LOWER: | 187 | case WPS_TOKEN_RTC_AM_PM_LOWER: |
185 | snprintf(buf, sizeof(buf), "rtc: lower case am or pm indicator"); | 188 | snprintf(buf, sizeof(buf), |
189 | "rtc: lower case am or pm indicator"); | ||
186 | break; | 190 | break; |
187 | case WPS_TOKEN_RTC_WEEKDAY_NAME: | 191 | case WPS_TOKEN_RTC_WEEKDAY_NAME: |
188 | snprintf(buf, sizeof(buf), "rtc: abbreviated weekday name (Sun..Sat)"); | 192 | snprintf(buf, sizeof(buf), |
193 | "rtc: abbreviated weekday name (Sun..Sat)"); | ||
189 | break; | 194 | break; |
190 | case WPS_TOKEN_RTC_MONTH_NAME: | 195 | case WPS_TOKEN_RTC_MONTH_NAME: |
191 | snprintf(buf, sizeof(buf), "rtc: abbreviated month name (Jan..Dec)"); | 196 | snprintf(buf, sizeof(buf), |
197 | "rtc: abbreviated month name (Jan..Dec)"); | ||
192 | break; | 198 | break; |
193 | case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON: | 199 | case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON: |
194 | snprintf(buf, sizeof(buf), "rtc: day of week (1..7); 1 is Monday"); | 200 | snprintf(buf, sizeof(buf), |
201 | "rtc: day of week (1..7); 1 is Monday"); | ||
195 | break; | 202 | break; |
196 | case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN: | 203 | case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN: |
197 | snprintf(buf, sizeof(buf), "rtc: day of week (0..6); 0 is Sunday"); | 204 | snprintf(buf, sizeof(buf), |
205 | "rtc: day of week (0..6); 0 is Sunday"); | ||
198 | break; | 206 | break; |
199 | #endif | 207 | #endif |
200 | 208 | ||
@@ -265,31 +273,38 @@ static void dump_wps_tokens(struct wps_data *data) | |||
265 | break; | 273 | break; |
266 | 274 | ||
267 | case WPS_TOKEN_METADATA_ARTIST: | 275 | case WPS_TOKEN_METADATA_ARTIST: |
268 | snprintf(buf, sizeof(buf), "%strack artist", next_str(next)); | 276 | snprintf(buf, sizeof(buf), "%strack artist", |
277 | next_str(next)); | ||
269 | break; | 278 | break; |
270 | 279 | ||
271 | case WPS_TOKEN_METADATA_COMPOSER: | 280 | case WPS_TOKEN_METADATA_COMPOSER: |
272 | snprintf(buf, sizeof(buf), "%strack composer", next_str(next)); | 281 | snprintf(buf, sizeof(buf), "%strack composer", |
282 | next_str(next)); | ||
273 | break; | 283 | break; |
274 | 284 | ||
275 | case WPS_TOKEN_METADATA_ALBUM: | 285 | case WPS_TOKEN_METADATA_ALBUM: |
276 | snprintf(buf, sizeof(buf), "%strack album", next_str(next)); | 286 | snprintf(buf, sizeof(buf), "%strack album", |
287 | next_str(next)); | ||
277 | break; | 288 | break; |
278 | 289 | ||
279 | case WPS_TOKEN_METADATA_GENRE: | 290 | case WPS_TOKEN_METADATA_GENRE: |
280 | snprintf(buf, sizeof(buf), "%strack genre", next_str(next)); | 291 | snprintf(buf, sizeof(buf), "%strack genre", |
292 | next_str(next)); | ||
281 | break; | 293 | break; |
282 | 294 | ||
283 | case WPS_TOKEN_METADATA_TRACK_NUMBER: | 295 | case WPS_TOKEN_METADATA_TRACK_NUMBER: |
284 | snprintf(buf, sizeof(buf), "%strack number", next_str(next)); | 296 | snprintf(buf, sizeof(buf), "%strack number", |
297 | next_str(next)); | ||
285 | break; | 298 | break; |
286 | 299 | ||
287 | case WPS_TOKEN_METADATA_TRACK_TITLE: | 300 | case WPS_TOKEN_METADATA_TRACK_TITLE: |
288 | snprintf(buf, sizeof(buf), "%strack title", next_str(next)); | 301 | snprintf(buf, sizeof(buf), "%strack title", |
302 | next_str(next)); | ||
289 | break; | 303 | break; |
290 | 304 | ||
291 | case WPS_TOKEN_METADATA_VERSION: | 305 | case WPS_TOKEN_METADATA_VERSION: |
292 | snprintf(buf, sizeof(buf), "%strack ID3 version", next_str(next)); | 306 | snprintf(buf, sizeof(buf), "%strack ID3 version", |
307 | next_str(next)); | ||
293 | break; | 308 | break; |
294 | 309 | ||
295 | case WPS_TOKEN_METADATA_YEAR: | 310 | case WPS_TOKEN_METADATA_YEAR: |
@@ -325,7 +340,8 @@ static void dump_wps_tokens(struct wps_data *data) | |||
325 | break; | 340 | break; |
326 | 341 | ||
327 | case WPS_TOKEN_FILE_FREQUENCY: | 342 | case WPS_TOKEN_FILE_FREQUENCY: |
328 | snprintf(buf, sizeof(buf), "%sfile audio frequency", next_str(next)); | 343 | snprintf(buf, sizeof(buf), "%sfile audio frequency", |
344 | next_str(next)); | ||
329 | break; | 345 | break; |
330 | 346 | ||
331 | case WPS_TOKEN_FILE_NAME: | 347 | case WPS_TOKEN_FILE_NAME: |
@@ -333,7 +349,8 @@ static void dump_wps_tokens(struct wps_data *data) | |||
333 | break; | 349 | break; |
334 | 350 | ||
335 | case WPS_TOKEN_FILE_NAME_WITH_EXTENSION: | 351 | case WPS_TOKEN_FILE_NAME_WITH_EXTENSION: |
336 | snprintf(buf, sizeof(buf), "%sfile name with extension", next_str(next)); | 352 | snprintf(buf, sizeof(buf), "%sfile name with extension", |
353 | next_str(next)); | ||
337 | break; | 354 | break; |
338 | 355 | ||
339 | case WPS_TOKEN_FILE_PATH: | 356 | case WPS_TOKEN_FILE_PATH: |
@@ -349,8 +366,8 @@ static void dump_wps_tokens(struct wps_data *data) | |||
349 | break; | 366 | break; |
350 | 367 | ||
351 | case WPS_TOKEN_FILE_DIRECTORY: | 368 | case WPS_TOKEN_FILE_DIRECTORY: |
352 | snprintf(buf, sizeof(buf), "%sfile directory, level: %d", next_str(next), | 369 | snprintf(buf, sizeof(buf), "%sfile directory, level: %d", |
353 | token->value.i); | 370 | next_str(next), token->value.i); |
354 | break; | 371 | break; |
355 | 372 | ||
356 | default: | 373 | default: |
@@ -421,9 +438,11 @@ static void print_wps_strings(struct wps_data *data) | |||
421 | DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]); | 438 | DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]); |
422 | } | 439 | } |
423 | DEBUGF("\n"); | 440 | DEBUGF("\n"); |
424 | DEBUGF("Number of strings: %d out of an allowed %d\n", data->num_strings, WPS_MAX_STRINGS); | 441 | DEBUGF("Number of strings: %d out of an allowed %d\n", |
442 | data->num_strings, WPS_MAX_STRINGS); | ||
425 | DEBUGF("Total string length: %d\n", total_len); | 443 | DEBUGF("Total string length: %d\n", total_len); |
426 | DEBUGF("String buffer used: %d out of %d bytes\n", buf_used, STRING_BUFFER_SIZE); | 444 | DEBUGF("String buffer used: %d out of %d bytes\n", |
445 | buf_used, STRING_BUFFER_SIZE); | ||
427 | DEBUGF("\n"); | 446 | DEBUGF("\n"); |
428 | } | 447 | } |
429 | 448 | ||
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index ee16de330a..b053cee109 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -136,23 +136,23 @@ static const struct wps_tag all_tags[] = { | |||
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | #if CONFIG_RTC | 138 | #if CONFIG_RTC |
139 | { WPS_TOKEN_RTC_DAY_OF_MONTH, "cd", WPS_REFRESH_DYNAMIC, NULL }, | 139 | { WPS_TOKEN_RTC_DAY_OF_MONTH, "cd", WPS_REFRESH_DYNAMIC, NULL }, |
140 | { WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED, "ce", WPS_REFRESH_DYNAMIC, NULL }, | 140 | { WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,"ce", WPS_REFRESH_DYNAMIC, NULL }, |
141 | { WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED, "cH", WPS_REFRESH_DYNAMIC, NULL }, | 141 | { WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED, "cH", WPS_REFRESH_DYNAMIC, NULL }, |
142 | { WPS_TOKEN_RTC_HOUR_24, "ck", WPS_REFRESH_DYNAMIC, NULL }, | 142 | { WPS_TOKEN_RTC_HOUR_24, "ck", WPS_REFRESH_DYNAMIC, NULL }, |
143 | { WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED, "cI", WPS_REFRESH_DYNAMIC, NULL }, | 143 | { WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED, "cI", WPS_REFRESH_DYNAMIC, NULL }, |
144 | { WPS_TOKEN_RTC_HOUR_12, "cl", WPS_REFRESH_DYNAMIC, NULL }, | 144 | { WPS_TOKEN_RTC_HOUR_12, "cl", WPS_REFRESH_DYNAMIC, NULL }, |
145 | { WPS_TOKEN_RTC_MONTH, "cm", WPS_REFRESH_DYNAMIC, NULL }, | 145 | { WPS_TOKEN_RTC_MONTH, "cm", WPS_REFRESH_DYNAMIC, NULL }, |
146 | { WPS_TOKEN_RTC_MINUTE, "cM", WPS_REFRESH_DYNAMIC, NULL }, | 146 | { WPS_TOKEN_RTC_MINUTE, "cM", WPS_REFRESH_DYNAMIC, NULL }, |
147 | { WPS_TOKEN_RTC_SECOND, "cS", WPS_REFRESH_DYNAMIC, NULL }, | 147 | { WPS_TOKEN_RTC_SECOND, "cS", WPS_REFRESH_DYNAMIC, NULL }, |
148 | { WPS_TOKEN_RTC_YEAR_2_DIGITS, "cy", WPS_REFRESH_DYNAMIC, NULL }, | 148 | { WPS_TOKEN_RTC_YEAR_2_DIGITS, "cy", WPS_REFRESH_DYNAMIC, NULL }, |
149 | { WPS_TOKEN_RTC_YEAR_4_DIGITS, "cY", WPS_REFRESH_DYNAMIC, NULL }, | 149 | { WPS_TOKEN_RTC_YEAR_4_DIGITS, "cY", WPS_REFRESH_DYNAMIC, NULL }, |
150 | { WPS_TOKEN_RTC_AM_PM_UPPER, "cP", WPS_REFRESH_DYNAMIC, NULL }, | 150 | { WPS_TOKEN_RTC_AM_PM_UPPER, "cP", WPS_REFRESH_DYNAMIC, NULL }, |
151 | { WPS_TOKEN_RTC_AM_PM_LOWER, "cp", WPS_REFRESH_DYNAMIC, NULL }, | 151 | { WPS_TOKEN_RTC_AM_PM_LOWER, "cp", WPS_REFRESH_DYNAMIC, NULL }, |
152 | { WPS_TOKEN_RTC_WEEKDAY_NAME, "ca", WPS_REFRESH_DYNAMIC, NULL }, | 152 | { WPS_TOKEN_RTC_WEEKDAY_NAME, "ca", WPS_REFRESH_DYNAMIC, NULL }, |
153 | { WPS_TOKEN_RTC_MONTH_NAME, "cb", WPS_REFRESH_DYNAMIC, NULL }, | 153 | { WPS_TOKEN_RTC_MONTH_NAME, "cb", WPS_REFRESH_DYNAMIC, NULL }, |
154 | { WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON, "cu", WPS_REFRESH_DYNAMIC, NULL }, | 154 | { WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON, "cu", WPS_REFRESH_DYNAMIC, NULL }, |
155 | { WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN, "cw", WPS_REFRESH_DYNAMIC, NULL }, | 155 | { WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN, "cw", WPS_REFRESH_DYNAMIC, NULL }, |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | /* current file */ | 158 | /* current file */ |
@@ -164,7 +164,8 @@ static const struct wps_tag all_tags[] = { | |||
164 | { WPS_TOKEN_FILE_PATH, "fp", WPS_REFRESH_STATIC, NULL }, | 164 | { WPS_TOKEN_FILE_PATH, "fp", WPS_REFRESH_STATIC, NULL }, |
165 | { WPS_TOKEN_FILE_SIZE, "fs", WPS_REFRESH_STATIC, NULL }, | 165 | { WPS_TOKEN_FILE_SIZE, "fs", WPS_REFRESH_STATIC, NULL }, |
166 | { WPS_TOKEN_FILE_VBR, "fv", WPS_REFRESH_STATIC, NULL }, | 166 | { WPS_TOKEN_FILE_VBR, "fv", WPS_REFRESH_STATIC, NULL }, |
167 | { WPS_TOKEN_FILE_DIRECTORY, "d", WPS_REFRESH_STATIC, parse_dir_level }, | 167 | { WPS_TOKEN_FILE_DIRECTORY, "d", WPS_REFRESH_STATIC, |
168 | parse_dir_level }, | ||
168 | 169 | ||
169 | /* next file */ | 170 | /* next file */ |
170 | { WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_DYNAMIC, NULL }, | 171 | { WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_DYNAMIC, NULL }, |
@@ -175,7 +176,8 @@ static const struct wps_tag all_tags[] = { | |||
175 | { WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_DYNAMIC, NULL }, | 176 | { WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_DYNAMIC, NULL }, |
176 | { WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_DYNAMIC, NULL }, | 177 | { WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_DYNAMIC, NULL }, |
177 | { WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_DYNAMIC, NULL }, | 178 | { WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_DYNAMIC, NULL }, |
178 | { WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_DYNAMIC, parse_dir_level }, | 179 | { WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_DYNAMIC, |
180 | parse_dir_level }, | ||
179 | 181 | ||
180 | /* current metadata */ | 182 | /* current metadata */ |
181 | { WPS_TOKEN_METADATA_ARTIST, "ia", WPS_REFRESH_STATIC, NULL }, | 183 | { WPS_TOKEN_METADATA_ARTIST, "ia", WPS_REFRESH_STATIC, NULL }, |
@@ -187,13 +189,13 @@ static const struct wps_tag all_tags[] = { | |||
187 | { WPS_TOKEN_METADATA_TRACK_TITLE, "it", WPS_REFRESH_STATIC, NULL }, | 189 | { WPS_TOKEN_METADATA_TRACK_TITLE, "it", WPS_REFRESH_STATIC, NULL }, |
188 | { WPS_TOKEN_METADATA_VERSION, "iv", WPS_REFRESH_STATIC, NULL }, | 190 | { WPS_TOKEN_METADATA_VERSION, "iv", WPS_REFRESH_STATIC, NULL }, |
189 | { WPS_TOKEN_METADATA_YEAR, "iy", WPS_REFRESH_STATIC, NULL }, | 191 | { WPS_TOKEN_METADATA_YEAR, "iy", WPS_REFRESH_STATIC, NULL }, |
190 | { WPS_TOKEN_METADATA_COMMENT, "iC", WPS_REFRESH_STATIC, NULL }, | 192 | { WPS_TOKEN_METADATA_COMMENT, "iC", WPS_REFRESH_STATIC, NULL }, |
191 | 193 | ||
192 | /* next metadata */ | 194 | /* next metadata */ |
193 | { WPS_TOKEN_METADATA_ARTIST, "Ia", WPS_REFRESH_DYNAMIC, NULL }, | 195 | { WPS_TOKEN_METADATA_ARTIST, "Ia", WPS_REFRESH_DYNAMIC, NULL }, |
194 | { WPS_TOKEN_METADATA_COMPOSER, "Ic", WPS_REFRESH_DYNAMIC, NULL }, | 196 | { WPS_TOKEN_METADATA_COMPOSER, "Ic", WPS_REFRESH_DYNAMIC, NULL }, |
195 | { WPS_TOKEN_METADATA_ALBUM, "Id", WPS_REFRESH_DYNAMIC, NULL }, | 197 | { WPS_TOKEN_METADATA_ALBUM, "Id", WPS_REFRESH_DYNAMIC, NULL }, |
196 | { WPS_TOKEN_METADATA_ALBUM_ARTIST, "IA", WPS_REFRESH_DYNAMIC, NULL }, | 198 | { WPS_TOKEN_METADATA_ALBUM_ARTIST, "IA", WPS_REFRESH_DYNAMIC, NULL }, |
197 | { WPS_TOKEN_METADATA_GENRE, "Ig", WPS_REFRESH_DYNAMIC, NULL }, | 199 | { WPS_TOKEN_METADATA_GENRE, "Ig", WPS_REFRESH_DYNAMIC, NULL }, |
198 | { WPS_TOKEN_METADATA_TRACK_NUMBER, "In", WPS_REFRESH_DYNAMIC, NULL }, | 200 | { WPS_TOKEN_METADATA_TRACK_NUMBER, "In", WPS_REFRESH_DYNAMIC, NULL }, |
199 | { WPS_TOKEN_METADATA_TRACK_TITLE, "It", WPS_REFRESH_DYNAMIC, NULL }, | 201 | { WPS_TOKEN_METADATA_TRACK_TITLE, "It", WPS_REFRESH_DYNAMIC, NULL }, |
@@ -220,11 +222,13 @@ static const struct wps_tag all_tags[] = { | |||
220 | { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL }, | 222 | { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL }, |
221 | 223 | ||
222 | #ifdef HAVE_LCD_BITMAP | 224 | #ifdef HAVE_LCD_BITMAP |
223 | { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL }, | 225 | { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL }, |
224 | #else | 226 | #else |
225 | { WPS_TOKEN_PLAYER_PROGRESSBAR, "pf", WPS_REFRESH_DYNAMIC | WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar }, | 227 | { WPS_TOKEN_PLAYER_PROGRESSBAR, "pf", |
228 | WPS_REFRESH_DYNAMIC | WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar }, | ||
226 | #endif | 229 | #endif |
227 | { WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar }, | 230 | { WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS, |
231 | parse_progressbar }, | ||
228 | 232 | ||
229 | { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL }, | 233 | { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL }, |
230 | 234 | ||
@@ -254,7 +258,8 @@ static const struct wps_tag all_tags[] = { | |||
254 | 258 | ||
255 | { WPS_NO_TOKEN, "xl", 0, parse_image_load }, | 259 | { WPS_NO_TOKEN, "xl", 0, parse_image_load }, |
256 | 260 | ||
257 | { WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC, parse_image_display }, | 261 | { WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC, |
262 | parse_image_display }, | ||
258 | 263 | ||
259 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, | 264 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, |
260 | { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, | 265 | { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, |
@@ -622,7 +627,8 @@ static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) | |||
622 | 627 | ||
623 | taglen = (tag->type != WPS_TOKEN_UNKNOWN) ? strlen(tag->name) : 2; | 628 | taglen = (tag->type != WPS_TOKEN_UNKNOWN) ? strlen(tag->name) : 2; |
624 | token->type = tag->type; | 629 | token->type = tag->type; |
625 | wps_data->sublines[wps_data->num_sublines].line_type |= tag->refresh_type; | 630 | wps_data->sublines[wps_data->num_sublines].line_type |= |
631 | tag->refresh_type; | ||
626 | 632 | ||
627 | /* if the tag has a special parsing function, we call it */ | 633 | /* if the tag has a special parsing function, we call it */ |
628 | if (tag->parse_func) | 634 | if (tag->parse_func) |
@@ -633,7 +639,8 @@ static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) | |||
633 | break; | 639 | break; |
634 | 640 | ||
635 | /* tags that start with 'F', 'I' or 'D' are for the next file */ | 641 | /* tags that start with 'F', 'I' or 'D' are for the next file */ |
636 | if ( *(tag->name) == 'I' || *(tag->name) == 'F' || *(tag->name) == 'D') | 642 | if ( *(tag->name) == 'I' || *(tag->name) == 'F' || |
643 | *(tag->name) == 'D') | ||
637 | token->next = true; | 644 | token->next = true; |
638 | 645 | ||
639 | wps_data->num_tokens++; | 646 | wps_data->num_tokens++; |
@@ -758,8 +765,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) | |||
758 | if ((data->num_lines < WPS_MAX_LINES) && | 765 | if ((data->num_lines < WPS_MAX_LINES) && |
759 | (data->num_sublines < WPS_MAX_SUBLINES)) | 766 | (data->num_sublines < WPS_MAX_SUBLINES)) |
760 | { | 767 | { |
761 | data->lines[data->num_lines].first_subline_idx = data->num_sublines; | 768 | data->lines[data->num_lines].first_subline_idx = |
762 | data->sublines[data->num_sublines].first_token_idx = data->num_tokens; | 769 | data->num_sublines; |
770 | |||
771 | data->sublines[data->num_sublines].first_token_idx = | ||
772 | data->num_tokens; | ||
763 | } | 773 | } |
764 | 774 | ||
765 | break; | 775 | break; |
@@ -771,7 +781,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) | |||
771 | const char *string_start = wps_bufptr - 1; | 781 | const char *string_start = wps_bufptr - 1; |
772 | 782 | ||
773 | /* find the length of the string */ | 783 | /* find the length of the string */ |
774 | while (wps_bufptr && *wps_bufptr != '#' && | 784 | while (*wps_bufptr && *wps_bufptr != '#' && |
775 | *wps_bufptr != '%' && *wps_bufptr != ';' && | 785 | *wps_bufptr != '%' && *wps_bufptr != ';' && |
776 | *wps_bufptr != '<' && *wps_bufptr != '>' && | 786 | *wps_bufptr != '<' && *wps_bufptr != '>' && |
777 | *wps_bufptr != '|' && *wps_bufptr != '\n') | 787 | *wps_bufptr != '|' && *wps_bufptr != '\n') |
@@ -812,7 +822,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) | |||
812 | data->strings[data->num_strings] = stringbuf; | 822 | data->strings[data->num_strings] = stringbuf; |
813 | stringbuf += len + 1; | 823 | stringbuf += len + 1; |
814 | stringbuf_used += len + 1; | 824 | stringbuf_used += len + 1; |
815 | data->tokens[data->num_tokens].value.i = data->num_strings; | 825 | data->tokens[data->num_tokens].value.i = |
826 | data->num_strings; | ||
816 | data->num_strings++; | 827 | data->num_strings++; |
817 | } | 828 | } |
818 | else | 829 | else |
@@ -1021,7 +1032,8 @@ bool wps_data_load(struct wps_data *wps_data, | |||
1021 | if (!wps_buffer) | 1032 | if (!wps_buffer) |
1022 | return false; | 1033 | return false; |
1023 | 1034 | ||
1024 | /* copy the file's content to the buffer for parsing */ | 1035 | /* copy the file's content to the buffer for parsing, |
1036 | ensuring that every line ends with a newline char. */ | ||
1025 | unsigned int start = 0; | 1037 | unsigned int start = 0; |
1026 | while(read_line(fd, wps_buffer + start, buffersize - start) > 0) | 1038 | while(read_line(fd, wps_buffer + start, buffersize - start) > 0) |
1027 | { | 1039 | { |