Rename h100 specific screenshots so they are used again
[kugel-rb.git] / tools / checkwps / checkwps.c
blob17098d2b06be8a472fa8b724373de686dc80ab23
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <fcntl.h>
25 #include "config.h"
26 #include "gwps.h"
27 #include "checkwps.h"
28 #include "resize.h"
30 bool debug_wps = true;
31 int wps_verbose_level = 0;
33 int errno;
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;
51 if (*ch == 0x34)
53 /* Little-endian */
54 return x;
55 } else {
56 return SWAP_16(x);
60 unsigned short letoh32(unsigned short x)
62 unsigned short n = 0x1234;
63 unsigned char* ch = (unsigned char*)&n;
65 if (*ch == 0x34)
67 /* Little-endian */
68 return x;
69 } else {
70 return SWAP_32(x);
74 unsigned int htole32(unsigned int x)
76 unsigned short n = 0x1234;
77 unsigned char* ch = (unsigned char*)&n;
79 if (*ch == 0x34)
81 /* Little-endian */
82 return x;
83 } else {
84 return SWAP_32(x);
88 int read_line(int fd, char* buffer, int buffer_size)
90 int count = 0;
91 int num_read = 0;
93 errno = 0;
95 while (count < buffer_size)
97 unsigned char c;
99 if (1 != read(fd, &c, 1))
100 break;
102 num_read++;
104 if ( c == '\n' )
105 break;
107 if ( c == '\r' )
108 continue;
110 buffer[count++] = c;
113 buffer[MIN(count, buffer_size - 1)] = 0;
115 return errno ? -1 : num_read;
118 bool load_wps_backdrop(const char* filename)
120 return true;
123 bool load_remote_wps_backdrop(const char* filename)
125 return true;
128 int recalc_dimension(struct dim *dst, struct dim *src)
130 return 0;
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),
137 void *args)
139 return 0;
142 int audio_status(void)
144 return 0;
147 struct mp3entry* audio_current_track(void)
149 return NULL;
152 void audio_stop(void)
156 void audio_play(long offset)
160 static char pluginbuf[PLUGIN_BUFFER_SIZE];
162 static unsigned dummy_func2(void)
164 return 0;
167 void* plugin_get_buffer(size_t *buffer_size)
169 *buffer_size = PLUGIN_BUFFER_SIZE;
170 return pluginbuf;
172 struct user_settings global_settings = {
173 .statusbar = true,
174 #ifdef HAVE_LCD_COLOR
175 .bg_color = LCD_DEFAULT_BG,
176 .fg_color = LCD_DEFAULT_FG,
177 #endif
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; }
185 #endif
187 struct screen screens[NB_SCREENS] =
190 .screen_type=SCREEN_MAIN,
191 .lcdwidth=LCD_WIDTH,
192 .lcdheight=LCD_HEIGHT,
193 .depth=LCD_DEPTH,
194 #ifdef HAVE_LCD_COLOR
195 .is_color=true,
196 #else
197 .is_color=false,
198 #endif
199 .getwidth = getwidth,
200 .getheight = getheight,
201 #if LCD_DEPTH > 1
202 .get_foreground=dummy_func2,
203 .get_background=dummy_func2,
204 #endif
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,
218 #endif
220 #endif
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);
231 #endif
234 int main(int argc, char **argv)
236 int res;
237 int fd;
238 int filearg = 1;
240 struct wps_data wps;
242 /* No arguments -> print the help text
243 * Also print the help text upon -h or --help */
244 if( (argc < 2) ||
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");
254 return 1;
257 if (argv[1][0] == '-') {
258 filearg++;
259 int i = 1;
260 while (argv[1][i] && argv[1][i] == 'v') {
261 i++;
262 wps_verbose_level++;
266 fd = open(argv[filearg], O_RDONLY);
267 if (fd < 0) {
268 printf("Failed to open %s\n",argv[1]);
269 return 2;
271 close(fd);
273 /* Go through every wps that was thrown at us, error out at the first
274 * flawed wps */
275 while (argv[filearg]) {
276 printf("Checking %s...\n", argv[filearg]);
277 res = wps_data_load(&wps, &screens[0], argv[filearg], true);
279 if (!res) {
280 printf("WPS parsing failure\n");
281 return 3;
284 printf("WPS parsed OK\n\n");
285 filearg++;
287 return 0;