/[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 65 Revision 351
1/* 1/*
2 parse_layout.c - Part of psiconv, a PSION 5 file formats converter 2 parse_layout.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2014 Frodo Looijaard <frodo@frodo.looijaard.name>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
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+len, 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)
145 else if (temp == 0x02) 157 else if (temp == 0x02)
146 (*result)->kind = psiconv_border_double; 158 (*result)->kind = psiconv_border_double;
147 else if (temp == 0x03) 159 else if (temp == 0x03)
148 (*result)->kind = psiconv_border_dotted; 160 (*result)->kind = psiconv_border_dotted;
149 else if (temp == 0x04) 161 else if (temp == 0x04)
150 (*result)->kind = psiconv_border_striped; 162 (*result)->kind = psiconv_border_dashed;
151 else if (temp == 0x05) 163 else if (temp == 0x05)
152 (*result)->kind = psiconv_border_dotstripe; 164 (*result)->kind = psiconv_border_dotdashed;
153 else if (temp == 0x06) 165 else if (temp == 0x06)
154 (*result)->kind = psiconv_border_dotdotstripe; 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;
222 238
223 if (!(*result = malloc(sizeof(**result)))) 239 if (!(*result = malloc(sizeof(**result))))
224 goto ERROR1; 240 goto ERROR1;
225 (*result)->on = psiconv_bool_true; 241 (*result)->on = psiconv_bool_true;
226 242
227 psiconv_progress(lev+1,off,"Going to parse bullet data"); 243 psiconv_progress(config,lev+1,off,"Going to parse bullet data");
228 psiconv_progress(lev+2,off+len,"Going to read bullet length"); 244 psiconv_progress(config,lev+2,off+len,"Going to read bullet length");
229 bullet_length = psiconv_read_u8(buf,lev+2,off+len,&res); 245 bullet_length = psiconv_read_u8(config,buf,lev+2,off+len,&res);
230 if (res) 246 if (res)
231 goto ERROR2; 247 goto ERROR2;
232 psiconv_debug(lev+2,off+len,"Length: %02x",bullet_length); 248 psiconv_debug(config,lev+2,off+len,"Length: %02x",bullet_length);
233 len ++; 249 len ++;
234 250
235 psiconv_progress(lev+2,off+len,"Going to read bullet font size"); 251 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); 252 (*result)->font_size = psiconv_read_size(config,buf,lev+2,off+len, &leng,&res);
237 if (res) 253 if (res)
238 goto ERROR2; 254 goto ERROR2;
239 len +=leng; 255 len +=leng;
240 256
241 psiconv_progress(lev+2,off+len,"Going to read bullet character"); 257 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
242 (*result)->character = psiconv_read_u8(buf,lev+2,off+len,&res); 258 (*result)->character = psiconv_unicode_read_char(config,buf,lev+2,
259 off+len,&leng,&res);
243 if (res) 260 if (res)
244 goto ERROR2; 261 goto ERROR2;
245 psiconv_debug(lev+2,off+len,"Character: %02x",(*result)->character); 262 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
246 len ++; 263 len += leng;
247 264
248 psiconv_progress(lev+2,off+len,"Going to read indent on/off"); 265 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))) 266 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
250 goto ERROR2; 267 goto ERROR2;
251 psiconv_debug(lev+2,off+len,"Indent on: %02x",(*result)->indent); 268 psiconv_debug(config,lev+2,off+len,"Indent on: %02x",(*result)->indent);
252 len += leng; 269 len += leng;
253 270
254 psiconv_progress(lev+2,off+len,"Going to read bullet color"); 271 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))) 272 if ((res = psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
256 goto ERROR2; 273 goto ERROR2;
257 len += leng; 274 len += leng;
258 275
259 psiconv_progress(lev+2,off+len,"Going to read bullet font"); 276 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))) 277 if ((res = psiconv_parse_font(config,buf,lev+2,off+len,&leng,&(*result)->font)))
261 goto ERROR3; 278 goto ERROR3;
262 len += leng; 279 len += leng;
263 280
264 if (len != bullet_length + 1) { 281 if (len != bullet_length + 1) {
265 psiconv_warn(lev+2,off,"Bullet data structure length mismatch"); 282 psiconv_warn(config,lev+2,off,"Bullet data structure length mismatch");
266 psiconv_debug(lev+2,off,"Length: specified %02x, found %02x", 283 psiconv_debug(config,lev+2,off,"Length: specified %02x, found %02x",
267 bullet_length,len-1); 284 bullet_length,len-1);
268 } 285 }
269 286
270 psiconv_progress(lev+1,off + len - 1, 287 psiconv_progress(config,lev+1,off + len - 1,
271 "End of bullet data (total length: %08x)",len); 288 "End of bullet data (total length: %08x)",len);
272 289
273 if (length) 290 if (length)
274 *length = len; 291 *length = len;
275 return 0; 292 return 0;
277ERROR3: 294ERROR3:
278 psiconv_free_color((*result)->color); 295 psiconv_free_color((*result)->color);
279ERROR2: 296ERROR2:
280 free (result); 297 free (result);
281ERROR1: 298ERROR1:
282 psiconv_warn(lev+1,off,"Reading of Bullet failed"); 299 psiconv_error(config,lev+1,off,"Reading of Bullet failed");
283 if (length) 300 if (length)
284 *length = 0; 301 *length = 0;
285 if (!res) 302 if (!res)
286 return -PSICONV_E_NOMEM; 303 return -PSICONV_E_NOMEM;
287 else 304 else
288 return res; 305 return res;
289} 306}
290 307
291int psiconv_parse_tab(const psiconv_buffer buf, int lev, psiconv_u32 off, 308int psiconv_parse_tab(const psiconv_config config,
309 const psiconv_buffer buf, int lev, psiconv_u32 off,
292 int *length, psiconv_tab *result) 310 int *length, psiconv_tab *result)
293{ 311{
294 int res = 0; 312 int res = 0;
295 int len = 0; 313 int len = 0;
296 int leng; 314 int leng;
297 psiconv_u8 temp; 315 psiconv_u8 temp;
298 316
299 psiconv_progress(lev+1,off,"Going to parse tab"); 317 psiconv_progress(config,lev+1,off,"Going to parse tab");
300 if (!(*result = malloc(sizeof(**result)))) 318 if (!(*result = malloc(sizeof(**result))))
301 goto ERROR1; 319 goto ERROR1;
302 320
303 psiconv_progress(lev+2,off,"Going to read tab location"); 321 psiconv_progress(config,lev+2,off,"Going to read tab location");
304 (*result)->location = psiconv_read_length(buf,lev+2,off+len,&leng,&res); 322 (*result)->location = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
305 if (res) 323 if (res)
306 goto ERROR2; 324 goto ERROR2;
307 len += leng; 325 len += leng;
308 326
309 psiconv_progress(lev+2,off+len,"Going to read the tab kind"); 327 psiconv_progress(config,lev+2,off+len,"Going to read the tab kind");
310 temp = psiconv_read_u8(buf,lev+2,off+len,&res); 328 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
311 if (res) 329 if (res)
312 goto ERROR2; 330 goto ERROR2;
313 if (temp == 1) 331 if (temp == 1)
314 (*result)->kind = psiconv_tab_left; 332 (*result)->kind = psiconv_tab_left;
315 else if (temp == 2) 333 else if (temp == 2)
316 (*result)->kind = psiconv_tab_centre; 334 (*result)->kind = psiconv_tab_centre;
317 else if (temp == 3) 335 else if (temp == 3)
318 (*result)->kind = psiconv_tab_right; 336 (*result)->kind = psiconv_tab_right;
319 else { 337 else {
320 psiconv_warn(lev+2,off+len,"Unknown tab kind argument"); 338 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)", 339 psiconv_debug(config,lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
322 temp); 340 temp);
323 (*result)->kind = psiconv_tab_left; 341 (*result)->kind = psiconv_tab_left;
324 } 342 }
325 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 343 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
326 len ++; 344 len ++;
327 345
328 if (length) 346 if (length)
329 *length = len; 347 *length = len;
330 348
331 psiconv_progress(lev+1,off+len-1,"End of tab (total length: %08x)",len); 349 psiconv_progress(config,lev+1,off+len-1,"End of tab (total length: %08x)",len);
332 return 0; 350 return 0;
333 351
334ERROR2: 352ERROR2:
335 free (result); 353 free (result);
336ERROR1: 354ERROR1:
337 psiconv_warn(lev+1,off,"Reading of Tab failed"); 355 psiconv_error(config,lev+1,off,"Reading of Tab failed");
338 if (length) 356 if (length)
339 *length = 0; 357 *length = 0;
340 if (!res) 358 if (!res)
341 return -PSICONV_E_NOMEM; 359 return -PSICONV_E_NOMEM;
342 else 360 else
343 return res; 361 return res;
344} 362}
345 363
346int psiconv_parse_paragraph_layout_list(const psiconv_buffer buf, int lev, 364int psiconv_parse_paragraph_layout_list(const psiconv_config config,
365 const psiconv_buffer buf, int lev,
347 psiconv_u32 off, int *length, 366 psiconv_u32 off, int *length,
348 psiconv_paragraph_layout result) 367 psiconv_paragraph_layout result)
349{ 368{
350 int res=0; 369 int res=0;
351 int len=0; 370 int len=0;
355 psiconv_tab temp_tab; 374 psiconv_tab temp_tab;
356 psiconv_color temp_color; 375 psiconv_color temp_color;
357 psiconv_border temp_border; 376 psiconv_border temp_border;
358 psiconv_bullet temp_bullet; 377 psiconv_bullet temp_bullet;
359 378
360 psiconv_progress(lev+1,off,"Going to read paragraph layout list"); 379 psiconv_progress(config,lev+1,off,"Going to read paragraph layout list");
361 380
362 psiconv_progress(lev+2,off,"Going to read the list length"); 381 psiconv_progress(config,lev+2,off,"Going to read the list length");
363 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 382 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
364 if (res) 383 if (res)
365 goto ERROR1; 384 goto ERROR1;
366 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 385 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
367 len += 4; 386 len += 4;
368 387
369 nr = 0; 388 nr = 0;
370 while(len - 4 < list_length) { 389 while(len - 4 < list_length) {
371 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 390 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"); 391 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
373 id = psiconv_read_u8(buf,lev+2,off+len,&res); 392 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
374 if (res) 393 if (res)
375 goto ERROR1; 394 goto ERROR1;
376 psiconv_debug(lev+3,off+len,"Id: %02x",id); 395 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
377 len ++; 396 len ++;
378 switch(id) { 397 switch(id) {
379 case 0x01: 398 case 0x01:
380 psiconv_progress(lev+3,off+len,"Going to read background color"); 399 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))) 400 if ((res = psiconv_parse_color(config,buf,lev+3,off+len,&leng,&temp_color)))
382 goto ERROR1; 401 goto ERROR1;
383 psiconv_free_color(result->back_color); 402 psiconv_free_color(result->back_color);
384 result->back_color = temp_color; 403 result->back_color = temp_color;
385 len += leng; 404 len += leng;
386 break; 405 break;
387 case 0x02: 406 case 0x02:
388 psiconv_progress(lev+3,off+len ,"Going to read indent left"); 407 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); 408 result->indent_left = psiconv_read_length(config,buf,lev+3,off+len,&leng,&res);
390 if (res) 409 if (res)
391 goto ERROR1; 410 goto ERROR1;
392 len += leng; 411 len += leng;
393 break; 412 break;
394 case 0x03: 413 case 0x03:
395 psiconv_progress(lev+3,off+len,"Going to read indent right"); 414 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, 415 result->indent_right = psiconv_read_length(config,buf,lev+2,off+len,&leng,
397 &res); 416 &res);
398 if (res) 417 if (res)
399 goto ERROR1; 418 goto ERROR1;
400 len += leng; 419 len += leng;
401 break; 420 break;
402 case 0x04: 421 case 0x04:
403 psiconv_progress(lev+3,off+len,"Going to read indent left first line"); 422 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, 423 result->indent_first = psiconv_read_length(config,buf,lev+2,off+len, &leng,
405 &res); 424 &res);
406 if (res) 425 if (res)
407 goto ERROR1; 426 goto ERROR1;
408 len += leng; 427 len += leng;
409 break; 428 break;
410 case 0x05: 429 case 0x05:
411 psiconv_progress(lev+3,off+len,"Going to read horizontal justify"); 430 psiconv_progress(config,lev+3,off+len,"Going to read horizontal justify");
412 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 431 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
413 if (res) 432 if (res)
414 goto ERROR1; 433 goto ERROR1;
415 if (temp == 0x00) 434 if (temp == 0x00)
416 result->justify_hor = psiconv_justify_left; 435 result->justify_hor = psiconv_justify_left;
417 else if (temp == 0x01) 436 else if (temp == 0x01)
419 else if (temp == 0x02) 438 else if (temp == 0x02)
420 result->justify_hor = psiconv_justify_right; 439 result->justify_hor = psiconv_justify_right;
421 else if (temp == 0x03) 440 else if (temp == 0x03)
422 result->justify_hor = psiconv_justify_full; 441 result->justify_hor = psiconv_justify_full;
423 else { 442 else {
424 psiconv_warn(lev+3,off+len, "Unknown horizontal justify argument " 443 psiconv_warn(config,lev+3,off+len, "Unknown horizontal justify argument "
425 "in paragraph layout codes list"); 444 "in paragraph layout codes list");
426 result->justify_hor = psiconv_justify_left; 445 result->justify_hor = psiconv_justify_left;
427 } 446 }
428 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 447 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
429 len ++; 448 len ++;
430 break; 449 break;
431 case 0x06: 450 case 0x06:
432 psiconv_progress(lev+3,off+len,"Going to read vertical justify"); 451 psiconv_progress(config,lev+3,off+len,"Going to read vertical justify");
433 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 452 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
434 if (res) 453 if (res)
435 goto ERROR1; 454 goto ERROR1;
436 if (temp == 0x00) 455 if (temp == 0x00)
437 result->justify_ver = psiconv_justify_top; 456 result->justify_ver = psiconv_justify_top;
438 else if (temp == 0x01) 457 else if (temp == 0x01)
439 result->justify_ver = psiconv_justify_middle; 458 result->justify_ver = psiconv_justify_middle;
440 else if (temp == 0x02) 459 else if (temp == 0x02)
441 result->justify_ver = psiconv_justify_bottom; 460 result->justify_ver = psiconv_justify_bottom;
442 else { 461 else {
443 psiconv_warn(lev+3,off+len, "Unknown vertical justify argument " 462 psiconv_warn(config,lev+3,off+len, "Unknown vertical justify argument "
444 "in paragraph layout codes list"); 463 "in paragraph layout codes list");
445 result->justify_ver = psiconv_justify_bottom; 464 result->justify_ver = psiconv_justify_bottom;
446 } 465 }
447 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 466 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
448 len ++; 467 len ++;
468 break;
449 case 0x07: 469 case 0x07:
450 psiconv_progress(lev+3,off+len,"Going to read interline distance"); 470 psiconv_progress(config,lev+3,off+len,"Going to read linespacing distance");
451 result->interline = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 471 result->linespacing = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
452 if (res) 472 if (res)
453 goto ERROR1; 473 goto ERROR1;
454 len += leng; 474 len += leng;
455 break; 475 break;
456 case 0x08: 476 case 0x08:
457 psiconv_progress(lev+3,off+len,"Going to read interline exact"); 477 psiconv_progress(config,lev+3,off+len,"Going to read linespacing exact");
458 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 478 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
459 &result->interline_exact))) 479 &result->linespacing_exact)))
460 goto ERROR1; 480 goto ERROR1;
461 len += leng; 481 len += leng;
462 break; 482 break;
463 case 0x09: 483 case 0x09:
464 psiconv_progress(lev+3,off+len,"Going to read top space"); 484 psiconv_progress(config,lev+3,off+len,"Going to read top space");
465 result->top_space = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 485 result->space_above = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
466 if (res) 486 if (res)
467 goto ERROR1; 487 goto ERROR1;
468 len += leng; 488 len += leng;
469 break; 489 break;
470 case 0x0a: 490 case 0x0a:
471 psiconv_progress(lev+3,off+len,"Going to read bottom space"); 491 psiconv_progress(config,lev+3,off+len,"Going to read bottom space");
472 result->bottom_space = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 492 result->space_below = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
473 if (res) 493 if (res)
474 goto ERROR1; 494 goto ERROR1;
475 len += leng; 495 len += leng;
476 break; 496 break;
477 case 0x0b: 497 case 0x0b:
478 psiconv_progress(lev+3,off+len,"Going to read on one page"); 498 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, 499 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
480 &result->on_one_page))) 500 &result->keep_together)))
481 goto ERROR1; 501 goto ERROR1;
482 len += leng; 502 len += leng;
483 break; 503 break;
484 case 0x0c: 504 case 0x0c:
485 psiconv_progress(lev+3,off+len,"Going to read together with"); 505 psiconv_progress(config,lev+3,off+len,"Going to read together with");
486 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 506 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
487 &result->together_with))) 507 &result->keep_with_next)))
488 goto ERROR1; 508 goto ERROR1;
489 len += leng; 509 len += leng;
490 break; 510 break;
491 case 0x0d: 511 case 0x0d:
492 psiconv_progress(lev+3,off+len,"Going to read on next page"); 512 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, 513 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
494 &result->on_next_page))) 514 &result->on_next_page)))
495 goto ERROR1; 515 goto ERROR1;
496 len += leng; 516 len += leng;
497 break; 517 break;
498 case 0x0e: 518 case 0x0e:
499 psiconv_progress(lev+3,off+len,"Going to read no widow protection"); 519 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, 520 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
501 &result->no_widow_protection))) 521 &result->no_widow_protection)))
502 goto ERROR1; 522 goto ERROR1;
503 len += leng; 523 len += leng;
504 break; 524 break;
525 case 0x0f:
526 psiconv_progress(config,lev+3,off+len,"Going to read wrap to fit cell limits");
527 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
528 &result->wrap_to_fit_cell)))
529 goto ERROR1;
530 len += leng;
531 break;
505 case 0x10: 532 case 0x10:
506 psiconv_progress(lev+3,off+len,"Going to read border distance to text"); 533 psiconv_progress(config,lev+3,off+len,"Going to read border distance to text");
507 result->border_distance = psiconv_read_length(buf,lev+3, 534 result->border_distance = psiconv_read_length(config,buf,lev+3,
508 off+len,&leng,&res); 535 off+len,&leng,&res);
509 if (res) 536 if (res)
510 goto ERROR1; 537 goto ERROR1;
511 len += leng; 538 len += leng;
512 break; 539 break;
513 case 0x11: 540 case 0x11:
514 psiconv_progress(lev+3,off+len,"Going to read top border"); 541 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))) 542 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
516 goto ERROR1; 543 goto ERROR1;
517 psiconv_free_border(result->top_border); 544 psiconv_free_border(result->top_border);
518 result->top_border = temp_border; 545 result->top_border = temp_border;
519 len += leng; 546 len += leng;
520 break; 547 break;
521 case 0x12: 548 case 0x12:
522 psiconv_progress(lev+3,off+len,"Going to read bottom border"); 549 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))) 550 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
524 goto ERROR1; 551 goto ERROR1;
525 psiconv_free_border(result->bottom_border); 552 psiconv_free_border(result->bottom_border);
526 result->bottom_border = temp_border; 553 result->bottom_border = temp_border;
527 len += leng; 554 len += leng;
528 break; 555 break;
529 case 0x13: 556 case 0x13:
530 psiconv_progress(lev+3,off+len,"Going to read left border"); 557 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))) 558 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
532 goto ERROR1; 559 goto ERROR1;
533 psiconv_free_border(result->left_border); 560 psiconv_free_border(result->left_border);
534 result->left_border = temp_border; 561 result->left_border = temp_border;
535 len += leng; 562 len += leng;
536 break; 563 break;
537 case 0x14: 564 case 0x14:
538 psiconv_progress(lev+3,off+len,"Going to read right border"); 565 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))) 566 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
540 goto ERROR1; 567 goto ERROR1;
541 psiconv_free_border(result->right_border); 568 psiconv_free_border(result->right_border);
542 result->right_border = temp_border; 569 result->right_border = temp_border;
543 len += leng; 570 len += leng;
544 break; 571 break;
545 case 0x15: 572 case 0x15:
546 psiconv_progress(lev+3,off+len,"Going to read bullet"); 573 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))) 574 if ((res = psiconv_parse_bullet(config,buf,lev+3,off+len,&leng,&temp_bullet)))
548 goto ERROR1; 575 goto ERROR1;
549 psiconv_free_bullet(result->bullet); 576 psiconv_free_bullet(result->bullet);
550 result->bullet = temp_bullet; 577 result->bullet = temp_bullet;
551 len += leng; 578 len += leng;
552 break; 579 break;
553 case 0x16: 580 case 0x16:
554 psiconv_progress(lev+3,off+len,"Going to read standard tabs"); 581 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, 582 result->tabs->normal = psiconv_read_length(config,buf,lev+3,off+len,&leng,
556 &res); 583 &res);
557 if (res) 584 if (res)
558 goto ERROR1; 585 goto ERROR1;
559 len += leng; 586 len += leng;
560 break; 587 break;
561 case 0x17: 588 case 0x17:
562 psiconv_progress(lev+3,off+len,"Going to read extra tab"); 589 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))) 590 if ((res = psiconv_parse_tab(config,buf,lev+3,off+len,&leng,&temp_tab)))
564 goto ERROR1; 591 goto ERROR1;
565 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) { 592 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
566 psiconv_free_tab(temp_tab); 593 psiconv_free_tab(temp_tab);
567 goto ERROR1; 594 goto ERROR1;
568 } 595 }
596 psiconv_free_tab(temp_tab);
569 len += leng; 597 len += leng;
570 break; 598 break;
571 default: 599 default:
572 psiconv_warn(lev+3,off+len, 600 psiconv_warn(config,lev+3,off+len,
573 "Unknown code in paragraph layout codes list"); 601 "Unknown code in paragraph layout codes list");
574 psiconv_debug(lev+3,off+len,"Code: %02x",id); 602 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
575 len ++; 603 len ++;
576 break; 604 break;
577 } 605 }
578 nr ++; 606 nr ++;
579 } 607 }
580 608
581 if (len - 4 != list_length) { 609 if (len - 4 != list_length) {
582 psiconv_warn(lev+2,off+len, 610 psiconv_error(config,lev+2,off+len,
583 "Read past end of paragraph layout codes list. I probably lost track" 611 "Read past end of paragraph layout codes list. I probably lost track "
584 "somewhere!"); 612 "somewhere!");
585 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 613 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
586 len-4,list_length); 614 len-4,list_length);
587 res = PSICONV_E_PARSE; 615 res = PSICONV_E_PARSE;
588 goto ERROR1; 616 goto ERROR1;
589 } 617 }
590 618
591 len = list_length + 4; 619 len = list_length + 4;
592 620
593 psiconv_progress(lev+1,off+len, 621 psiconv_progress(config,lev+1,off+len,
594 "End of paragraph layout list (total length: %08x)",len); 622 "End of paragraph layout list (total length: %08x)",len);
595 623
596 if (length) 624 if (length)
597 *length = len; 625 *length = len;
598 return 0; 626 return 0;
599 627
600ERROR1: 628ERROR1:
601 psiconv_warn(lev+1,off,"Reading of paragraph_layout_list failed"); 629 psiconv_error(config,lev+1,off,"Reading of paragraph_layout_list failed");
602 if (length) 630 if (length)
603 *length = 0; 631 *length = 0;
604 if (!res) 632 if (!res)
605 return -PSICONV_E_NOMEM; 633 return -PSICONV_E_NOMEM;
606 else 634 else
607 return res; 635 return res;
608} 636}
609 637
610int psiconv_parse_character_layout_list(const psiconv_buffer buf, int lev, 638int psiconv_parse_character_layout_list(const psiconv_config config,
639 const psiconv_buffer buf, int lev,
611 psiconv_u32 off, int *length, 640 psiconv_u32 off, int *length,
612 psiconv_character_layout result) 641 psiconv_character_layout result)
613{ 642{
614 int res=0; 643 int res=0;
615 int len=0; 644 int len=0;
617 psiconv_u8 id; 646 psiconv_u8 id;
618 psiconv_u32 temp; 647 psiconv_u32 temp;
619 psiconv_color temp_color; 648 psiconv_color temp_color;
620 psiconv_font temp_font; 649 psiconv_font temp_font;
621 650
622 psiconv_progress(lev+1,off,"Going to read character layout codes"); 651 psiconv_progress(config,lev+1,off,"Going to read character layout codes");
623 652
624 psiconv_progress(lev+2,off,"Going to read the list length"); 653 psiconv_progress(config,lev+2,off,"Going to read the list length");
625 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 654 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
626 if (res) 655 if (res)
627 goto ERROR1; 656 goto ERROR1;
628 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 657 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
629 len += 4; 658 len += 4;
630 659
631 nr = 0; 660 nr = 0;
632 while(len-4 < list_length) { 661 while(len-4 < list_length) {
633 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 662 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"); 663 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
635 id = psiconv_read_u8(buf,lev+2,off+len,&res); 664 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
636 if (res) 665 if (res)
637 goto ERROR1; 666 goto ERROR1;
638 psiconv_debug(lev+3,off+len,"Id: %02x",id); 667 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
639 len ++; 668 len ++;
640 switch(id) { 669 switch(id) {
670 case 0x18:
671 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
672 len ++;
673 break;
641 case 0x19: 674 case 0x19:
642 psiconv_progress(lev+3,off+len,"Going to read text color"); 675 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))) 676 if ((res = psiconv_parse_color(config,buf,lev+3,off+len, &leng,&temp_color)))
644 goto ERROR1; 677 goto ERROR1;
645 psiconv_free_color(result->color); 678 psiconv_free_color(result->color);
646 result->color = temp_color; 679 result->color = temp_color;
647 len += leng; 680 len += leng;
648 break; 681 break;
649 case 0x1a: 682 case 0x1a:
650 psiconv_progress(lev+3,off+len,"Going to read background color (?)"); 683 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))) 684 if ((res = psiconv_parse_color(config,buf,lev+2,off+len, &leng,&temp_color)))
652 goto ERROR1; 685 goto ERROR1;
653 psiconv_free_color(result->back_color); 686 psiconv_free_color(result->back_color);
654 result->back_color = temp_color; 687 result->back_color = temp_color;
655 len += leng; 688 len += leng;
656 break; 689 break;
690 case 0x1b:
691 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
692 len ++;
693 break;
657 case 0x1c: 694 case 0x1c:
658 psiconv_progress(lev+3,off+len,"Going to read font size"); 695 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); 696 result->font_size = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
660 if (res) 697 if (res)
661 goto ERROR1; 698 goto ERROR1;
662 len += leng; 699 len += leng;
663 break; 700 break;
664 case 0x1d: 701 case 0x1d:
665 psiconv_progress(lev+3,off+len,"Going to read italic"); 702 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))) 703 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->italic)))
667 goto ERROR1; 704 goto ERROR1;
668 len += leng; 705 len += leng;
669 break; 706 break;
670 case 0x1e: 707 case 0x1e:
671 psiconv_progress(lev+3,off+len,"Going to read bold"); 708 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))) 709 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->bold)))
673 goto ERROR1; 710 goto ERROR1;
674 len += leng; 711 len += leng;
675 break; 712 break;
676 case 0x1f: 713 case 0x1f:
677 psiconv_progress(lev+3,off+len,"Going to read super_sub"); 714 psiconv_progress(config,lev+3,off+len,"Going to read super_sub");
678 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 715 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
679 if (res) 716 if (res)
680 goto ERROR1; 717 goto ERROR1;
681 if (temp == 0x00) 718 if (temp == 0x00)
682 result->super_sub = psiconv_normalscript; 719 result->super_sub = psiconv_normalscript;
683 else if (temp == 0x01) 720 else if (temp == 0x01)
684 result->super_sub = psiconv_superscript; 721 result->super_sub = psiconv_superscript;
685 else if (temp == 0x02) 722 else if (temp == 0x02)
686 result->super_sub = psiconv_subscript; 723 result->super_sub = psiconv_subscript;
687 else { 724 else {
688 psiconv_warn(lev+3,off+len, 725 psiconv_warn(config,lev+3,off+len,
689 "Unknown super_sub argument in character layout codes list"); 726 "Unknown super_sub argument in character layout codes list");
690 } 727 }
691 psiconv_debug(lev+3,off+len,"Super_sub: %02x",temp); 728 psiconv_debug(config,lev+3,off+len,"Super_sub: %02x",temp);
692 len ++; 729 len ++;
693 break; 730 break;
694 case 0x20: 731 case 0x20:
695 psiconv_progress(lev+3,off+len,"Going to read underline"); 732 psiconv_progress(config,lev+3,off+len,"Going to read underline");
696 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 733 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
697 &result->underline))) 734 &result->underline)))
698 goto ERROR1; 735 goto ERROR1;
699 len += leng; 736 len += leng;
700 break; 737 break;
701 case 0x21: 738 case 0x21:
702 psiconv_progress(lev+3,off+len,"Going to read strike_out"); 739 psiconv_progress(config,lev+3,off+len,"Going to read strikethrough");
703 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 740 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
704 &result->strike_out))) 741 &result->strikethrough)))
705 goto ERROR1; 742 goto ERROR1;
706 len += leng; 743 len += leng;
707 break; 744 break;
708 case 0x22: 745 case 0x22:
709 psiconv_progress(lev+3,off+len,"Going to read font"); 746 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))) 747 if ((res = psiconv_parse_font(config,buf,lev+3,off+len, &leng, &temp_font)))
711 goto ERROR1; 748 goto ERROR1;
712 psiconv_free_font(result->font); 749 psiconv_free_font(result->font);
713 result->font = temp_font; 750 result->font = temp_font;
714 len += leng; 751 len += leng;
715 break; 752 break;
753 case 0x23:
754 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
755 len ++;
756 break;
716 case 0x24: 757 case 0x24:
717 psiconv_progress(lev+3,off+len, 758 psiconv_progress(config,lev+3,off+len,
718 "Going to read unknown code 0x24 (%02x expected)", 0); 759 "Going to read unknown code 0x24 (%02x expected)", 0);
719 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 760 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
720 if (res) 761 if (res)
721 goto ERROR1; 762 goto ERROR1;
722 if (temp != 0) { 763 if (temp != 0) {
723 psiconv_warn(lev+3,off+len, 764 psiconv_warn(config,lev+3,off+len,
724 "Unknown code 0x24 value != 0x0 (0x%02x)", temp); 765 "Unknown code 0x24 value != 0x0 (0x%02x)", temp);
725 } 766 }
726 len ++; 767 len ++;
727 break; 768 break;
728 default: 769 default:
729 psiconv_warn(lev+3,off+len,"Unknown code in character layout list"); 770 psiconv_warn(config,lev+3,off+len,"Unknown code in character layout list");
730 psiconv_debug(lev+3,off+len,"Code: %02x",id); 771 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
731 len ++; 772 len ++;
732 break; 773 break;
733 } 774 }
734 nr ++; 775 nr ++;
735 } 776 }
736 777
737 if (len - 4 != list_length) { 778 if (len - 4 != list_length) {
738 psiconv_warn(lev+2,off+len, 779 psiconv_error(config,lev+2,off+len,
739 "Read past end of character layout codes list. I probably lost track" 780 "Read past end of character layout codes list. I probably lost track "
740 "somewhere!"); 781 "somewhere!");
741 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 782 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
742 len-4,list_length); 783 len-4,list_length);
743 res = PSICONV_E_PARSE; 784 res = PSICONV_E_PARSE;
744 goto ERROR1; 785 goto ERROR1;
745 } 786 }
746 787
747 len = list_length + 4; 788 len = list_length + 4;
748 789
749 psiconv_progress(lev+1,off+len, 790 psiconv_progress(config,lev+1,off+len,
750 "End of character layout list (total length: %08x)",len); 791 "End of character layout list (total length: %08x)",len);
751 792
752 if (length) 793 if (length)
753 *length = len; 794 *length = len;
754 return res; 795 return res;
755 796
756ERROR1: 797ERROR1:
757 psiconv_warn(lev+1,off,"Reading of character_layout_list failed"); 798 psiconv_error(config,lev+1,off,"Reading of character_layout_list failed");
758 if (length) 799 if (length)
759 *length = 0; 800 *length = 0;
760 if (!res) 801 if (!res)
761 return -PSICONV_E_NOMEM; 802 return -PSICONV_E_NOMEM;
762 else 803 else

Legend:
Removed from v.65  
changed lines
  Added in v.351

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