7 #define MIN(x,y) ((x) > (y) ? (y) : (x))
10 int wps_verbose_level
= 0;
14 /* static endianness conversion */
15 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
16 ((unsigned short)(x) << 8)))
18 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
19 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
20 (((unsigned long)(x) & 0xff00ul) << 8) | \
21 ((unsigned long)(x) << 24)))
22 unsigned short letoh16(unsigned short x
)
24 unsigned short n
= 0x1234;
25 unsigned char* ch
= (unsigned char*)&n
;
36 unsigned int htole32(unsigned int x
)
38 unsigned short n
= 0x1234;
39 unsigned char* ch
= (unsigned char*)&n
;
50 int read_line(int fd
, char* buffer
, int buffer_size
)
57 while (count
< buffer_size
)
61 if (1 != read(fd
, &c
, 1))
75 buffer
[MIN(count
, buffer_size
- 1)] = 0;
77 return errno
? -1 : num_read
;
80 bool load_wps_backdrop(const char* filename
)
85 bool load_remote_wps_backdrop(const char* filename
)
90 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
92 static int dummy_func1(void)
97 static unsigned dummy_func2(void)
102 void* plugin_get_buffer(size_t *buffer_size
)
104 *buffer_size
= PLUGIN_BUFFER_SIZE
;
108 struct screen screens
[NB_SCREENS
] =
111 .screen_type
=SCREEN_MAIN
,
115 #ifdef HAVE_LCD_COLOR
120 .getxmargin
=dummy_func1
,
121 .getymargin
=dummy_func1
,
123 .get_foreground
=dummy_func2
,
124 .get_background
=dummy_func2
,
127 #ifdef HAVE_REMOTE_LCD
129 .screen_type
=SCREEN_REMOTE
,
130 .width
=LCD_REMOTE_WIDTH
,
131 .height
=LCD_REMOTE_HEIGHT
,
132 .depth
=LCD_REMOTE_DEPTH
,
133 .is_color
=false,/* No color remotes yet */
134 .getxmargin
=dummy_func1
,
135 .getymargin
=dummy_func1
,
136 #if LCD_REMOTE_DEPTH > 1
137 .get_foreground
=dummy_func2
,
138 .get_background
=dummy_func2
,
144 #ifdef HAVE_LCD_BITMAP
145 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
146 int width
, int height
)
148 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
149 display
->fillrect(xstart
, ystart
, width
, height
);
150 display
->set_drawmode(DRMODE_SOLID
);
155 int main(int argc
, char **argv
)
164 printf("Usage: checkwps [OPTIONS] filename.wps\n");
165 printf("\nOPTIONS:\n");
166 printf("\t-v\tverbose\n");
167 printf("\t-vv\tmore verbose\n");
168 printf("\t-vvv\tvery verbose\n");
172 if (argv
[1][0] == '-') {
175 while (argv
[1][i
] && argv
[1][i
] == 'v') {
181 fd
= open(argv
[filearg
], O_RDONLY
);
183 printf("Failed to open %s\n",argv
[1]);
188 res
= wps_data_load(&wps
, &screens
[0], argv
[filearg
], true);
191 printf("WPS parsing failure\n");
195 printf("WPS parsed OK\n");