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

Legend:
Removed from v.67  
changed lines
  Added in v.184

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