Forgot to add a file as usual.
[Rockbox.git] / tools / checkwps.c
blob74ce1e82be9096cb8f26120c684ed0cbcc795954
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;
9 int read_bmp_file(char* filename,
10 struct bitmap *bm,
11 int maxsize,
12 int format)
14 return 0;
17 int errno;
19 int read_line(int fd, char* buffer, int buffer_size)
21 int count = 0;
22 int num_read = 0;
24 errno = 0;
26 while (count < buffer_size)
28 unsigned char c;
30 if (1 != read(fd, &c, 1))
31 break;
33 num_read++;
35 if ( c == '\n' )
36 break;
38 if ( c == '\r' )
39 continue;
41 buffer[count++] = c;
44 buffer[MIN(count, buffer_size - 1)] = 0;
46 return errno ? -1 : num_read;
49 bool load_wps_backdrop(char* filename)
51 return true;
54 static char pluginbuf[PLUGIN_BUFFER_SIZE];
56 void* plugin_get_buffer(size_t *buffer_size)
58 *buffer_size = PLUGIN_BUFFER_SIZE;
59 return pluginbuf;
62 int main(int argc, char **argv)
64 int res;
65 int fd;
67 struct wps_data wps;
69 if (argc != 2) {
70 printf("Usage: checkwps filename.wps\n");
71 return 1;
74 fd = open(argv[1], O_RDONLY);
75 if (fd < 0) {
76 printf("Failed to open %s\n",argv[1]);
77 return 2;
79 close(fd);
81 res = wps_data_load(&wps, argv[1], true);
83 if (!res) {
84 printf("WPS parsing failure\n");
85 return 3;
88 printf("WPS parsed OK\n");
89 return 0;