Manual: Very slight alteration to the mp3 encoder plugin entry.
[maemo-rb.git] / tools / checkwps / checkwps.c
blob39d4358320ff8932599acdcc3a8fba62dadcd234
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_buffer.h"
30 #include "skin_debug.h"
31 #include "skin_engine.h"
32 #include "wps_internals.h"
33 #include "settings.h"
34 #include "viewport.h"
35 #include "file.h"
36 #include "font.h"
38 bool debug_wps = true;
39 int wps_verbose_level = 0;
41 int errno;
43 const struct settings_list *settings;
44 const int nb_settings = 0;
46 /* static endianness conversion */
47 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
48 ((unsigned short)(x) << 8)))
50 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
51 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
52 (((unsigned long)(x) & 0xff00ul) << 8) | \
53 ((unsigned long)(x) << 24)))
55 #ifndef letoh16
56 unsigned short letoh16(unsigned short x)
58 unsigned short n = 0x1234;
59 unsigned char* ch = (unsigned char*)&n;
61 if (*ch == 0x34)
63 /* Little-endian */
64 return x;
65 } else {
66 return SWAP_16(x);
69 #endif
71 #ifndef letoh32
72 unsigned short letoh32(unsigned short x)
74 unsigned short n = 0x1234;
75 unsigned char* ch = (unsigned char*)&n;
77 if (*ch == 0x34)
79 /* Little-endian */
80 return x;
81 } else {
82 return SWAP_32(x);
85 #endif
87 #ifndef htole32
88 unsigned int htole32(unsigned int x)
90 unsigned short n = 0x1234;
91 unsigned char* ch = (unsigned char*)&n;
93 if (*ch == 0x34)
95 /* Little-endian */
96 return x;
97 } else {
98 return SWAP_32(x);
101 #endif
103 int recalc_dimension(struct dim *dst, struct dim *src)
105 return 0;
108 #ifdef HAVE_ALBUMART
109 int playback_claim_aa_slot(struct dim *dim)
111 return 0;
114 void playback_release_aa_slot(int slot)
116 return;
118 #endif
120 int resize_on_load(struct bitmap *bm, bool dither,
121 struct dim *src, struct rowset *tmp_row,
122 unsigned char *buf, unsigned int len,
123 const struct custom_format *cformat,
124 IF_PIX_FMT(int format_index,)
125 struct img_part* (*store_part)(void *args),
126 void *args)
128 return 0;
131 static char pluginbuf[PLUGIN_BUFFER_SIZE];
133 static unsigned dummy_func2(void)
135 return 0;
138 void* plugin_get_buffer(size_t *buffer_size)
140 *buffer_size = PLUGIN_BUFFER_SIZE;
141 return pluginbuf;
144 struct user_settings global_settings = {
145 .statusbar = STATUSBAR_TOP,
146 #ifdef HAVE_LCD_COLOR
147 .bg_color = LCD_DEFAULT_BG,
148 .fg_color = LCD_DEFAULT_FG,
149 #endif
152 int getwidth(void) { return LCD_WIDTH; }
153 int getheight(void) { return LCD_HEIGHT; }
154 #ifdef HAVE_REMOTE_LCD
155 int remote_getwidth(void) { return LCD_REMOTE_WIDTH; }
156 int remote_getheight(void) { return LCD_REMOTE_HEIGHT; }
157 #endif
159 static inline bool backdrop_load(const char *filename, char* backdrop_buffer)
161 (void)filename; (void)backdrop_buffer; return true;
164 struct screen screens[NB_SCREENS] =
167 .screen_type=SCREEN_MAIN,
168 .lcdwidth=LCD_WIDTH,
169 .lcdheight=LCD_HEIGHT,
170 .depth=LCD_DEPTH,
171 #ifdef HAVE_LCD_COLOR
172 .is_color=true,
173 #else
174 .is_color=false,
175 #endif
176 .getwidth = getwidth,
177 .getheight = getheight,
178 #if LCD_DEPTH > 1
179 .get_foreground=dummy_func2,
180 .get_background=dummy_func2,
181 .backdrop_load=backdrop_load,
182 #endif
184 #ifdef HAVE_REMOTE_LCD
186 .screen_type=SCREEN_REMOTE,
187 .lcdwidth=LCD_REMOTE_WIDTH,
188 .lcdheight=LCD_REMOTE_HEIGHT,
189 .depth=LCD_REMOTE_DEPTH,
190 .is_color=false,/* No color remotes yet */
191 .getwidth=remote_getwidth,
192 .getheight=remote_getheight,
193 #if LCD_REMOTE_DEPTH > 1
194 .get_foreground=dummy_func2,
195 .get_background=dummy_func2,
196 .backdrop_load=backdrop_load,
197 #endif
199 #endif
202 #ifdef HAVE_LCD_BITMAP
203 void screen_clear_area(struct screen * display, int xstart, int ystart,
204 int width, int height)
206 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
207 display->fillrect(xstart, ystart, width, height);
208 display->set_drawmode(DRMODE_SOLID);
210 #endif
212 #if CONFIG_TUNER
213 bool radio_hardware_present(void)
215 return true;
217 #endif
219 #ifdef HAVE_LCD_BITMAP
220 static int loaded_fonts = 0;
221 int font_load(struct font* pf, const char *path)
223 int id = SYSTEMFONTCOUNT + loaded_fonts;
224 loaded_fonts++;
225 return id;
228 void font_unload(int font_id)
230 (void)font_id;
232 #endif
234 int main(int argc, char **argv)
236 int res;
237 int filearg = 1;
239 struct wps_data wps={0};
240 enum screen_type screen = SCREEN_MAIN;
241 struct screen* wps_screen;
243 char* buffer = NULL;
245 /* No arguments -> print the help text
246 * Also print the help text upon -h or --help */
247 if( (argc < 2) ||
248 strcmp(argv[1],"-h") == 0 ||
249 strcmp(argv[1],"--help") == 0 )
251 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
252 printf("\nOPTIONS:\n");
253 printf("\t-v\t\tverbose\n");
254 printf("\t-vv\t\tmore verbose\n");
255 printf("\t-vvv\t\tvery verbose\n");
256 printf("\t-h,\t--help\tshow this message\n");
257 return 1;
260 if (argv[1][0] == '-') {
261 filearg++;
262 int i = 1;
263 while (argv[1][i] && argv[1][i] == 'v') {
264 i++;
265 wps_verbose_level++;
268 buffer = malloc(SKIN_BUFFER_SIZE);
269 if (!buffer)
271 printf("mallloc fail!\n");
272 return 1;
275 skin_buffer_init(buffer, SKIN_BUFFER_SIZE);
276 #ifdef HAVE_LCD_BITMAP
277 skin_font_init();
278 #endif
280 /* Go through every skin that was thrown at us, error out at the first
281 * flawed wps */
282 while (argv[filearg]) {
283 printf("Checking %s...\n", argv[filearg]);
284 #ifdef HAVE_REMOTE_LCD
285 if((strcmp(&argv[filearg][strlen(argv[filearg])-4], "rwps") == 0) ||
286 (strcmp(&argv[filearg][strlen(argv[filearg])-4], "rsbs") == 0) ||
287 (strcmp(&argv[filearg][strlen(argv[filearg])-4], "rfms") == 0))
288 screen = SCREEN_REMOTE;
289 else
290 screen = SCREEN_MAIN;
291 #endif
292 wps_screen = &screens[screen];
294 res = skin_data_load(screen, &wps, argv[filearg], true);
296 if (!res) {
297 printf("WPS parsing failure\n");
298 skin_error_format_message();
299 return 3;
302 printf("WPS parsed OK\n\n");
303 if (wps_verbose_level>2)
304 skin_debug_tree(wps.tree);
305 filearg++;
307 return 0;