diff options
author | Dave Chapman <dave@dchapman.com> | 2008-03-26 20:19:39 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-03-26 20:19:39 +0000 |
commit | 3d88eddb833d75b8d7a2c57fcc407530a5f8a57e (patch) | |
tree | 6969c420408dd8f329354e89b214ab375cd7d832 /tools/checkwps | |
parent | 2ce440d740a2f9a1f496729c7d67bcaff281a5ea (diff) | |
download | rockbox-3d88eddb833d75b8d7a2c57fcc407530a5f8a57e.tar.gz rockbox-3d88eddb833d75b8d7a2c57fcc407530a5f8a57e.zip |
Move checkwps to its own subdir in preparation for compiling target-specific versions. Also remove a DEBUGF that should not have been left in.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16827 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/checkwps')
-rw-r--r-- | tools/checkwps/Makefile | 18 | ||||
-rw-r--r-- | tools/checkwps/checkwps.c | 184 |
2 files changed, 202 insertions, 0 deletions
diff --git a/tools/checkwps/Makefile b/tools/checkwps/Makefile new file mode 100644 index 0000000000..a64196d456 --- /dev/null +++ b/tools/checkwps/Makefile | |||
@@ -0,0 +1,18 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id: Makefile 16822 2008-03-26 18:18:22Z dave $ | ||
8 | # | ||
9 | |||
10 | all: checkwps | ||
11 | |||
12 | checkwps: checkwps.c ../../apps/gui/wps_parser.c ../../apps/gui/wps_debug.c ../../firmware/common/ctype.c ../../apps/misc.c ../../apps/recorder/bmp.c | ||
13 | $(SILENT)$(CC) -g -I ../../apps/gui -I../../firmware/export \ | ||
14 | -D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \ | ||
15 | -I../../apps -I../../firmware/target/arm/ipod -I../../firmware/include $+ -o $@ | ||
16 | |||
17 | clean: | ||
18 | rm -f cleanwps | ||
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c new file mode 100644 index 0000000000..ddaaf49b73 --- /dev/null +++ b/tools/checkwps/checkwps.c | |||
@@ -0,0 +1,184 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include "gwps.h" | ||
4 | |||
5 | #define MIN(x,y) ((x) > (y) ? (y) : (x)) | ||
6 | |||
7 | bool debug_wps = true; | ||
8 | int wps_verbose_level = 0; | ||
9 | |||
10 | int errno; | ||
11 | |||
12 | /* static endianness conversion */ | ||
13 | #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ | ||
14 | ((unsigned short)(x) << 8))) | ||
15 | |||
16 | #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \ | ||
17 | (((unsigned long)(x) & 0xff0000ul) >> 8) | \ | ||
18 | (((unsigned long)(x) & 0xff00ul) << 8) | \ | ||
19 | ((unsigned long)(x) << 24))) | ||
20 | unsigned short letoh16(unsigned short x) | ||
21 | { | ||
22 | unsigned short n = 0x1234; | ||
23 | unsigned char* ch = &n; | ||
24 | |||
25 | if (*ch == 0x34) | ||
26 | { | ||
27 | /* Little-endian */ | ||
28 | return x; | ||
29 | } else { | ||
30 | return SWAP_16(x); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | unsigned int htole32(unsigned int x) | ||
35 | { | ||
36 | unsigned short n = 0x1234; | ||
37 | unsigned char* ch = &n; | ||
38 | |||
39 | if (*ch == 0x34) | ||
40 | { | ||
41 | /* Little-endian */ | ||
42 | return x; | ||
43 | } else { | ||
44 | return SWAP_32(x); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | int read_line(int fd, char* buffer, int buffer_size) | ||
49 | { | ||
50 | int count = 0; | ||
51 | int num_read = 0; | ||
52 | |||
53 | errno = 0; | ||
54 | |||
55 | while (count < buffer_size) | ||
56 | { | ||
57 | unsigned char c; | ||
58 | |||
59 | if (1 != read(fd, &c, 1)) | ||
60 | break; | ||
61 | |||
62 | num_read++; | ||
63 | |||
64 | if ( c == '\n' ) | ||
65 | break; | ||
66 | |||
67 | if ( c == '\r' ) | ||
68 | continue; | ||
69 | |||
70 | buffer[count++] = c; | ||
71 | } | ||
72 | |||
73 | buffer[MIN(count, buffer_size - 1)] = 0; | ||
74 | |||
75 | return errno ? -1 : num_read; | ||
76 | } | ||
77 | |||
78 | bool load_wps_backdrop(char* filename) | ||
79 | { | ||
80 | return true; | ||
81 | } | ||
82 | |||
83 | static char pluginbuf[PLUGIN_BUFFER_SIZE]; | ||
84 | |||
85 | static int dummy_func1(void) | ||
86 | { | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static unsigned dummy_func2(void) | ||
91 | { | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | void* plugin_get_buffer(size_t *buffer_size) | ||
96 | { | ||
97 | *buffer_size = PLUGIN_BUFFER_SIZE; | ||
98 | return pluginbuf; | ||
99 | } | ||
100 | |||
101 | struct screen screens[NB_SCREENS] = | ||
102 | { | ||
103 | { | ||
104 | .screen_type=SCREEN_MAIN, | ||
105 | .width=LCD_WIDTH, | ||
106 | .height=LCD_HEIGHT, | ||
107 | .depth=LCD_DEPTH, | ||
108 | .is_color=true, | ||
109 | .has_disk_led=false, | ||
110 | .getxmargin=dummy_func1, | ||
111 | .getymargin=dummy_func1, | ||
112 | .get_foreground=dummy_func2, | ||
113 | .get_background=dummy_func2, | ||
114 | }, | ||
115 | #ifdef HAVE_REMOTE_LCD | ||
116 | { | ||
117 | .screen_type=SCREEN_REMOTE, | ||
118 | .width=LCD_REMOTE_WIDTH, | ||
119 | .height=LCD_REMOTE_HEIGHT, | ||
120 | .depth=LCD_REMOTE_DEPTH, | ||
121 | .is_color=false,/* No color remotes yet */ | ||
122 | .getxmargin=dummy_func, | ||
123 | .getymargin=dummy_func, | ||
124 | .get_foreground=dummy_func, | ||
125 | .get_background=dummy_func, | ||
126 | } | ||
127 | #endif | ||
128 | }; | ||
129 | |||
130 | #ifdef HAVE_LCD_BITMAP | ||
131 | void screen_clear_area(struct screen * display, int xstart, int ystart, | ||
132 | int width, int height) | ||
133 | { | ||
134 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
135 | display->fillrect(xstart, ystart, width, height); | ||
136 | display->set_drawmode(DRMODE_SOLID); | ||
137 | } | ||
138 | #endif | ||
139 | |||
140 | |||
141 | int main(int argc, char **argv) | ||
142 | { | ||
143 | int res; | ||
144 | int fd; | ||
145 | int filearg = 1; | ||
146 | |||
147 | struct wps_data wps; | ||
148 | |||
149 | if (argc < 2) { | ||
150 | printf("Usage: checkwps [OPTIONS] filename.wps\n"); | ||
151 | printf("\nOPTIONS:\n"); | ||
152 | printf("\t-v\tverbose\n"); | ||
153 | printf("\t-vv\tmore verbose\n"); | ||
154 | printf("\t-vvv\tvery verbose\n"); | ||
155 | return 1; | ||
156 | } | ||
157 | |||
158 | if (argv[1][0] == '-') { | ||
159 | filearg++; | ||
160 | int i = 1; | ||
161 | while (argv[1][i] && argv[1][i] == 'v') { | ||
162 | i++; | ||
163 | wps_verbose_level++; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | fd = open(argv[filearg], O_RDONLY); | ||
168 | if (fd < 0) { | ||
169 | printf("Failed to open %s\n",argv[1]); | ||
170 | return 2; | ||
171 | } | ||
172 | close(fd); | ||
173 | |||
174 | res = wps_data_load(&wps, &screens[0], argv[filearg], true); | ||
175 | |||
176 | if (!res) { | ||
177 | printf("WPS parsing failure\n"); | ||
178 | return 3; | ||
179 | } | ||
180 | |||
181 | printf("WPS parsed OK\n"); | ||
182 | return 0; | ||
183 | } | ||
184 | |||