summaryrefslogtreecommitdiff
path: root/apps/gui/wps_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps_parser.c')
-rw-r--r--apps/gui/wps_parser.c76
1 files changed, 44 insertions, 32 deletions
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 {