1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Dave Chapman
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 ****************************************************************************/
30 bool debug_wps
= true;
31 int wps_verbose_level
= 0;
35 const struct settings_list
*settings
;
36 const int nb_settings
= 0;
38 /* static endianness conversion */
39 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
40 ((unsigned short)(x) << 8)))
42 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
43 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
44 (((unsigned long)(x) & 0xff00ul) << 8) | \
45 ((unsigned long)(x) << 24)))
46 unsigned short letoh16(unsigned short x
)
48 unsigned short n
= 0x1234;
49 unsigned char* ch
= (unsigned char*)&n
;
60 unsigned short letoh32(unsigned short x
)
62 unsigned short n
= 0x1234;
63 unsigned char* ch
= (unsigned char*)&n
;
74 unsigned int htole32(unsigned int x
)
76 unsigned short n
= 0x1234;
77 unsigned char* ch
= (unsigned char*)&n
;
88 int read_line(int fd
, char* buffer
, int buffer_size
)
95 while (count
< buffer_size
)
99 if (1 != read(fd
, &c
, 1))
113 buffer
[MIN(count
, buffer_size
- 1)] = 0;
115 return errno
? -1 : num_read
;
118 bool load_wps_backdrop(const char* filename
)
123 bool load_remote_wps_backdrop(const char* filename
)
128 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
133 int resize_on_load(struct bitmap
*bm
, bool dither
, struct dim
*src
,
134 struct rowset
*rset
, unsigned char *buf
, unsigned int len
,
135 const struct custom_format
*format
,
136 struct img_part
* (*store_part
)(void *args
),
142 int audio_status(void)
147 struct mp3entry
* audio_current_track(void)
152 void audio_stop(void)
156 void audio_play(long offset
)
160 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
162 static unsigned dummy_func2(void)
167 void* plugin_get_buffer(size_t *buffer_size
)
169 *buffer_size
= PLUGIN_BUFFER_SIZE
;
172 struct user_settings global_settings
= {
174 #ifdef HAVE_LCD_COLOR
175 .bg_color
= LCD_DEFAULT_BG
,
176 .fg_color
= LCD_DEFAULT_FG
,
180 int getwidth(void) { return LCD_WIDTH
; }
181 int getheight(void) { return LCD_HEIGHT
; }
182 #ifdef HAVE_REMOTE_LCD
183 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
184 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
187 struct screen screens
[NB_SCREENS
] =
190 .screen_type
=SCREEN_MAIN
,
192 .lcdheight
=LCD_HEIGHT
,
194 #ifdef HAVE_LCD_COLOR
199 .getwidth
= getwidth
,
200 .getheight
= getheight
,
202 .get_foreground
=dummy_func2
,
203 .get_background
=dummy_func2
,
206 #ifdef HAVE_REMOTE_LCD
208 .screen_type
=SCREEN_REMOTE
,
209 .lcdwidth
=LCD_REMOTE_WIDTH
,
210 .lcdheight
=LCD_REMOTE_HEIGHT
,
211 .depth
=LCD_REMOTE_DEPTH
,
212 .is_color
=false,/* No color remotes yet */
213 .getwidth
= remote_getwidth
,
214 .getheight
= remote_getheight
,
215 #if LCD_REMOTE_DEPTH > 1
216 .get_foreground
=dummy_func2
,
217 .get_background
=dummy_func2
,
223 #ifdef HAVE_LCD_BITMAP
224 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
225 int width
, int height
)
227 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
228 display
->fillrect(xstart
, ystart
, width
, height
);
229 display
->set_drawmode(DRMODE_SOLID
);
234 int main(int argc
, char **argv
)
242 /* No arguments -> print the help text
243 * Also print the help text upon -h or --help */
245 strcmp(argv
[1],"-h") == 0 ||
246 strcmp(argv
[1],"--help") == 0 )
248 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
249 printf("\nOPTIONS:\n");
250 printf("\t-v\t\tverbose\n");
251 printf("\t-vv\t\tmore verbose\n");
252 printf("\t-vvv\t\tvery verbose\n");
253 printf("\t-h,\t--help\tshow this message\n");
257 if (argv
[1][0] == '-') {
260 while (argv
[1][i
] && argv
[1][i
] == 'v') {
266 fd
= open(argv
[filearg
], O_RDONLY
);
268 printf("Failed to open %s\n",argv
[1]);
273 /* Go through every wps that was thrown at us, error out at the first
275 while (argv
[filearg
]) {
276 printf("Checking %s...\n", argv
[filearg
]);
277 res
= wps_data_load(&wps
, &screens
[0], argv
[filearg
], true);
280 printf("WPS parsing failure\n");
284 printf("WPS parsed OK\n\n");