summaryrefslogtreecommitdiff
path: root/tools/checkwps.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-05-29 19:00:36 +0000
committerDave Chapman <dave@dchapman.com>2007-05-29 19:00:36 +0000
commitf0d4fc6c6b146197c0fc51753d838252766aeda2 (patch)
tree14a80b9a30d14b63c50f3350f9c2cececdc1baef /tools/checkwps.c
parentbe0cbc940641264fe536ea1b3c1153f627367f55 (diff)
downloadrockbox-f0d4fc6c6b146197c0fc51753d838252766aeda2.tar.gz
rockbox-f0d4fc6c6b146197c0fc51753d838252766aeda2.zip
Commit my patch from FS#7179 - a standalone command-line checkwps tool. To build, just type "make checkwps" in tools and run it with "checkwps wpsname.wps".
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13517 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/checkwps.c')
-rw-r--r--tools/checkwps.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/tools/checkwps.c b/tools/checkwps.c
new file mode 100644
index 0000000000..74ce1e82be
--- /dev/null
+++ b/tools/checkwps.c
@@ -0,0 +1,91 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include "gwps.h"
4
5#define MIN(x,y) ((x) > (y) ? (y) : (x))
6
7bool debug_wps = true;
8
9int read_bmp_file(char* filename,
10 struct bitmap *bm,
11 int maxsize,
12 int format)
13{
14 return 0;
15}
16
17int errno;
18
19int read_line(int fd, char* buffer, int buffer_size)
20{
21 int count = 0;
22 int num_read = 0;
23
24 errno = 0;
25
26 while (count < buffer_size)
27 {
28 unsigned char c;
29
30 if (1 != read(fd, &c, 1))
31 break;
32
33 num_read++;
34
35 if ( c == '\n' )
36 break;
37
38 if ( c == '\r' )
39 continue;
40
41 buffer[count++] = c;
42 }
43
44 buffer[MIN(count, buffer_size - 1)] = 0;
45
46 return errno ? -1 : num_read;
47}
48
49bool load_wps_backdrop(char* filename)
50{
51 return true;
52}
53
54static char pluginbuf[PLUGIN_BUFFER_SIZE];
55
56void* plugin_get_buffer(size_t *buffer_size)
57{
58 *buffer_size = PLUGIN_BUFFER_SIZE;
59 return pluginbuf;
60}
61
62int main(int argc, char **argv)
63{
64 int res;
65 int fd;
66
67 struct wps_data wps;
68
69 if (argc != 2) {
70 printf("Usage: checkwps filename.wps\n");
71 return 1;
72 }
73
74 fd = open(argv[1], O_RDONLY);
75 if (fd < 0) {
76 printf("Failed to open %s\n",argv[1]);
77 return 2;
78 }
79 close(fd);
80
81 res = wps_data_load(&wps, argv[1], true);
82
83 if (!res) {
84 printf("WPS parsing failure\n");
85 return 3;
86 }
87
88 printf("WPS parsed OK\n");
89 return 0;
90}
91