simplify a bit.
[Rockbox.git] / tools / checkwps.c
blob950c341bfc7feafbbb9359840830cc00e1ce95c2
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "gwps.h"
5 #define MIN(x,y) ((x) > (y) ? (y) : (x))
7 bool debug_wps = true;
8 int wps_verbose_level = 0;
10 int read_bmp_file(char* filename,
11 struct bitmap *bm,
12 int maxsize,
13 int format)
15 return 0;
18 int errno;
20 int read_line(int fd, char* buffer, int buffer_size)
22 int count = 0;
23 int num_read = 0;
25 errno = 0;
27 while (count < buffer_size)
29 unsigned char c;
31 if (1 != read(fd, &c, 1))
32 break;
34 num_read++;
36 if ( c == '\n' )
37 break;
39 if ( c == '\r' )
40 continue;
42 buffer[count++] = c;
45 buffer[MIN(count, buffer_size - 1)] = 0;
47 return errno ? -1 : num_read;
50 bool load_wps_backdrop(char* filename)
52 return true;
55 static char pluginbuf[PLUGIN_BUFFER_SIZE];
57 void* plugin_get_buffer(size_t *buffer_size)
59 *buffer_size = PLUGIN_BUFFER_SIZE;
60 return pluginbuf;
63 int main(int argc, char **argv)
65 int res;
66 int fd;
67 int filearg = 1;
69 struct wps_data wps;
71 if (argc < 2) {
72 printf("Usage: checkwps [OPTIONS] filename.wps\n");
73 printf("\nOPTIONS:\n");
74 printf("\t-v\tverbose\n");
75 printf("\t-vv\tmore verbose\n");
76 printf("\t-vvv\tvery verbose\n");
77 return 1;
80 if (argv[1][0] == '-') {
81 filearg++;
82 int i = 1;
83 while (argv[1][i] && argv[1][i] == 'v') {
84 i++;
85 wps_verbose_level++;
89 fd = open(argv[filearg], O_RDONLY);
90 if (fd < 0) {
91 printf("Failed to open %s\n",argv[1]);
92 return 2;
94 close(fd);
96 res = wps_data_load(&wps, argv[filearg], true);
98 if (!res) {
99 printf("WPS parsing failure\n");
100 return 3;
103 printf("WPS parsed OK\n");
104 return 0;