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)))
48 unsigned short letoh16(unsigned short x
)
50 unsigned short n
= 0x1234;
51 unsigned char* ch
= (unsigned char*)&n
;
64 unsigned short letoh32(unsigned short x
)
66 unsigned short n
= 0x1234;
67 unsigned char* ch
= (unsigned char*)&n
;
80 unsigned int htole32(unsigned int x
)
82 unsigned short n
= 0x1234;
83 unsigned char* ch
= (unsigned char*)&n
;
95 int read_line(int fd
, char* buffer
, int buffer_size
)
102 while (count
< buffer_size
)
106 if (1 != read(fd
, &c
, 1))
120 buffer
[MIN(count
, buffer_size
- 1)] = 0;
122 return errno
? -1 : num_read
;
125 bool load_wps_backdrop(const char* filename
)
130 bool load_remote_wps_backdrop(const char* filename
)
135 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
140 int resize_on_load(struct bitmap
*bm
, bool dither
, struct dim
*src
,
141 struct rowset
*rset
, unsigned char *buf
, unsigned int len
,
142 const struct custom_format
*format
,
143 struct img_part
* (*store_part
)(void *args
),
149 int audio_status(void)
154 struct mp3entry
* audio_current_track(void)
159 void audio_stop(void)
163 void audio_play(long offset
)
167 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
169 static unsigned dummy_func2(void)
174 void* plugin_get_buffer(size_t *buffer_size
)
176 *buffer_size
= PLUGIN_BUFFER_SIZE
;
179 struct user_settings global_settings
= {
181 #ifdef HAVE_LCD_COLOR
182 .bg_color
= LCD_DEFAULT_BG
,
183 .fg_color
= LCD_DEFAULT_FG
,
187 int getwidth(void) { return LCD_WIDTH
; }
188 int getheight(void) { return LCD_HEIGHT
; }
189 #ifdef HAVE_REMOTE_LCD
190 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
191 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
194 struct screen screens
[NB_SCREENS
] =
197 .screen_type
=SCREEN_MAIN
,
199 .lcdheight
=LCD_HEIGHT
,
201 #ifdef HAVE_LCD_COLOR
206 .getwidth
= getwidth
,
207 .getheight
= getheight
,
209 .get_foreground
=dummy_func2
,
210 .get_background
=dummy_func2
,
213 #ifdef HAVE_REMOTE_LCD
215 .screen_type
=SCREEN_REMOTE
,
216 .lcdwidth
=LCD_REMOTE_WIDTH
,
217 .lcdheight
=LCD_REMOTE_HEIGHT
,
218 .depth
=LCD_REMOTE_DEPTH
,
219 .is_color
=false,/* No color remotes yet */
220 .getwidth
= remote_getwidth
,
221 .getheight
= remote_getheight
,
222 #if LCD_REMOTE_DEPTH > 1
223 .get_foreground
=dummy_func2
,
224 .get_background
=dummy_func2
,
230 #ifdef HAVE_LCD_BITMAP
231 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
232 int width
, int height
)
234 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
235 display
->fillrect(xstart
, ystart
, width
, height
);
236 display
->set_drawmode(DRMODE_SOLID
);
241 int main(int argc
, char **argv
)
249 /* No arguments -> print the help text
250 * Also print the help text upon -h or --help */
252 strcmp(argv
[1],"-h") == 0 ||
253 strcmp(argv
[1],"--help") == 0 )
255 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
256 printf("\nOPTIONS:\n");
257 printf("\t-v\t\tverbose\n");
258 printf("\t-vv\t\tmore verbose\n");
259 printf("\t-vvv\t\tvery verbose\n");
260 printf("\t-h,\t--help\tshow this message\n");
264 if (argv
[1][0] == '-') {
267 while (argv
[1][i
] && argv
[1][i
] == 'v') {
273 fd
= open(argv
[filearg
], O_RDONLY
);
275 printf("Failed to open %s\n",argv
[1]);
280 /* Go through every wps that was thrown at us, error out at the first
282 while (argv
[filearg
]) {
283 printf("Checking %s...\n", argv
[filearg
]);
284 res
= wps_data_load(&wps
, &screens
[0], argv
[filearg
], true);
287 printf("WPS parsing failure\n");
291 printf("WPS parsed OK\n\n");