Add Insert Shuffled to hotkey options
[kugel-rb.git] / tools / checkwps / checkwps.c
blob6760d6215e478a5e11e9411374000789088f266d
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 <string.h>
25 #include "config.h"
26 #include "checkwps.h"
27 #include "resize.h"
28 #include "wps.h"
29 #include "skin_engine.h"
30 #include "wps_internals.h"
31 #include "settings.h"
32 #include "viewport.h"
33 #include "file.h"
34 #include "font.h"
36 bool debug_wps = true;
37 int wps_verbose_level = 0;
39 int errno;
41 const struct settings_list *settings;
42 const int nb_settings = 0;
44 /* static endianness conversion */
45 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
46 ((unsigned short)(x) << 8)))
48 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
49 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
50 (((unsigned long)(x) & 0xff00ul) << 8) | \
51 ((unsigned long)(x) << 24)))
53 #ifndef letoh16
54 unsigned short letoh16(unsigned short x)
56 unsigned short n = 0x1234;
57 unsigned char* ch = (unsigned char*)&n;
59 if (*ch == 0x34)
61 /* Little-endian */
62 return x;
63 } else {
64 return SWAP_16(x);
67 #endif
69 #ifndef letoh32
70 unsigned short letoh32(unsigned short x)
72 unsigned short n = 0x1234;
73 unsigned char* ch = (unsigned char*)&n;
75 if (*ch == 0x34)
77 /* Little-endian */
78 return x;
79 } else {
80 return SWAP_32(x);
83 #endif
85 #ifndef htole32
86 unsigned int htole32(unsigned int x)
88 unsigned short n = 0x1234;
89 unsigned char* ch = (unsigned char*)&n;
91 if (*ch == 0x34)
93 /* Little-endian */
94 return x;
95 } else {
96 return SWAP_32(x);
99 #endif
101 int recalc_dimension(struct dim *dst, struct dim *src)
103 return 0;
106 #ifdef HAVE_ALBUMART
107 int playback_claim_aa_slot(struct dim *dim)
109 return 0;
112 void playback_release_aa_slot(int slot)
114 return;
116 #endif
118 int resize_on_load(struct bitmap *bm, bool dither,
119 struct dim *src, struct rowset *tmp_row,
120 unsigned char *buf, unsigned int len,
121 const struct custom_format *cformat,
122 IF_PIX_FMT(int format_index,)
123 struct img_part* (*store_part)(void *args),
124 void *args)
126 return 0;
129 static char pluginbuf[PLUGIN_BUFFER_SIZE];
131 static unsigned dummy_func2(void)
133 return 0;
136 void* plugin_get_buffer(size_t *buffer_size)
138 *buffer_size = PLUGIN_BUFFER_SIZE;
139 return pluginbuf;
142 struct user_settings global_settings = {
143 .statusbar = STATUSBAR_TOP,
144 #ifdef HAVE_LCD_COLOR
145 .bg_color = LCD_DEFAULT_BG,
146 .fg_color = LCD_DEFAULT_FG,
147 #endif
150 int getwidth(void) { return LCD_WIDTH; }
151 int getheight(void) { return LCD_HEIGHT; }
152 #ifdef HAVE_REMOTE_LCD
153 int remote_getwidth(void) { return LCD_REMOTE_WIDTH; }
154 int remote_getheight(void) { return LCD_REMOTE_HEIGHT; }
155 #endif
157 static inline bool backdrop_load(const char *filename, char* backdrop_buffer)
159 (void)filename; (void)backdrop_buffer; return true;
162 struct screen screens[NB_SCREENS] =
165 .screen_type=SCREEN_MAIN,
166 .lcdwidth=LCD_WIDTH,
167 .lcdheight=LCD_HEIGHT,
168 .depth=LCD_DEPTH,
169 #ifdef HAVE_LCD_COLOR
170 .is_color=true,
171 #else
172 .is_color=false,
173 #endif
174 .getwidth = getwidth,
175 .getheight = getheight,
176 #if LCD_DEPTH > 1
177 .get_foreground=dummy_func2,
178 .get_background=dummy_func2,
179 .backdrop_load=backdrop_load,
180 #endif
182 #ifdef HAVE_REMOTE_LCD
184 .screen_type=SCREEN_REMOTE,
185 .lcdwidth=LCD_REMOTE_WIDTH,
186 .lcdheight=LCD_REMOTE_HEIGHT,
187 .depth=LCD_REMOTE_DEPTH,
188 .is_color=false,/* No color remotes yet */
189 .getwidth=remote_getwidth,
190 .getheight=remote_getheight,
191 #if LCD_REMOTE_DEPTH > 1
192 .get_foreground=dummy_func2,
193 .get_background=dummy_func2,
194 .backdrop_load=backdrop_load,
195 #endif
197 #endif
200 #ifdef HAVE_LCD_BITMAP
201 void screen_clear_area(struct screen * display, int xstart, int ystart,
202 int width, int height)
204 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
205 display->fillrect(xstart, ystart, width, height);
206 display->set_drawmode(DRMODE_SOLID);
208 #endif
210 #ifdef HAVE_LCD_BITMAP
211 static int loaded_fonts = 0;
212 int font_load(struct font* pf, const char *path)
214 int id = SYSTEMFONTCOUNT + loaded_fonts;
215 loaded_fonts++;
216 return id;
219 void font_unload(int font_id)
221 (void)font_id;
223 #endif
225 int main(int argc, char **argv)
227 int res;
228 int filearg = 1;
230 struct wps_data wps;
231 enum screen_type screen = SCREEN_MAIN;
232 struct screen* wps_screen;
234 /* No arguments -> print the help text
235 * Also print the help text upon -h or --help */
236 if( (argc < 2) ||
237 strcmp(argv[1],"-h") == 0 ||
238 strcmp(argv[1],"--help") == 0 )
240 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
241 printf("\nOPTIONS:\n");
242 printf("\t-v\t\tverbose\n");
243 printf("\t-vv\t\tmore verbose\n");
244 printf("\t-vvv\t\tvery verbose\n");
245 printf("\t-h,\t--help\tshow this message\n");
246 return 1;
249 if (argv[1][0] == '-') {
250 filearg++;
251 int i = 1;
252 while (argv[1][i] && argv[1][i] == 'v') {
253 i++;
254 wps_verbose_level++;
258 skin_buffer_init();
259 #ifdef HAVE_LCD_BITMAP
260 skin_font_init();
261 #endif
263 /* Go through every wps that was thrown at us, error out at the first
264 * flawed wps */
265 while (argv[filearg]) {
266 printf("Checking %s...\n", argv[filearg]);
267 #ifdef HAVE_REMOTE_LCD
268 if((strcmp(&argv[filearg][strlen(argv[filearg])-4], "rwps") == 0) ||
269 (strcmp(&argv[filearg][strlen(argv[filearg])-4], "rsbs") == 0))
270 screen = SCREEN_REMOTE;
271 else
272 screen = SCREEN_MAIN;
273 #endif
274 wps_screen = &screens[screen];
276 res = skin_data_load(screen, &wps, argv[filearg], true);
278 if (!res) {
279 printf("WPS parsing failure\n");
280 return 3;
283 printf("WPS parsed OK\n\n");
284 filearg++;
286 return 0;