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 ****************************************************************************/
29 #define MIN(x,y) ((x) > (y) ? (y) : (x))
31 bool debug_wps
= true;
32 int wps_verbose_level
= 0;
36 /* static endianness conversion */
37 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
38 ((unsigned short)(x) << 8)))
40 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
41 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
42 (((unsigned long)(x) & 0xff00ul) << 8) | \
43 ((unsigned long)(x) << 24)))
44 unsigned short letoh16(unsigned short x
)
46 unsigned short n
= 0x1234;
47 unsigned char* ch
= (unsigned char*)&n
;
58 unsigned int htole32(unsigned int x
)
60 unsigned short n
= 0x1234;
61 unsigned char* ch
= (unsigned char*)&n
;
72 int read_line(int fd
, char* buffer
, int buffer_size
)
79 while (count
< buffer_size
)
83 if (1 != read(fd
, &c
, 1))
97 buffer
[MIN(count
, buffer_size
- 1)] = 0;
99 return errno
? -1 : num_read
;
102 bool load_wps_backdrop(const char* filename
)
107 bool load_remote_wps_backdrop(const char* filename
)
112 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
114 static unsigned dummy_func2(void)
119 void* plugin_get_buffer(size_t *buffer_size
)
121 *buffer_size
= PLUGIN_BUFFER_SIZE
;
124 struct user_settings global_settings
= {
126 #ifdef HAVE_LCD_COLOR
127 .bg_color
= LCD_DEFAULT_BG
,
128 .fg_color
= LCD_DEFAULT_FG
,
132 int getwidth(void) { return LCD_WIDTH
; }
133 int getheight(void) { return LCD_HEIGHT
; }
134 #ifdef HAVE_REMOTE_LCD
135 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
136 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
139 struct screen screens
[NB_SCREENS
] =
142 .screen_type
=SCREEN_MAIN
,
144 .lcdheight
=LCD_HEIGHT
,
146 #ifdef HAVE_LCD_COLOR
151 .getwidth
= getwidth
,
152 .getheight
= getheight
,
154 .get_foreground
=dummy_func2
,
155 .get_background
=dummy_func2
,
158 #ifdef HAVE_REMOTE_LCD
160 .screen_type
=SCREEN_REMOTE
,
161 .lcdwidth
=LCD_REMOTE_WIDTH
,
162 .lcdheight
=LCD_REMOTE_HEIGHT
,
163 .depth
=LCD_REMOTE_DEPTH
,
164 .is_color
=false,/* No color remotes yet */
165 .getwidth
= remote_getwidth
,
166 .getheight
= remote_getheight
,
167 #if LCD_REMOTE_DEPTH > 1
168 .get_foreground
=dummy_func2
,
169 .get_background
=dummy_func2
,
175 #ifdef HAVE_LCD_BITMAP
176 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
177 int width
, int height
)
179 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
180 display
->fillrect(xstart
, ystart
, width
, height
);
181 display
->set_drawmode(DRMODE_SOLID
);
186 int main(int argc
, char **argv
)
194 /* No arguments -> print the help text
195 * Also print the help text upon -h or --help */
197 strcmp(argv
[1],"-h") == 0 ||
198 strcmp(argv
[1],"--help") == 0 )
200 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
201 printf("\nOPTIONS:\n");
202 printf("\t-v\t\tverbose\n");
203 printf("\t-vv\t\tmore verbose\n");
204 printf("\t-vvv\t\tvery verbose\n");
205 printf("\t-h,\t--help\tshow this message\n");
209 if (argv
[1][0] == '-') {
212 while (argv
[1][i
] && argv
[1][i
] == 'v') {
218 fd
= open(argv
[filearg
], O_RDONLY
);
220 printf("Failed to open %s\n",argv
[1]);
225 /* Go through every wps that was thrown at us, error out at the first
227 while (argv
[filearg
]) {
228 printf("Checking %s...\n", argv
[filearg
]);
229 res
= wps_data_load(&wps
, &screens
[0], argv
[filearg
], true);
232 printf("WPS parsing failure\n");
236 printf("WPS parsed OK\n\n");