/[public]/psiconv/trunk/lib/psiconv/parse_layout.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_layout.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 110 Revision 182
24#include <math.h> 24#include <math.h>
25 25
26#include "parse_routines.h" 26#include "parse_routines.h"
27#include "error.h" 27#include "error.h"
28 28
29int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, 29#ifdef DMALLOC
30#include <dmalloc.h>
31#endif
32
33
34int psiconv_parse_color(const psiconv_config config,
35 const psiconv_buffer buf, int lev, psiconv_u32 off,
30 int *length, psiconv_color *result) 36 int *length, psiconv_color *result)
31{ 37{
32 int res = 0; 38 int res = 0;
33 int len = 0; 39 int len = 0;
34 40
35 psiconv_progress(lev+1,off,"Going to parse color"); 41 psiconv_progress(config,lev+1,off,"Going to parse color");
36 if (!(*result = malloc(sizeof(**result)))) 42 if (!(*result = malloc(sizeof(**result))))
37 goto ERROR1; 43 goto ERROR1;
38 44
39 (*result)->red = psiconv_read_u8(buf,lev+2,off+len,&res); 45 (*result)->red = psiconv_read_u8(config,buf,lev+2,off+len,&res);
40 if (res) 46 if (res)
41 goto ERROR2; 47 goto ERROR2;
42 (*result)->green = psiconv_read_u8(buf,lev+2,off+len+1,&res); 48 (*result)->green = psiconv_read_u8(config,buf,lev+2,off+len+1,&res);
43 if (res) 49 if (res)
44 goto ERROR2; 50 goto ERROR2;
45 (*result)->blue = psiconv_read_u8(buf,lev+2,off+len+2,&res); 51 (*result)->blue = psiconv_read_u8(config,buf,lev+2,off+len+2,&res);
46 if (res) 52 if (res)
47 goto ERROR2; 53 goto ERROR2;
48 len += 3; 54 len += 3;
49 55
50 psiconv_debug(lev+2,off,"Color: red %02x, green %02x, blue %02x", 56 psiconv_debug(config,lev+2,off,"Color: red %02x, green %02x, blue %02x",
51 (*result)->red, (*result)->green, (*result)->blue); 57 (*result)->red, (*result)->green, (*result)->blue);
52 if (length) 58 if (length)
53 *length = len; 59 *length = len;
54 60
55 psiconv_progress(lev+1,off+len-1,"End of color (total length: %08x)",len); 61 psiconv_progress(config,lev+1,off+len-1,"End of color (total length: %08x)",len);
56 return 0; 62 return 0;
57 63
58ERROR2: 64ERROR2:
59 free(*result); 65 free(*result);
60ERROR1: 66ERROR1:
61 psiconv_warn(lev+1,off,"Reading of Color failed"); 67 psiconv_warn(config,lev+1,off,"Reading of Color failed");
62 if (length) 68 if (length)
63 *length = 0; 69 *length = 0;
64 if (res == 0) 70 if (res == 0)
65 return -PSICONV_E_NOMEM; 71 return -PSICONV_E_NOMEM;
66 else 72 else
67 return res; 73 return res;
68} 74}
69 75
70 76
71 77
72int psiconv_parse_font(const psiconv_buffer buf, int lev, psiconv_u32 off, 78int psiconv_parse_font(const psiconv_config config,
79 const psiconv_buffer buf, int lev, psiconv_u32 off,
73 int *length, psiconv_font *result) 80 int *length, psiconv_font *result)
74{ 81{
75 int res = 0; 82 int res = 0;
76 int strlength,i;
77 char *str_copy; 83 char *str_copy;
84 int len=0;
78 int len; 85 int leng;
79 86
80 psiconv_progress(lev+1,off,"Going to parse font"); 87 psiconv_progress(config,lev+1,off,"Going to parse font");
81 if (!(*result = malloc(sizeof(**result)))) 88 if (!(*result = malloc(sizeof(**result))))
82 goto ERROR1; 89 goto ERROR1;
83 90
84 strlength = psiconv_read_u8(buf,lev+2,off,&res); 91 (*result)->name = psiconv_read_short_string(config,buf,lev+2,off+len,
92 &leng,&res);
85 if (res) 93 if (res)
86 goto ERROR2;
87 if (!((*result)->name = malloc(strlength))) {
88 goto ERROR2;
89 }
90 for (i = 0; (i < strlength-1) && !res; i++)
91 (*result)->name[i] = psiconv_read_u8(buf,lev+2,off + 1 + i,&res);
92 if (res)
93 goto ERROR3; 94 goto ERROR2;
94 (*result)->name[strlength-1] = 0; 95 len += leng;
96
95 (*result)->screenfont = psiconv_read_u8(buf,lev+2,off + strlength,&res); 97 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res);
96 if (res) 98 if (res)
97 goto ERROR3; 99 goto ERROR3;
98 100
99 if (!(str_copy = psiconv_make_printable((*result)->name))) 101 if (!(str_copy = psiconv_make_printable((*result)->name)))
100 goto ERROR3; 102 goto ERROR3;
101 103
102 psiconv_debug(lev+2,off+1,"Found font `%s', displayed with screen font %02x", 104 psiconv_debug(config,lev+2,off+len,
105 "Found font `%s', displayed with screen font %02x",
103 str_copy,(*result)->screenfont); 106 str_copy,(*result)->screenfont);
104 free(str_copy); 107 free(str_copy);
105 len = strlength + 1; 108 len ++;
109
106 if (length) 110 if (length)
107 *length = len; 111 *length = len;
108 112
109 psiconv_progress(lev+1,off + len - 1,"End of font (total length: %08x)",len); 113 psiconv_progress(config,lev+1,off + len - 1,
114 "End of font (total length: %08x)",len);
110 return 0; 115 return 0;
111 116
112ERROR3: 117ERROR3:
113 free ((*result)->name); 118 free ((*result)->name);
114ERROR2: 119ERROR2:
115 free (*result); 120 free (*result);
116ERROR1: 121ERROR1:
117 psiconv_warn(lev+1,off,"Reading of Font failed"); 122 psiconv_warn(config,lev+1,off,"Reading of Font failed");
118 if (length) 123 if (length)
119 *length = 0; 124 *length = 0;
120 if (!res) 125 if (!res)
121 return -PSICONV_E_NOMEM; 126 return -PSICONV_E_NOMEM;
122 else 127 else
123 return res; 128 return res;
124} 129}
125 130
126int psiconv_parse_border(const psiconv_buffer buf,int lev,psiconv_u32 off, 131int psiconv_parse_border(const psiconv_config config,
132 const psiconv_buffer buf,int lev,psiconv_u32 off,
127 int *length, psiconv_border *result) 133 int *length, psiconv_border *result)
128{ 134{
129 int res = 0; 135 int res = 0;
130 int len = 0; 136 int len = 0;
131 psiconv_u32 temp; 137 psiconv_u32 temp;
132 int leng; 138 int leng;
133 139
134 psiconv_progress(lev+1,off,"Going to parse border data"); 140 psiconv_progress(config,lev+1,off,"Going to parse border data");
135 if (!(*result = malloc(sizeof(**result)))) { 141 if (!(*result = malloc(sizeof(**result)))) {
136 goto ERROR1; 142 goto ERROR1;
137 } 143 }
138 144
139 psiconv_progress(lev+2,off+len,"Going to read border kind"); 145 psiconv_progress(config,lev+2,off+len,"Going to read border kind");
140 temp = psiconv_read_u8(buf,lev+2,off+len,&res); 146 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
141 if (res) 147 if (res)
142 goto ERROR2; 148 goto ERROR2;
143 if (temp == 0x00) 149 if (temp == 0x00)
144 (*result)->kind = psiconv_border_none; 150 (*result)->kind = psiconv_border_none;
145 else if (temp == 0x01) 151 else if (temp == 0x01)
153 else if (temp == 0x05) 159 else if (temp == 0x05)
154 (*result)->kind = psiconv_border_dotdashed; 160 (*result)->kind = psiconv_border_dotdashed;
155 else if (temp == 0x06) 161 else if (temp == 0x06)
156 (*result)->kind = psiconv_border_dotdotdashed; 162 (*result)->kind = psiconv_border_dotdotdashed;
157 else { 163 else {
158 psiconv_warn(lev+2,off,"Unknown border kind (defaults to `none')"); 164 psiconv_warn(config,lev+2,off,"Unknown border kind (defaults to `none')");
159 (*result)->kind = psiconv_border_none; 165 (*result)->kind = psiconv_border_none;
160 } 166 }
161 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 167 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
162 len ++; 168 len ++;
163 169
164 psiconv_progress(lev+2,off+len,"Going to read border thickness"); 170 psiconv_progress(config,lev+2,off+len,"Going to read border thickness");
165 (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); 171 (*result)->thickness = psiconv_read_size(config,buf,lev+2,off+len,&leng,&res);
166 if (res) 172 if (res)
167 goto ERROR2; 173 goto ERROR2;
168#if 0 174#if 0
169 /* This seems no longer necessary to test? */ 175 /* This seems no longer necessary to test? */
170 if (((*result)->kind != psiconv_border_solid) && 176 if (((*result)->kind != psiconv_border_solid) &&
171 ((*result)->kind != psiconv_border_double) && 177 ((*result)->kind != psiconv_border_double) &&
172 ((*result)->thickness != 0.0) && 178 ((*result)->thickness != 0.0) &&
173 (fabs((*result)->thickness - 1/20) >= 1/1000)) { 179 (fabs((*result)->thickness - 1/20) >= 1/1000)) {
174 psiconv_warn(lev+2,off, 180 psiconv_warn(config,lev+2,off,
175 "Border thickness specified for unlikely border type"); 181 "Border thickness specified for unlikely border type");
176 } 182 }
177#endif 183#endif
178 psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); 184 psiconv_debug(config,lev+2,off+len,"Thickness: %f",(*result)->thickness);
179 len += leng; 185 len += leng;
180 186
181 psiconv_progress(lev+2,off+len,"Going to read the border color"); 187 psiconv_progress(config,lev+2,off+len,"Going to read the border color");
182 if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) 188 if ((psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
183 goto ERROR2; 189 goto ERROR2;
184 len += leng; 190 len += leng;
185 191
186 psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " 192 psiconv_progress(config,lev+2,off+len,"Going to read the final unknown byte "
187 "(0x00 or 0x01 expected)"); 193 "(0x00 or 0x01 expected)");
188 temp = psiconv_read_u8(buf,lev+2,off + len,&res); 194 temp = psiconv_read_u8(config,buf,lev+2,off + len,&res);
189 if (res) 195 if (res)
190 goto ERROR3; 196 goto ERROR3;
191 if ((temp != 0x01) && (temp != 0x00)) { 197 if ((temp != 0x01) && (temp != 0x00)) {
192 psiconv_warn(lev+2,off,"Unknown last byte in border specification"); 198 psiconv_warn(config,lev+2,off,"Unknown last byte in border specification");
193 psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x or %02x", 199 psiconv_debug(config,lev+2,off+len, "Last byte: read %02x, expected %02x or %02x",
194 temp,0x00,0x01); 200 temp,0x00,0x01);
195 } 201 }
196 len ++; 202 len ++;
197 203
198 if (length) 204 if (length)
199 *length = len; 205 *length = len;
200 206
201 psiconv_progress(lev+1,off + len - 1, 207 psiconv_progress(config,lev+1,off + len - 1,
202 "End of border (total length: %08x)",len); 208 "End of border (total length: %08x)",len);
203 209
204 return 0; 210 return 0;
205 211
206ERROR3: 212ERROR3:
207 psiconv_free_color((*result)->color); 213 psiconv_free_color((*result)->color);
208ERROR2: 214ERROR2:
209 free (result); 215 free (result);
210ERROR1: 216ERROR1:
211 psiconv_warn(lev+1,off,"Reading of Border failed"); 217 psiconv_warn(config,lev+1,off,"Reading of Border failed");
212 if (length) 218 if (length)
213 *length = 0; 219 *length = 0;
214 if (!res) 220 if (!res)
215 return -PSICONV_E_NOMEM; 221 return -PSICONV_E_NOMEM;
216 else 222 else
217 return res; 223 return res;
218} 224}
219 225
220int psiconv_parse_bullet(const psiconv_buffer buf,int lev,psiconv_u32 off, 226int psiconv_parse_bullet(const psiconv_config config,
227 const psiconv_buffer buf,int lev,psiconv_u32 off,
221 int *length, psiconv_bullet *result) 228 int *length, psiconv_bullet *result)
222{ 229{
223 int res = 0; 230 int res = 0;
224 int len = 0; 231 int len = 0;
225 int leng; 232 int leng;
227 234
228 if (!(*result = malloc(sizeof(**result)))) 235 if (!(*result = malloc(sizeof(**result))))
229 goto ERROR1; 236 goto ERROR1;
230 (*result)->on = psiconv_bool_true; 237 (*result)->on = psiconv_bool_true;
231 238
232 psiconv_progress(lev+1,off,"Going to parse bullet data"); 239 psiconv_progress(config,lev+1,off,"Going to parse bullet data");
233 psiconv_progress(lev+2,off+len,"Going to read bullet length"); 240 psiconv_progress(config,lev+2,off+len,"Going to read bullet length");
234 bullet_length = psiconv_read_u8(buf,lev+2,off+len,&res); 241 bullet_length = psiconv_read_u8(config,buf,lev+2,off+len,&res);
235 if (res) 242 if (res)
236 goto ERROR2; 243 goto ERROR2;
237 psiconv_debug(lev+2,off+len,"Length: %02x",bullet_length); 244 psiconv_debug(config,lev+2,off+len,"Length: %02x",bullet_length);
238 len ++; 245 len ++;
239 246
240 psiconv_progress(lev+2,off+len,"Going to read bullet font size"); 247 psiconv_progress(config,lev+2,off+len,"Going to read bullet font size");
241 (*result)->font_size = psiconv_read_size(buf,lev+2,off+len, &leng,&res); 248 (*result)->font_size = psiconv_read_size(config,buf,lev+2,off+len, &leng,&res);
242 if (res) 249 if (res)
243 goto ERROR2; 250 goto ERROR2;
244 len +=leng; 251 len +=leng;
245 252
246 psiconv_progress(lev+2,off+len,"Going to read bullet character"); 253 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
247 (*result)->character = psiconv_read_u8(buf,lev+2,off+len,&res); 254 (*result)->character = psiconv_read_u8(config,buf,lev+2,off+len,&res);
248 if (res) 255 if (res)
249 goto ERROR2; 256 goto ERROR2;
250 psiconv_debug(lev+2,off+len,"Character: %02x",(*result)->character); 257 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
251 len ++; 258 len ++;
252 259
253 psiconv_progress(lev+2,off+len,"Going to read indent on/off"); 260 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off");
254 if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->indent))) 261 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
255 goto ERROR2; 262 goto ERROR2;
256 psiconv_debug(lev+2,off+len,"Indent on: %02x",(*result)->indent); 263 psiconv_debug(config,lev+2,off+len,"Indent on: %02x",(*result)->indent);
257 len += leng; 264 len += leng;
258 265
259 psiconv_progress(lev+2,off+len,"Going to read bullet color"); 266 psiconv_progress(config,lev+2,off+len,"Going to read bullet color");
260 if ((res = psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) 267 if ((res = psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
261 goto ERROR2; 268 goto ERROR2;
262 len += leng; 269 len += leng;
263 270
264 psiconv_progress(lev+2,off+len,"Going to read bullet font"); 271 psiconv_progress(config,lev+2,off+len,"Going to read bullet font");
265 if ((res = psiconv_parse_font(buf,lev+2,off+len,&leng,&(*result)->font))) 272 if ((res = psiconv_parse_font(config,buf,lev+2,off+len,&leng,&(*result)->font)))
266 goto ERROR3; 273 goto ERROR3;
267 len += leng; 274 len += leng;
268 275
269 if (len != bullet_length + 1) { 276 if (len != bullet_length + 1) {
270 psiconv_warn(lev+2,off,"Bullet data structure length mismatch"); 277 psiconv_warn(config,lev+2,off,"Bullet data structure length mismatch");
271 psiconv_debug(lev+2,off,"Length: specified %02x, found %02x", 278 psiconv_debug(config,lev+2,off,"Length: specified %02x, found %02x",
272 bullet_length,len-1); 279 bullet_length,len-1);
273 } 280 }
274 281
275 psiconv_progress(lev+1,off + len - 1, 282 psiconv_progress(config,lev+1,off + len - 1,
276 "End of bullet data (total length: %08x)",len); 283 "End of bullet data (total length: %08x)",len);
277 284
278 if (length) 285 if (length)
279 *length = len; 286 *length = len;
280 return 0; 287 return 0;
282ERROR3: 289ERROR3:
283 psiconv_free_color((*result)->color); 290 psiconv_free_color((*result)->color);
284ERROR2: 291ERROR2:
285 free (result); 292 free (result);
286ERROR1: 293ERROR1:
287 psiconv_warn(lev+1,off,"Reading of Bullet failed"); 294 psiconv_warn(config,lev+1,off,"Reading of Bullet failed");
288 if (length) 295 if (length)
289 *length = 0; 296 *length = 0;
290 if (!res) 297 if (!res)
291 return -PSICONV_E_NOMEM; 298 return -PSICONV_E_NOMEM;
292 else 299 else
293 return res; 300 return res;
294} 301}
295 302
296int psiconv_parse_tab(const psiconv_buffer buf, int lev, psiconv_u32 off, 303int psiconv_parse_tab(const psiconv_config config,
304 const psiconv_buffer buf, int lev, psiconv_u32 off,
297 int *length, psiconv_tab *result) 305 int *length, psiconv_tab *result)
298{ 306{
299 int res = 0; 307 int res = 0;
300 int len = 0; 308 int len = 0;
301 int leng; 309 int leng;
302 psiconv_u8 temp; 310 psiconv_u8 temp;
303 311
304 psiconv_progress(lev+1,off,"Going to parse tab"); 312 psiconv_progress(config,lev+1,off,"Going to parse tab");
305 if (!(*result = malloc(sizeof(**result)))) 313 if (!(*result = malloc(sizeof(**result))))
306 goto ERROR1; 314 goto ERROR1;
307 315
308 psiconv_progress(lev+2,off,"Going to read tab location"); 316 psiconv_progress(config,lev+2,off,"Going to read tab location");
309 (*result)->location = psiconv_read_length(buf,lev+2,off+len,&leng,&res); 317 (*result)->location = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
310 if (res) 318 if (res)
311 goto ERROR2; 319 goto ERROR2;
312 len += leng; 320 len += leng;
313 321
314 psiconv_progress(lev+2,off+len,"Going to read the tab kind"); 322 psiconv_progress(config,lev+2,off+len,"Going to read the tab kind");
315 temp = psiconv_read_u8(buf,lev+2,off+len,&res); 323 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
316 if (res) 324 if (res)
317 goto ERROR2; 325 goto ERROR2;
318 if (temp == 1) 326 if (temp == 1)
319 (*result)->kind = psiconv_tab_left; 327 (*result)->kind = psiconv_tab_left;
320 else if (temp == 2) 328 else if (temp == 2)
321 (*result)->kind = psiconv_tab_centre; 329 (*result)->kind = psiconv_tab_centre;
322 else if (temp == 3) 330 else if (temp == 3)
323 (*result)->kind = psiconv_tab_right; 331 (*result)->kind = psiconv_tab_right;
324 else { 332 else {
325 psiconv_warn(lev+2,off+len,"Unknown tab kind argument"); 333 psiconv_warn(config,lev+2,off+len,"Unknown tab kind argument");
326 psiconv_debug(lev+2,off+len,"Kind found: %02x (defaulted to left tab)", 334 psiconv_debug(config,lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
327 temp); 335 temp);
328 (*result)->kind = psiconv_tab_left; 336 (*result)->kind = psiconv_tab_left;
329 } 337 }
330 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 338 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
331 len ++; 339 len ++;
332 340
333 if (length) 341 if (length)
334 *length = len; 342 *length = len;
335 343
336 psiconv_progress(lev+1,off+len-1,"End of tab (total length: %08x)",len); 344 psiconv_progress(config,lev+1,off+len-1,"End of tab (total length: %08x)",len);
337 return 0; 345 return 0;
338 346
339ERROR2: 347ERROR2:
340 free (result); 348 free (result);
341ERROR1: 349ERROR1:
342 psiconv_warn(lev+1,off,"Reading of Tab failed"); 350 psiconv_warn(config,lev+1,off,"Reading of Tab failed");
343 if (length) 351 if (length)
344 *length = 0; 352 *length = 0;
345 if (!res) 353 if (!res)
346 return -PSICONV_E_NOMEM; 354 return -PSICONV_E_NOMEM;
347 else 355 else
348 return res; 356 return res;
349} 357}
350 358
351int psiconv_parse_paragraph_layout_list(const psiconv_buffer buf, int lev, 359int psiconv_parse_paragraph_layout_list(const psiconv_config config,
360 const psiconv_buffer buf, int lev,
352 psiconv_u32 off, int *length, 361 psiconv_u32 off, int *length,
353 psiconv_paragraph_layout result) 362 psiconv_paragraph_layout result)
354{ 363{
355 int res=0; 364 int res=0;
356 int len=0; 365 int len=0;
360 psiconv_tab temp_tab; 369 psiconv_tab temp_tab;
361 psiconv_color temp_color; 370 psiconv_color temp_color;
362 psiconv_border temp_border; 371 psiconv_border temp_border;
363 psiconv_bullet temp_bullet; 372 psiconv_bullet temp_bullet;
364 373
365 psiconv_progress(lev+1,off,"Going to read paragraph layout list"); 374 psiconv_progress(config,lev+1,off,"Going to read paragraph layout list");
366 375
367 psiconv_progress(lev+2,off,"Going to read the list length"); 376 psiconv_progress(config,lev+2,off,"Going to read the list length");
368 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 377 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
369 if (res) 378 if (res)
370 goto ERROR1; 379 goto ERROR1;
371 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 380 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
372 len += 4; 381 len += 4;
373 382
374 nr = 0; 383 nr = 0;
375 while(len - 4 < list_length) { 384 while(len - 4 < list_length) {
376 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 385 psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
377 psiconv_progress(lev+3,off+len,"Going to read the element id"); 386 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
378 id = psiconv_read_u8(buf,lev+2,off+len,&res); 387 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
379 if (res) 388 if (res)
380 goto ERROR1; 389 goto ERROR1;
381 psiconv_debug(lev+3,off+len,"Id: %02x",id); 390 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
382 len ++; 391 len ++;
383 switch(id) { 392 switch(id) {
384 case 0x01: 393 case 0x01:
385 psiconv_progress(lev+3,off+len,"Going to read background color"); 394 psiconv_progress(config,lev+3,off+len,"Going to read background color");
386 if ((res = psiconv_parse_color(buf,lev+3,off+len,&leng,&temp_color))) 395 if ((res = psiconv_parse_color(config,buf,lev+3,off+len,&leng,&temp_color)))
387 goto ERROR1; 396 goto ERROR1;
388 psiconv_free_color(result->back_color); 397 psiconv_free_color(result->back_color);
389 result->back_color = temp_color; 398 result->back_color = temp_color;
390 len += leng; 399 len += leng;
391 break; 400 break;
392 case 0x02: 401 case 0x02:
393 psiconv_progress(lev+3,off+len ,"Going to read indent left"); 402 psiconv_progress(config,lev+3,off+len ,"Going to read indent left");
394 result->indent_left = psiconv_read_length(buf,lev+3,off+len,&leng,&res); 403 result->indent_left = psiconv_read_length(config,buf,lev+3,off+len,&leng,&res);
395 if (res) 404 if (res)
396 goto ERROR1; 405 goto ERROR1;
397 len += leng; 406 len += leng;
398 break; 407 break;
399 case 0x03: 408 case 0x03:
400 psiconv_progress(lev+3,off+len,"Going to read indent right"); 409 psiconv_progress(config,lev+3,off+len,"Going to read indent right");
401 result->indent_right = psiconv_read_length(buf,lev+2,off+len,&leng, 410 result->indent_right = psiconv_read_length(config,buf,lev+2,off+len,&leng,
402 &res); 411 &res);
403 if (res) 412 if (res)
404 goto ERROR1; 413 goto ERROR1;
405 len += leng; 414 len += leng;
406 break; 415 break;
407 case 0x04: 416 case 0x04:
408 psiconv_progress(lev+3,off+len,"Going to read indent left first line"); 417 psiconv_progress(config,lev+3,off+len,"Going to read indent left first line");
409 result->indent_first = psiconv_read_length(buf,lev+2,off+len, &leng, 418 result->indent_first = psiconv_read_length(config,buf,lev+2,off+len, &leng,
410 &res); 419 &res);
411 if (res) 420 if (res)
412 goto ERROR1; 421 goto ERROR1;
413 len += leng; 422 len += leng;
414 break; 423 break;
415 case 0x05: 424 case 0x05:
416 psiconv_progress(lev+3,off+len,"Going to read horizontal justify"); 425 psiconv_progress(config,lev+3,off+len,"Going to read horizontal justify");
417 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 426 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
418 if (res) 427 if (res)
419 goto ERROR1; 428 goto ERROR1;
420 if (temp == 0x00) 429 if (temp == 0x00)
421 result->justify_hor = psiconv_justify_left; 430 result->justify_hor = psiconv_justify_left;
422 else if (temp == 0x01) 431 else if (temp == 0x01)
424 else if (temp == 0x02) 433 else if (temp == 0x02)
425 result->justify_hor = psiconv_justify_right; 434 result->justify_hor = psiconv_justify_right;
426 else if (temp == 0x03) 435 else if (temp == 0x03)
427 result->justify_hor = psiconv_justify_full; 436 result->justify_hor = psiconv_justify_full;
428 else { 437 else {
429 psiconv_warn(lev+3,off+len, "Unknown horizontal justify argument " 438 psiconv_warn(config,lev+3,off+len, "Unknown horizontal justify argument "
430 "in paragraph layout codes list"); 439 "in paragraph layout codes list");
431 result->justify_hor = psiconv_justify_left; 440 result->justify_hor = psiconv_justify_left;
432 } 441 }
433 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 442 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
434 len ++; 443 len ++;
435 break; 444 break;
436 case 0x06: 445 case 0x06:
437 psiconv_progress(lev+3,off+len,"Going to read vertical justify"); 446 psiconv_progress(config,lev+3,off+len,"Going to read vertical justify");
438 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 447 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
439 if (res) 448 if (res)
440 goto ERROR1; 449 goto ERROR1;
441 if (temp == 0x00) 450 if (temp == 0x00)
442 result->justify_ver = psiconv_justify_top; 451 result->justify_ver = psiconv_justify_top;
443 else if (temp == 0x01) 452 else if (temp == 0x01)
444 result->justify_ver = psiconv_justify_middle; 453 result->justify_ver = psiconv_justify_middle;
445 else if (temp == 0x02) 454 else if (temp == 0x02)
446 result->justify_ver = psiconv_justify_bottom; 455 result->justify_ver = psiconv_justify_bottom;
447 else { 456 else {
448 psiconv_warn(lev+3,off+len, "Unknown vertical justify argument " 457 psiconv_warn(config,lev+3,off+len, "Unknown vertical justify argument "
449 "in paragraph layout codes list"); 458 "in paragraph layout codes list");
450 result->justify_ver = psiconv_justify_bottom; 459 result->justify_ver = psiconv_justify_bottom;
451 } 460 }
452 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 461 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
453 len ++; 462 len ++;
454 break; 463 break;
455 case 0x07: 464 case 0x07:
456 psiconv_progress(lev+3,off+len,"Going to read linespacing distance"); 465 psiconv_progress(config,lev+3,off+len,"Going to read linespacing distance");
457 result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 466 result->linespacing = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
458 if (res) 467 if (res)
459 goto ERROR1; 468 goto ERROR1;
460 len += leng; 469 len += leng;
461 break; 470 break;
462 case 0x08: 471 case 0x08:
463 psiconv_progress(lev+3,off+len,"Going to read linespacing exact"); 472 psiconv_progress(config,lev+3,off+len,"Going to read linespacing exact");
464 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 473 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
465 &result->linespacing_exact))) 474 &result->linespacing_exact)))
466 goto ERROR1; 475 goto ERROR1;
467 len += leng; 476 len += leng;
468 break; 477 break;
469 case 0x09: 478 case 0x09:
470 psiconv_progress(lev+3,off+len,"Going to read top space"); 479 psiconv_progress(config,lev+3,off+len,"Going to read top space");
471 result->space_above = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 480 result->space_above = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
472 if (res) 481 if (res)
473 goto ERROR1; 482 goto ERROR1;
474 len += leng; 483 len += leng;
475 break; 484 break;
476 case 0x0a: 485 case 0x0a:
477 psiconv_progress(lev+3,off+len,"Going to read bottom space"); 486 psiconv_progress(config,lev+3,off+len,"Going to read bottom space");
478 result->space_below = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 487 result->space_below = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
479 if (res) 488 if (res)
480 goto ERROR1; 489 goto ERROR1;
481 len += leng; 490 len += leng;
482 break; 491 break;
483 case 0x0b: 492 case 0x0b:
484 psiconv_progress(lev+3,off+len,"Going to read on one page"); 493 psiconv_progress(config,lev+3,off+len,"Going to read on one page");
485 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 494 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
486 &result->keep_together))) 495 &result->keep_together)))
487 goto ERROR1; 496 goto ERROR1;
488 len += leng; 497 len += leng;
489 break; 498 break;
490 case 0x0c: 499 case 0x0c:
491 psiconv_progress(lev+3,off+len,"Going to read together with"); 500 psiconv_progress(config,lev+3,off+len,"Going to read together with");
492 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 501 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
493 &result->keep_with_next))) 502 &result->keep_with_next)))
494 goto ERROR1; 503 goto ERROR1;
495 len += leng; 504 len += leng;
496 break; 505 break;
497 case 0x0d: 506 case 0x0d:
498 psiconv_progress(lev+3,off+len,"Going to read on next page"); 507 psiconv_progress(config,lev+3,off+len,"Going to read on next page");
499 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 508 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
500 &result->on_next_page))) 509 &result->on_next_page)))
501 goto ERROR1; 510 goto ERROR1;
502 len += leng; 511 len += leng;
503 break; 512 break;
504 case 0x0e: 513 case 0x0e:
505 psiconv_progress(lev+3,off+len,"Going to read no widow protection"); 514 psiconv_progress(config,lev+3,off+len,"Going to read no widow protection");
506 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 515 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
507 &result->no_widow_protection))) 516 &result->no_widow_protection)))
508 goto ERROR1; 517 goto ERROR1;
509 len += leng; 518 len += leng;
510 break; 519 break;
511 case 0x0f: 520 case 0x0f:
512 psiconv_progress(lev+3,off+len,"Going to read wrap to fit cell limits"); 521 psiconv_progress(config,lev+3,off+len,"Going to read wrap to fit cell limits");
513 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 522 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
514 &result->wrap_to_fit_cell))) 523 &result->wrap_to_fit_cell)))
515 goto ERROR1; 524 goto ERROR1;
516 len += leng; 525 len += leng;
517 break; 526 break;
518 case 0x10: 527 case 0x10:
519 psiconv_progress(lev+3,off+len,"Going to read border distance to text"); 528 psiconv_progress(config,lev+3,off+len,"Going to read border distance to text");
520 result->border_distance = psiconv_read_length(buf,lev+3, 529 result->border_distance = psiconv_read_length(config,buf,lev+3,
521 off+len,&leng,&res); 530 off+len,&leng,&res);
522 if (res) 531 if (res)
523 goto ERROR1; 532 goto ERROR1;
524 len += leng; 533 len += leng;
525 break; 534 break;
526 case 0x11: 535 case 0x11:
527 psiconv_progress(lev+3,off+len,"Going to read top border"); 536 psiconv_progress(config,lev+3,off+len,"Going to read top border");
528 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border))) 537 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
529 goto ERROR1; 538 goto ERROR1;
530 psiconv_free_border(result->top_border); 539 psiconv_free_border(result->top_border);
531 result->top_border = temp_border; 540 result->top_border = temp_border;
532 len += leng; 541 len += leng;
533 break; 542 break;
534 case 0x12: 543 case 0x12:
535 psiconv_progress(lev+3,off+len,"Going to read bottom border"); 544 psiconv_progress(config,lev+3,off+len,"Going to read bottom border");
536 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border))) 545 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
537 goto ERROR1; 546 goto ERROR1;
538 psiconv_free_border(result->bottom_border); 547 psiconv_free_border(result->bottom_border);
539 result->bottom_border = temp_border; 548 result->bottom_border = temp_border;
540 len += leng; 549 len += leng;
541 break; 550 break;
542 case 0x13: 551 case 0x13:
543 psiconv_progress(lev+3,off+len,"Going to read left border"); 552 psiconv_progress(config,lev+3,off+len,"Going to read left border");
544 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border))) 553 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
545 goto ERROR1; 554 goto ERROR1;
546 psiconv_free_border(result->left_border); 555 psiconv_free_border(result->left_border);
547 result->left_border = temp_border; 556 result->left_border = temp_border;
548 len += leng; 557 len += leng;
549 break; 558 break;
550 case 0x14: 559 case 0x14:
551 psiconv_progress(lev+3,off+len,"Going to read right border"); 560 psiconv_progress(config,lev+3,off+len,"Going to read right border");
552 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border))) 561 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
553 goto ERROR1; 562 goto ERROR1;
554 psiconv_free_border(result->right_border); 563 psiconv_free_border(result->right_border);
555 result->right_border = temp_border; 564 result->right_border = temp_border;
556 len += leng; 565 len += leng;
557 break; 566 break;
558 case 0x15: 567 case 0x15:
559 psiconv_progress(lev+3,off+len,"Going to read bullet"); 568 psiconv_progress(config,lev+3,off+len,"Going to read bullet");
560 if ((res = psiconv_parse_bullet(buf,lev+3,off+len,&leng,&temp_bullet))) 569 if ((res = psiconv_parse_bullet(config,buf,lev+3,off+len,&leng,&temp_bullet)))
561 goto ERROR1; 570 goto ERROR1;
562 psiconv_free_bullet(result->bullet); 571 psiconv_free_bullet(result->bullet);
563 result->bullet = temp_bullet; 572 result->bullet = temp_bullet;
564 len += leng; 573 len += leng;
565 break; 574 break;
566 case 0x16: 575 case 0x16:
567 psiconv_progress(lev+3,off+len,"Going to read standard tabs"); 576 psiconv_progress(config,lev+3,off+len,"Going to read standard tabs");
568 result->tabs->normal = psiconv_read_length(buf,lev+3,off+len,&leng, 577 result->tabs->normal = psiconv_read_length(config,buf,lev+3,off+len,&leng,
569 &res); 578 &res);
570 if (res) 579 if (res)
571 goto ERROR1; 580 goto ERROR1;
572 len += leng; 581 len += leng;
573 break; 582 break;
574 case 0x17: 583 case 0x17:
575 psiconv_progress(lev+3,off+len,"Going to read extra tab"); 584 psiconv_progress(config,lev+3,off+len,"Going to read extra tab");
576 if ((res = psiconv_parse_tab(buf,lev+3,off+len,&leng,&temp_tab))) 585 if ((res = psiconv_parse_tab(config,buf,lev+3,off+len,&leng,&temp_tab)))
577 goto ERROR1; 586 goto ERROR1;
578 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) { 587 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
579 psiconv_free_tab(temp_tab); 588 psiconv_free_tab(temp_tab);
580 goto ERROR1; 589 goto ERROR1;
581 } 590 }
591 psiconv_free_tab(temp_tab);
582 len += leng; 592 len += leng;
583 break; 593 break;
584 default: 594 default:
585 psiconv_warn(lev+3,off+len, 595 psiconv_warn(config,lev+3,off+len,
586 "Unknown code in paragraph layout codes list"); 596 "Unknown code in paragraph layout codes list");
587 psiconv_debug(lev+3,off+len,"Code: %02x",id); 597 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
588 len ++; 598 len ++;
589 break; 599 break;
590 } 600 }
591 nr ++; 601 nr ++;
592 } 602 }
593 603
594 if (len - 4 != list_length) { 604 if (len - 4 != list_length) {
595 psiconv_warn(lev+2,off+len, 605 psiconv_warn(config,lev+2,off+len,
596 "Read past end of paragraph layout codes list. I probably lost track" 606 "Read past end of paragraph layout codes list. I probably lost track"
597 "somewhere!"); 607 "somewhere!");
598 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 608 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
599 len-4,list_length); 609 len-4,list_length);
600 res = PSICONV_E_PARSE; 610 res = PSICONV_E_PARSE;
601 goto ERROR1; 611 goto ERROR1;
602 } 612 }
603 613
604 len = list_length + 4; 614 len = list_length + 4;
605 615
606 psiconv_progress(lev+1,off+len, 616 psiconv_progress(config,lev+1,off+len,
607 "End of paragraph layout list (total length: %08x)",len); 617 "End of paragraph layout list (total length: %08x)",len);
608 618
609 if (length) 619 if (length)
610 *length = len; 620 *length = len;
611 return 0; 621 return 0;
612 622
613ERROR1: 623ERROR1:
614 psiconv_warn(lev+1,off,"Reading of paragraph_layout_list failed"); 624 psiconv_warn(config,lev+1,off,"Reading of paragraph_layout_list failed");
615 if (length) 625 if (length)
616 *length = 0; 626 *length = 0;
617 if (!res) 627 if (!res)
618 return -PSICONV_E_NOMEM; 628 return -PSICONV_E_NOMEM;
619 else 629 else
620 return res; 630 return res;
621} 631}
622 632
623int psiconv_parse_character_layout_list(const psiconv_buffer buf, int lev, 633int psiconv_parse_character_layout_list(const psiconv_config config,
634 const psiconv_buffer buf, int lev,
624 psiconv_u32 off, int *length, 635 psiconv_u32 off, int *length,
625 psiconv_character_layout result) 636 psiconv_character_layout result)
626{ 637{
627 int res=0; 638 int res=0;
628 int len=0; 639 int len=0;
630 psiconv_u8 id; 641 psiconv_u8 id;
631 psiconv_u32 temp; 642 psiconv_u32 temp;
632 psiconv_color temp_color; 643 psiconv_color temp_color;
633 psiconv_font temp_font; 644 psiconv_font temp_font;
634 645
635 psiconv_progress(lev+1,off,"Going to read character layout codes"); 646 psiconv_progress(config,lev+1,off,"Going to read character layout codes");
636 647
637 psiconv_progress(lev+2,off,"Going to read the list length"); 648 psiconv_progress(config,lev+2,off,"Going to read the list length");
638 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 649 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
639 if (res) 650 if (res)
640 goto ERROR1; 651 goto ERROR1;
641 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 652 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
642 len += 4; 653 len += 4;
643 654
644 nr = 0; 655 nr = 0;
645 while(len-4 < list_length) { 656 while(len-4 < list_length) {
646 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 657 psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
647 psiconv_progress(lev+3,off+len,"Going to read the element id"); 658 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
648 id = psiconv_read_u8(buf,lev+2,off+len,&res); 659 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
649 if (res) 660 if (res)
650 goto ERROR1; 661 goto ERROR1;
651 psiconv_debug(lev+3,off+len,"Id: %02x",id); 662 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
652 len ++; 663 len ++;
653 switch(id) { 664 switch(id) {
654 case 0x18: 665 case 0x18:
655 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 666 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
656 len ++; 667 len ++;
657 break; 668 break;
658 case 0x19: 669 case 0x19:
659 psiconv_progress(lev+3,off+len,"Going to read text color"); 670 psiconv_progress(config,lev+3,off+len,"Going to read text color");
660 if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color))) 671 if ((res = psiconv_parse_color(config,buf,lev+3,off+len, &leng,&temp_color)))
661 goto ERROR1; 672 goto ERROR1;
662 psiconv_free_color(result->color); 673 psiconv_free_color(result->color);
663 result->color = temp_color; 674 result->color = temp_color;
664 len += leng; 675 len += leng;
665 break; 676 break;
666 case 0x1a: 677 case 0x1a:
667 psiconv_progress(lev+3,off+len,"Going to read background color (?)"); 678 psiconv_progress(config,lev+3,off+len,"Going to read background color (?)");
668 if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color))) 679 if ((res = psiconv_parse_color(config,buf,lev+2,off+len, &leng,&temp_color)))
669 goto ERROR1; 680 goto ERROR1;
670 psiconv_free_color(result->back_color); 681 psiconv_free_color(result->back_color);
671 result->back_color = temp_color; 682 result->back_color = temp_color;
672 len += leng; 683 len += leng;
673 break; 684 break;
674 case 0x1b: 685 case 0x1b:
675 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 686 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
676 len ++; 687 len ++;
677 break; 688 break;
678 case 0x1c: 689 case 0x1c:
679 psiconv_progress(lev+3,off+len,"Going to read font size"); 690 psiconv_progress(config,lev+3,off+len,"Going to read font size");
680 result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 691 result->font_size = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
681 if (res) 692 if (res)
682 goto ERROR1; 693 goto ERROR1;
683 len += leng; 694 len += leng;
684 break; 695 break;
685 case 0x1d: 696 case 0x1d:
686 psiconv_progress(lev+3,off+len,"Going to read italic"); 697 psiconv_progress(config,lev+3,off+len,"Going to read italic");
687 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->italic))) 698 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->italic)))
688 goto ERROR1; 699 goto ERROR1;
689 len += leng; 700 len += leng;
690 break; 701 break;
691 case 0x1e: 702 case 0x1e:
692 psiconv_progress(lev+3,off+len,"Going to read bold"); 703 psiconv_progress(config,lev+3,off+len,"Going to read bold");
693 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->bold))) 704 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->bold)))
694 goto ERROR1; 705 goto ERROR1;
695 len += leng; 706 len += leng;
696 break; 707 break;
697 case 0x1f: 708 case 0x1f:
698 psiconv_progress(lev+3,off+len,"Going to read super_sub"); 709 psiconv_progress(config,lev+3,off+len,"Going to read super_sub");
699 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 710 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
700 if (res) 711 if (res)
701 goto ERROR1; 712 goto ERROR1;
702 if (temp == 0x00) 713 if (temp == 0x00)
703 result->super_sub = psiconv_normalscript; 714 result->super_sub = psiconv_normalscript;
704 else if (temp == 0x01) 715 else if (temp == 0x01)
705 result->super_sub = psiconv_superscript; 716 result->super_sub = psiconv_superscript;
706 else if (temp == 0x02) 717 else if (temp == 0x02)
707 result->super_sub = psiconv_subscript; 718 result->super_sub = psiconv_subscript;
708 else { 719 else {
709 psiconv_warn(lev+3,off+len, 720 psiconv_warn(config,lev+3,off+len,
710 "Unknown super_sub argument in character layout codes list"); 721 "Unknown super_sub argument in character layout codes list");
711 } 722 }
712 psiconv_debug(lev+3,off+len,"Super_sub: %02x",temp); 723 psiconv_debug(config,lev+3,off+len,"Super_sub: %02x",temp);
713 len ++; 724 len ++;
714 break; 725 break;
715 case 0x20: 726 case 0x20:
716 psiconv_progress(lev+3,off+len,"Going to read underline"); 727 psiconv_progress(config,lev+3,off+len,"Going to read underline");
717 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 728 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
718 &result->underline))) 729 &result->underline)))
719 goto ERROR1; 730 goto ERROR1;
720 len += leng; 731 len += leng;
721 break; 732 break;
722 case 0x21: 733 case 0x21:
723 psiconv_progress(lev+3,off+len,"Going to read strikethrough"); 734 psiconv_progress(config,lev+3,off+len,"Going to read strikethrough");
724 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 735 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
725 &result->strikethrough))) 736 &result->strikethrough)))
726 goto ERROR1; 737 goto ERROR1;
727 len += leng; 738 len += leng;
728 break; 739 break;
729 case 0x22: 740 case 0x22:
730 psiconv_progress(lev+3,off+len,"Going to read font"); 741 psiconv_progress(config,lev+3,off+len,"Going to read font");
731 if ((res = psiconv_parse_font(buf,lev+3,off+len, &leng, &temp_font))) 742 if ((res = psiconv_parse_font(config,buf,lev+3,off+len, &leng, &temp_font)))
732 goto ERROR1; 743 goto ERROR1;
733 psiconv_free_font(result->font); 744 psiconv_free_font(result->font);
734 result->font = temp_font; 745 result->font = temp_font;
735 len += leng; 746 len += leng;
736 break; 747 break;
737 case 0x23: 748 case 0x23:
738 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 749 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
739 len ++; 750 len ++;
740 break; 751 break;
741 case 0x24: 752 case 0x24:
742 psiconv_progress(lev+3,off+len, 753 psiconv_progress(config,lev+3,off+len,
743 "Going to read unknown code 0x24 (%02x expected)", 0); 754 "Going to read unknown code 0x24 (%02x expected)", 0);
744 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 755 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
745 if (res) 756 if (res)
746 goto ERROR1; 757 goto ERROR1;
747 if (temp != 0) { 758 if (temp != 0) {
748 psiconv_warn(lev+3,off+len, 759 psiconv_warn(config,lev+3,off+len,
749 "Unknown code 0x24 value != 0x0 (0x%02x)", temp); 760 "Unknown code 0x24 value != 0x0 (0x%02x)", temp);
750 } 761 }
751 len ++; 762 len ++;
752 break; 763 break;
753 default: 764 default:
754 psiconv_warn(lev+3,off+len,"Unknown code in character layout list"); 765 psiconv_warn(config,lev+3,off+len,"Unknown code in character layout list");
755 psiconv_debug(lev+3,off+len,"Code: %02x",id); 766 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
756 len ++; 767 len ++;
757 break; 768 break;
758 } 769 }
759 nr ++; 770 nr ++;
760 } 771 }
761 772
762 if (len - 4 != list_length) { 773 if (len - 4 != list_length) {
763 psiconv_warn(lev+2,off+len, 774 psiconv_warn(config,lev+2,off+len,
764 "Read past end of character layout codes list. I probably lost track" 775 "Read past end of character layout codes list. I probably lost track"
765 "somewhere!"); 776 "somewhere!");
766 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 777 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
767 len-4,list_length); 778 len-4,list_length);
768 res = PSICONV_E_PARSE; 779 res = PSICONV_E_PARSE;
769 goto ERROR1; 780 goto ERROR1;
770 } 781 }
771 782
772 len = list_length + 4; 783 len = list_length + 4;
773 784
774 psiconv_progress(lev+1,off+len, 785 psiconv_progress(config,lev+1,off+len,
775 "End of character layout list (total length: %08x)",len); 786 "End of character layout list (total length: %08x)",len);
776 787
777 if (length) 788 if (length)
778 *length = len; 789 *length = len;
779 return res; 790 return res;
780 791
781ERROR1: 792ERROR1:
782 psiconv_warn(lev+1,off,"Reading of character_layout_list failed"); 793 psiconv_warn(config,lev+1,off,"Reading of character_layout_list failed");
783 if (length) 794 if (length)
784 *length = 0; 795 *length = 0;
785 if (!res) 796 if (!res)
786 return -PSICONV_E_NOMEM; 797 return -PSICONV_E_NOMEM;
787 else 798 else

Legend:
Removed from v.110  
changed lines
  Added in v.182

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26