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

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

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

Revision 97 Revision 168
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "parse_routines.h" 25#include "parse_routines.h"
26#include "error.h" 26#include "error.h"
27 27
28#ifdef DMALLOC
29#include <dmalloc.h>
30#endif
31
32
28int psiconv_parse_jumptable_section(const psiconv_buffer buf,int lev, 33int psiconv_parse_jumptable_section(const psiconv_config config,
34 const psiconv_buffer buf,int lev,
29 psiconv_u32 off, int *length, 35 psiconv_u32 off, int *length,
30 psiconv_jumptable_section *result) 36 psiconv_jumptable_section *result)
31{ 37{
32 int res = 0; 38 int res = 0;
33 int len = 0; 39 int len = 0;
34 psiconv_u32 listlen,temp; 40 psiconv_u32 listlen,temp;
35 int i; 41 int i;
36 42
37 psiconv_progress(lev+1,off+len,"Going to read the jumptable section"); 43 psiconv_progress(config,lev+1,off+len,"Going to read the jumptable section");
38 if (!((*result) = psiconv_list_new(sizeof(psiconv_u32)))) 44 if (!((*result) = psiconv_list_new(sizeof(psiconv_u32))))
39 goto ERROR1; 45 goto ERROR1;
40 46
41 psiconv_progress(lev+2,off+len,"Going to read the list length"); 47 psiconv_progress(config,lev+2,off+len,"Going to read the list length");
42 listlen = psiconv_read_u32(buf,lev+2,off+len,&res); 48 listlen = psiconv_read_u32(config,buf,lev+2,off+len,&res);
43 if (res) 49 if (res)
44 goto ERROR2; 50 goto ERROR2;
45 psiconv_debug(lev+2,off+len,"List length: %08x",listlen); 51 psiconv_debug(config,lev+2,off+len,"List length: %08x",listlen);
46 len += 4; 52 len += 4;
47 53
48 psiconv_progress(lev+2,off+len,"Going to read the list"); 54 psiconv_progress(config,lev+2,off+len,"Going to read the list");
49 for (i = 0; i < listlen; i++) { 55 for (i = 0; i < listlen; i++) {
50 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 56 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
51 if (res) 57 if (res)
52 goto ERROR2; 58 goto ERROR2;
53 if ((res = psiconv_list_add(*result,&temp))) 59 if ((res = psiconv_list_add(*result,&temp)))
54 goto ERROR2; 60 goto ERROR2;
55 psiconv_debug(lev+3,off+len,"Offset: %08x",temp); 61 psiconv_debug(config,lev+3,off+len,"Offset: %08x",temp);
56 len += 4; 62 len += 4;
57 } 63 }
58 64
59 if (length) 65 if (length)
60 *length = len; 66 *length = len;
61 67
62 psiconv_progress(lev+1,off+len-1,"End of jumptable section " 68 psiconv_progress(config,lev+1,off+len-1,"End of jumptable section "
63 "(total length: %08x)", len); 69 "(total length: %08x)", len);
64 70
65 return 0; 71 return 0;
66 72
67ERROR2: 73ERROR2:
68 psiconv_list_free(*result); 74 psiconv_list_free(*result);
69ERROR1: 75ERROR1:
70 psiconv_warn(lev+1,off,"Reading of Jumptable Section failed"); 76 psiconv_warn(config,lev+1,off,"Reading of Jumptable Section failed");
71 if (length) 77 if (length)
72 *length = 0; 78 *length = 0;
73 if (!res) 79 if (!res)
74 return -PSICONV_E_NOMEM; 80 return -PSICONV_E_NOMEM;
75 else 81 else
76 return res; 82 return res;
77} 83}
78 84
79static int decode_byte(int lev, psiconv_u32 off, 85static int decode_byte(const psiconv_config config, int lev, psiconv_u32 off,
80 psiconv_paint_data_section data, psiconv_u32 *pixelnr, 86 psiconv_paint_data_section data, psiconv_u32 *pixelnr,
81 psiconv_u8 byte, int bits_per_pixel, int linelen, 87 psiconv_u8 byte, int bits_per_pixel, int linelen,
82 int *linepos,int picsize) 88 int *linepos,int picsize)
83{ 89{
84 int mask = (bits_per_pixel << 1) -1; 90 int mask = (bits_per_pixel << 1) -1;
85 int i; 91 int i;
86 if (*linepos < (data->xsize + (8/bits_per_pixel) - 1) / (8/bits_per_pixel)) 92 if (*linepos < (data->xsize + (8/bits_per_pixel) - 1) / (8/bits_per_pixel))
87 for (i = 0; i < 8/bits_per_pixel; i ++) { 93 for (i = 0; i < 8/bits_per_pixel; i ++) {
88 if ((i != 0) && ((*pixelnr % (data->xsize)) == 0)) { 94 if ((i != 0) && ((*pixelnr % (data->xsize)) == 0)) {
89 psiconv_debug(lev+1,off,"Skipping padding: %02x",byte); 95 psiconv_debug(config,lev+1,off,"Skipping padding: %02x",byte);
90 i = 8; 96 i = 8;
91 } else if (*pixelnr >= picsize) { 97 } else if (*pixelnr >= picsize) {
92 psiconv_warn(lev+1,off,"Corrupted picture data!"); 98 psiconv_warn(config,lev+1,off,"Corrupted picture data!");
93 psiconv_debug(lev+1,off,"Trying to write a pixel too far"); 99 psiconv_debug(config,lev+1,off,"Trying to write a pixel too far");
94 return -1; 100 return -1;
95 } else { 101 } else {
96 data->red[*pixelnr] = data->green[*pixelnr] = data->blue[*pixelnr] = 102 data->red[*pixelnr] = data->green[*pixelnr] = data->blue[*pixelnr] =
97 ((float) (byte & mask)) / ((1 << bits_per_pixel) -1); 103 ((float) (byte & mask)) / ((1 << bits_per_pixel) -1);
98 psiconv_debug(lev+1,off,"Pixel %04x: (%04x,%04x) value %02x, color %f", 104 psiconv_debug(config,lev+1,off,"Pixel %04x: (%04x,%04x) value %02x, color %f",
99 *pixelnr,*pixelnr % data->xsize, 105 *pixelnr,*pixelnr % data->xsize,
100 *pixelnr / data->xsize, byte&mask, data->red[*pixelnr]); 106 *pixelnr / data->xsize, byte&mask, data->red[*pixelnr]);
101 byte = byte >> bits_per_pixel; 107 byte = byte >> bits_per_pixel;
102 (*pixelnr) ++; 108 (*pixelnr) ++;
103 } 109 }
104 } 110 }
105 else 111 else
106 psiconv_debug(lev+1,off,"Skipping padding byte"); 112 psiconv_debug(config,lev+1,off,"Skipping padding byte");
107 (*linepos) ++; 113 (*linepos) ++;
108 if (*linepos == linelen) 114 if (*linepos == linelen)
109 *linepos = 0; 115 *linepos = 0;
110 return 0; 116 return 0;
111} 117}
112 118
113 119
114int psiconv_parse_paint_data_section(const psiconv_buffer buf,int lev, 120int psiconv_parse_paint_data_section(const psiconv_config config,
121 const psiconv_buffer buf,int lev,
115 psiconv_u32 off, int *length,int isclipart, 122 psiconv_u32 off, int *length,int isclipart,
116 psiconv_paint_data_section *result) 123 psiconv_paint_data_section *result)
117{ 124{
118 int res = 0; 125 int res = 0;
119 int len = 0; 126 int len = 0;
121 psiconv_u8 marker; 128 psiconv_u8 marker;
122 int i,leng; 129 int i,leng;
123 psiconv_u32 bits_per_pixel,compression; 130 psiconv_u32 bits_per_pixel,compression;
124 int linepos = 0; 131 int linepos = 0;
125 132
126 psiconv_progress(lev+1,off,"Going to read a paint data section"); 133 psiconv_progress(config,lev+1,off,"Going to read a paint data section");
127 if (!((*result) = malloc(sizeof(**result)))) 134 if (!((*result) = malloc(sizeof(**result))))
128 goto ERROR1; 135 goto ERROR1;
129 136
130 psiconv_progress(lev+2,off+len,"Going to read section size"); 137 psiconv_progress(config,lev+2,off+len,"Going to read section size");
131 size = psiconv_read_u32(buf,lev+2,off+len,&res); 138 size = psiconv_read_u32(config,buf,lev+2,off+len,&res);
132 if (res) 139 if (res)
133 goto ERROR2; 140 goto ERROR2;
134 psiconv_debug(lev+2,off+len,"Section size: %08x",size); 141 psiconv_debug(config,lev+2,off+len,"Section size: %08x",size);
135 len += 4; 142 len += 4;
136 143
137 psiconv_progress(lev+2,off+len,"Going to read pixel data offset"); 144 psiconv_progress(config,lev+2,off+len,"Going to read pixel data offset");
138 offset = psiconv_read_u32(buf,lev+2,off+len,&res); 145 offset = psiconv_read_u32(config,buf,lev+2,off+len,&res);
139 if (res) 146 if (res)
140 goto ERROR2; 147 goto ERROR2;
141 if (offset != 0x28) { 148 if (offset != 0x28) {
142 psiconv_warn(lev+2,off+len, 149 psiconv_warn(config,lev+2,off+len,
143 "Paint data section data offset has unexpected value"); 150 "Paint data section data offset has unexpected value");
144 psiconv_debug(lev+2,off+len, 151 psiconv_debug(config,lev+2,off+len,
145 "Data offset: read %08x, expected %08x",offset,0x28); 152 "Data offset: read %08x, expected %08x",offset,0x28);
146 res = -1; 153 res = -1;
147 } 154 }
148 len += 4; 155 len += 4;
149 156
150 psiconv_progress(lev+2,off+len,"Going to read picture X size"); 157 psiconv_progress(config,lev+2,off+len,"Going to read picture X size");
151 (*result)->xsize = psiconv_read_u32(buf,lev+2,off+len,&res); 158 (*result)->xsize = psiconv_read_u32(config,buf,lev+2,off+len,&res);
152 if (res) 159 if (res)
153 goto ERROR2; 160 goto ERROR2;
154 psiconv_debug(lev+2,off+len,"Picture X size: %08x:",(*result)->xsize); 161 psiconv_debug(config,lev+2,off+len,"Picture X size: %08x:",(*result)->xsize);
155 len += 4; 162 len += 4;
156 163
157 psiconv_progress(lev+2,off+len,"Going to read picture Y size"); 164 psiconv_progress(config,lev+2,off+len,"Going to read picture Y size");
158 (*result)->ysize = psiconv_read_u32(buf,lev+2,off+len,&res); 165 (*result)->ysize = psiconv_read_u32(config,buf,lev+2,off+len,&res);
159 if (res) 166 if (res)
160 goto ERROR2; 167 goto ERROR2;
161 psiconv_debug(lev+2,off+len,"Picture Y size: %08x:",(*result)->ysize); 168 psiconv_debug(config,lev+2,off+len,"Picture Y size: %08x:",(*result)->ysize);
162 len += 4; 169 len += 4;
163 170
164 picsize = (*result)->ysize * (*result)->xsize; 171 picsize = (*result)->ysize * (*result)->xsize;
165 172
166 psiconv_progress(lev+2,off+len,"Going to read the real picture x size"); 173 psiconv_progress(config,lev+2,off+len,"Going to read the real picture x size");
167 (*result)->pic_xsize = psiconv_read_length(buf,lev+2,off+len,&leng,&res); 174 (*result)->pic_xsize = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
168 if (res) 175 if (res)
169 goto ERROR2; 176 goto ERROR2;
170 psiconv_debug(lev+2,off+len,"Picture x size: %f",(*result)->pic_xsize); 177 psiconv_debug(config,lev+2,off+len,"Picture x size: %f",(*result)->pic_xsize);
171 len += leng; 178 len += leng;
172 179
173 psiconv_progress(lev+2,off+len,"Going to read the real picture y size"); 180 psiconv_progress(config,lev+2,off+len,"Going to read the real picture y size");
174 (*result)->pic_ysize = psiconv_read_length(buf,lev+2,off+len,&leng,&res); 181 (*result)->pic_ysize = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
175 if (res) 182 if (res)
176 goto ERROR2; 183 goto ERROR2;
177 psiconv_debug(lev+2,off+len,"Picture y size: %f",(*result)->pic_ysize); 184 psiconv_debug(config,lev+2,off+len,"Picture y size: %f",(*result)->pic_ysize);
178 len += leng; 185 len += leng;
179 186
180 psiconv_progress(lev+2,off+len,"Going to read the number of bits per pixel"); 187 psiconv_progress(config,lev+2,off+len,"Going to read the number of bits per pixel");
181 bits_per_pixel=psiconv_read_u32(buf,lev+2,off+len,&res); 188 bits_per_pixel=psiconv_read_u32(config,buf,lev+2,off+len,&res);
182 if (res) 189 if (res)
183 goto ERROR2; 190 goto ERROR2;
184 if (bits_per_pixel > 8) { 191 if (bits_per_pixel > 8) {
185 psiconv_warn(lev+2,off+len,"Picture has too many colors"); 192 psiconv_warn(config,lev+2,off+len,"Picture has too many colors");
186 psiconv_debug(lev+2,off+len,"Read %d colorbits",bits_per_pixel); 193 psiconv_debug(config,lev+2,off+len,"Read %d colorbits",bits_per_pixel);
187 res = -PSICONV_E_PARSE; 194 res = -PSICONV_E_PARSE;
188 goto ERROR2; 195 goto ERROR2;
189 } 196 }
190 psiconv_debug(lev+2,off+len,"Bits per pixel: %d",bits_per_pixel); 197 psiconv_debug(config,lev+2,off+len,"Bits per pixel: %d",bits_per_pixel);
191 len += 4; 198 len += 4;
192 199
193 for (i = 0 ; i < 2; i++) { 200 for (i = 0 ; i < 2; i++) {
194 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 201 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
195 if (res) 202 if (res)
196 goto ERROR2; 203 goto ERROR2;
197 if (temp != 00) { 204 if (temp != 00) {
198 psiconv_warn(lev+2,off+len, 205 psiconv_warn(config,lev+2,off+len,
199 "Paint data section prologue has unknown values (ignored)"); 206 "Paint data section prologue has unknown values (ignored)");
200 psiconv_debug(lev+2,off+len, 207 psiconv_debug(config,lev+2,off+len,
201 "offset %02x: read %08x, expected %08x",i,temp, 0x00); 208 "offset %02x: read %08x, expected %08x",i,temp, 0x00);
202 } 209 }
203 len += 4; 210 len += 4;
204 } 211 }
205 212
206 psiconv_progress(lev+2,off+len, 213 psiconv_progress(config,lev+2,off+len,
207 "Going to read whether RLE compression is used"); 214 "Going to read whether RLE compression is used");
208 compression=psiconv_read_u32(buf,lev+2,off+len,&res); 215 compression=psiconv_read_u32(config,buf,lev+2,off+len,&res);
209 if (res) 216 if (res)
210 goto ERROR2; 217 goto ERROR2;
211 if (compression > 1) { 218 if (compression > 1) {
212 psiconv_warn(lev+2,off+len,"Paint data section has unknown " 219 psiconv_warn(config,lev+2,off+len,"Paint data section has unknown "
213 "compression type, assuming RLE"); 220 "compression type, assuming RLE");
214 psiconv_debug(lev+2,off+len,"Read compression type %d",compression); 221 psiconv_debug(config,lev+2,off+len,"Read compression type %d",compression);
215 compression = 1; 222 compression = 1;
216 } 223 }
217 psiconv_debug(lev+2,off+len,"Compression: %s",compression?"RLE":"none"); 224 psiconv_debug(config,lev+2,off+len,"Compression: %s",compression?"RLE":"none");
218 len += 4; 225 len += 4;
219 226
220 if (isclipart) { 227 if (isclipart) {
221 psiconv_progress(lev+2,off+len,"Going to read an unknown long"); 228 psiconv_progress(config,lev+2,off+len,"Going to read an unknown long");
222 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 229 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
223 if (res) 230 if (res)
224 goto ERROR2; 231 goto ERROR2;
225 if (temp != 0xffffffff) { 232 if (temp != 0xffffffff) {
226 psiconv_warn(lev+2,off+len, 233 psiconv_warn(config,lev+2,off+len,
227 "Paint data section prologue has unknown values (ignoring)"); 234 "Paint data section prologue has unknown values (ignoring)");
228 psiconv_debug(lev+2,off+len, 235 psiconv_debug(config,lev+2,off+len,
229 "offset %02x: read %08x, expected %08x",i,temp, 0xffffffff); 236 "offset %02x: read %08x, expected %08x",i,temp, 0xffffffff);
230 } 237 }
231 len += 4; 238 len += 4;
232 psiconv_progress(lev+2,off+len,"Going to read a second unknown long"); 239 psiconv_progress(config,lev+2,off+len,"Going to read a second unknown long");
233 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 240 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
234 if (res) 241 if (res)
235 goto ERROR2; 242 goto ERROR2;
236 if (temp != 0x44) { 243 if (temp != 0x44) {
237 psiconv_warn(lev+2,off+len, 244 psiconv_warn(config,lev+2,off+len,
238 "Paint data section prologue has unknown values (ignoring)"); 245 "Paint data section prologue has unknown values (ignoring)");
239 psiconv_debug(lev+2,off+len, 246 psiconv_debug(config,lev+2,off+len,
240 "offset %02x: read %08x, expected %08x",i,temp, 0x44); 247 "offset %02x: read %08x, expected %08x",i,temp, 0x44);
241 } 248 }
242 len += 4; 249 len += 4;
243 } 250 }
244 251
251 len = offset; 258 len = offset;
252 datasize = size - len; 259 datasize = size - len;
253 if (isclipart) 260 if (isclipart)
254 len += 8; 261 len += 8;
255 262
256 psiconv_progress(lev+2,off+len,"Going to read the pixel data"); 263 psiconv_progress(config,lev+2,off+len,"Going to read the pixel data");
257 pixelnr = 0; 264 pixelnr = 0;
258 datanr = 0; 265 datanr = 0;
259 if (!compression) { 266 if (!compression) {
260 linelen = datasize / (*result)->ysize; 267 linelen = datasize / (*result)->ysize;
261 psiconv_debug(lev+3,off+len,"Line length: %04x bytes",linelen); 268 psiconv_debug(config,lev+3,off+len,"Line length: %04x bytes",linelen);
262 while((datanr < datasize)) { 269 while((datanr < datasize)) {
263 temp = psiconv_read_u8(buf,lev+2,off+len+datanr,&res); 270 temp = psiconv_read_u8(config,buf,lev+2,off+len+datanr,&res);
264 if (res) 271 if (res)
265 goto ERROR5; 272 goto ERROR5;
266 if (decode_byte(lev+3,off+len+datanr,*result,&pixelnr,temp,bits_per_pixel, 273 if (decode_byte(config,lev+3,off+len+datanr,*result,&pixelnr,temp,bits_per_pixel,
267 linelen,&linepos,picsize)) { 274 linelen,&linepos,picsize)) {
268 res = -PSICONV_E_PARSE; 275 res = -PSICONV_E_PARSE;
269 break; 276 break;
270 } 277 }
271 datanr++; 278 datanr++;
272 } 279 }
273 } else { 280 } else {
274 psiconv_progress(lev+2,off+len,"First pass: determining line length"); 281 psiconv_progress(config,lev+2,off+len,"First pass: determining line length");
275 datanr = 0; 282 datanr = 0;
276 i = 0; 283 i = 0;
277 while (datanr < datasize) { 284 while (datanr < datasize) {
278 marker = psiconv_read_u8(buf,lev+3,off+len+datanr,&res); 285 marker = psiconv_read_u8(config,buf,lev+3,off+len+datanr,&res);
279 if (res) 286 if (res)
280 goto ERROR5; 287 goto ERROR5;
281 if (marker >= 0x80) { 288 if (marker >= 0x80) {
282 datanr += 0x100 - marker + 1; 289 datanr += 0x100 - marker + 1;
283 i += 0x100 - marker; 290 i += 0x100 - marker;
286 i += marker + 1; 293 i += marker + 1;
287 } 294 }
288 } 295 }
289 linelen = i / (*result)->ysize; 296 linelen = i / (*result)->ysize;
290 datanr=0; 297 datanr=0;
291 psiconv_debug(lev+2,off+len,"Linelen: %04x bytes",linelen); 298 psiconv_debug(config,lev+2,off+len,"Linelen: %04x bytes",linelen);
292 while((datanr < datasize)) { 299 while((datanr < datasize)) {
293 marker = psiconv_read_u8(buf,lev+3,off+len+datanr,&res); 300 marker = psiconv_read_u8(config,buf,lev+3,off+len+datanr,&res);
294 if (res) 301 if (res)
295 goto ERROR5; 302 goto ERROR5;
296 psiconv_debug(lev+3,off+len+datanr, 303 psiconv_debug(config,lev+3,off+len+datanr,
297 "Pixelnr %08x, Datanr %08x: Read marker %02x", 304 "Pixelnr %08x, Datanr %08x: Read marker %02x",
298 pixelnr,datanr,marker); 305 pixelnr,datanr,marker);
299 datanr ++; 306 datanr ++;
300 if (marker >= 0x80) { 307 if (marker >= 0x80) {
301 /* 0x100 - marker bytes of data follow */ 308 /* 0x100 - marker bytes of data follow */
302 for (i = 0; i < 0x100-marker; i++,datanr++) { 309 for (i = 0; i < 0x100-marker; i++,datanr++) {
303 if (datanr >= datasize) { 310 if (datanr >= datasize) {
304 psiconv_warn(lev+3,off+len+datanr,"Corrupted picture data"); 311 psiconv_warn(config,lev+3,off+len+datanr,"Corrupted picture data");
305 psiconv_debug(lev+3,off+len+datanr, 312 psiconv_debug(config,lev+3,off+len+datanr,
306 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x," 313 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x,"
307 "Datanr: %08x, marker: %02x",picsize,datasize,pixelnr, 314 "Datanr: %08x, marker: %02x",picsize,datasize,pixelnr,
308 datanr,marker); 315 datanr,marker);
309 res = -PSICONV_E_PARSE; 316 res = -PSICONV_E_PARSE;
310 break; 317 break;
311 } 318 }
312 temp = psiconv_read_u8(buf,lev+2,off+len+datanr,&res); 319 temp = psiconv_read_u8(config,buf,lev+2,off+len+datanr,&res);
313 if (res) 320 if (res)
314 goto ERROR5; 321 goto ERROR5;
315 if (decode_byte(lev+2,off+len+datanr,*result,&pixelnr,temp, 322 if (decode_byte(config,lev+2,off+len+datanr,*result,&pixelnr,temp,
316 bits_per_pixel,linelen,&linepos,picsize)) { 323 bits_per_pixel,linelen,&linepos,picsize)) {
317 res = -PSICONV_E_PARSE; 324 res = -PSICONV_E_PARSE;
318 break; 325 break;
319 } 326 }
320 } 327 }
321 } else { 328 } else {
322 if (datanr >= datasize) { 329 if (datanr >= datasize) {
323 psiconv_warn(lev+3,off+len+datanr,"Corrupted picture data"); 330 psiconv_warn(config,lev+3,off+len+datanr,"Corrupted picture data");
324 psiconv_debug(lev+3,off+len+datanr, 331 psiconv_debug(config,lev+3,off+len+datanr,
325 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x," 332 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x,"
326 "Datanr: %08x, marker: %02x",picsize,datasize,pixelnr, 333 "Datanr: %08x, marker: %02x",picsize,datasize,pixelnr,
327 datanr,marker); 334 datanr,marker);
328 res = -PSICONV_E_PARSE; 335 res = -PSICONV_E_PARSE;
329 } else { 336 } else {
330 temp = psiconv_read_u8(buf,lev+3,off+len+datanr,&res); 337 temp = psiconv_read_u8(config,buf,lev+3,off+len+datanr,&res);
331 if (res) 338 if (res)
332 goto ERROR5; 339 goto ERROR5;
333 for (i = 0; i <= marker; i++) { 340 for (i = 0; i <= marker; i++) {
334 if (decode_byte(lev+2,off+len+datanr,*result,&pixelnr,temp, 341 if (decode_byte(config,lev+2,off+len+datanr,*result,&pixelnr,temp,
335 bits_per_pixel,linelen,&linepos,picsize)) { 342 bits_per_pixel,linelen,&linepos,picsize)) {
336 res = -PSICONV_E_PARSE; 343 res = -PSICONV_E_PARSE;
337 break; 344 break;
338 } 345 }
339 } 346 }
346 if (linepos >= ((*result)->xsize + (8/bits_per_pixel) - 1) / 353 if (linepos >= ((*result)->xsize + (8/bits_per_pixel) - 1) /
347 (8/bits_per_pixel)) 354 (8/bits_per_pixel))
348 datanr += (linelen - linepos); 355 datanr += (linelen - linepos);
349 356
350 if (res || (datanr != datasize) || (pixelnr != picsize)) { 357 if (res || (datanr != datasize) || (pixelnr != picsize)) {
351 psiconv_warn(lev+2,off+len,"Corrupted picture data!"); 358 psiconv_warn(config,lev+2,off+len,"Corrupted picture data!");
352 psiconv_debug(lev+3,off+len+datanr, 359 psiconv_debug(config,lev+3,off+len+datanr,
353 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x," 360 "Picsize: %08x, Datasize: %08x, Pixelnr: %08x,"
354 "Datanr: %08x",picsize,datasize,pixelnr,datanr); 361 "Datanr: %08x",picsize,datasize,pixelnr,datanr);
355 goto ERROR5; 362 goto ERROR5;
356 } 363 }
357 364
358 len += datanr; 365 len += datanr;
359 366
360 if (length) 367 if (length)
361 *length = len; 368 *length = len;
362 369
363 psiconv_progress(lev+1,off+len-1,"End of paint data section " 370 psiconv_progress(config,lev+1,off+len-1,"End of paint data section "
364 "(total length: %08x)", len); 371 "(total length: %08x)", len);
365 372
366 return res; 373 return res;
367 374
368ERROR5: 375ERROR5:
372ERROR3: 379ERROR3:
373 free((*result)->red); 380 free((*result)->red);
374ERROR2: 381ERROR2:
375 free (*result); 382 free (*result);
376ERROR1: 383ERROR1:
377 psiconv_warn(lev+1,off,"Reading of Paint Data Section failed"); 384 psiconv_warn(config,lev+1,off,"Reading of Paint Data Section failed");
378 if (length) 385 if (length)
379 *length = 0; 386 *length = 0;
380 if (!res) 387 if (!res)
381 return -PSICONV_E_NOMEM; 388 return -PSICONV_E_NOMEM;
382 else 389 else
383 return res; 390 return res;
384} 391}
385 392
386int psiconv_parse_sketch_section(const psiconv_buffer buf, int lev, 393int psiconv_parse_sketch_section(const psiconv_config config,
394 const psiconv_buffer buf, int lev,
387 psiconv_u32 off, int *length, int is_object, 395 psiconv_u32 off, int *length,
388 psiconv_sketch_section *result) 396 psiconv_sketch_section *result)
389{ 397{
390 int res=0; 398 int res=0;
391 int len=0; 399 int len=0;
392 psiconv_u32 temp; 400 psiconv_u32 temp;
393 int leng; 401 int leng;
394 int i;
395 402
396 psiconv_progress(lev+1,off,"Going to read the sketch section"); 403 psiconv_progress(config,lev+1,off,"Going to read the sketch section");
397 if (!(*result = malloc(sizeof(**result)))) 404 if (!(*result = malloc(sizeof(**result))))
398 goto ERROR1; 405 goto ERROR1;
399 406
400 if (!is_object) {
401 psiconv_progress(lev+2,off+len,"Going to read the form hor. size"); 407 psiconv_progress(config,lev+2,off+len,"Going to read the displayed hor. size");
402 (*result)->form_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); 408 (*result)->displayed_xsize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
403 if (res) 409 if (res)
404 goto ERROR2; 410 goto ERROR2;
411 psiconv_debug(config,lev+2,off+len,"Displayed hor. size: %04x",
412 (*result)->displayed_xsize);
413 len += 0x02;
414 psiconv_progress(config,lev+2,off+len,"Going to read displayed ver. size");
415 (*result)->displayed_ysize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
416 if (res)
417 goto ERROR2;
418 psiconv_debug(config,lev+2,off+len,"Displayed ver. size: %04x",
419 (*result)->displayed_ysize);
420 len += 0x02;
421
422 psiconv_progress(config,lev+2,off+len,"Going to read the data hor. offset");
423 (*result)->picture_data_x_offset = psiconv_read_u16(config,buf,lev+2,off + len,
424 &res);
425 if (res)
426 goto ERROR2;
427 psiconv_debug(config,lev+2,off+len,"Data hor. offset: %04x",
428 (*result)->picture_data_x_offset);
429 len += 0x02;
430 psiconv_progress(config,lev+2,off+len,"Going to read the data ver. offset");
431 (*result)->picture_data_y_offset = psiconv_read_u16(config,buf,lev+2,off + len,
432 &res);
433 if (res)
434 goto ERROR2;
435 psiconv_debug(config,lev+2,off+len,"Data ver. offset: %04x",
436 (*result)->picture_data_y_offset);
437 len += 0x02;
438
439 psiconv_progress(config,lev+2,off+len,"Going to read the displayed hor. offset");
440 (*result)->displayed_size_x_offset = psiconv_read_u16(config,buf,lev+2,off + len,
441 &res);
442 if (res)
443 goto ERROR2;
444 psiconv_debug(config,lev+2,off+len,"Displayed hor. offset: %04x",
445 (*result)->displayed_size_x_offset);
446 len += 0x02;
447 psiconv_progress(config,lev+2,off+len,"Going to read the displayed ver. offset");
448 (*result)->displayed_size_y_offset = psiconv_read_u16(config,buf,lev+2,off + len,
449 &res);
450 if (res)
451 goto ERROR2;
452 psiconv_debug(config,lev+2,off+len,"Displayed ver. offset: %04x",
453 (*result)->displayed_size_y_offset);
454 len += 0x02;
455
456 psiconv_progress(config,lev+2,off+len,"Going to read the form hor. size");
457 (*result)->form_xsize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
458 if (res)
459 goto ERROR2;
405 psiconv_debug(lev+2,off+len,"Form hor. size: %04x", 460 psiconv_debug(config,lev+2,off+len,"Form hor. size: %04x",
406 (*result)->form_xsize); 461 (*result)->form_xsize);
407 len += 0x02; 462 len += 0x02;
408 psiconv_progress(lev+2,off+len,"Going to read the form ver. size"); 463 psiconv_progress(config,lev+2,off+len,"Going to read form ver. size");
409 (*result)->form_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); 464 (*result)->form_ysize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
410 if (res) 465 if (res)
411 goto ERROR2; 466 goto ERROR2;
412 psiconv_debug(lev+2,off+len,"Form ver. size: %04x", 467 psiconv_debug(config,lev+2,off+len,"Form ver. size: %04x",
413 (*result)->form_ysize); 468 (*result)->form_ysize);
414 len += 0x02; 469 len += 0x02;
415 psiconv_progress(lev+2,off+len,"Going to read the picture hor. offset"); 470
416 (*result)->picture_x_offset = psiconv_read_u16(buf,lev+2,off + len,&res); 471 psiconv_progress(config,lev+2,off+len,"Going to skip 1 word of zeros");
472 temp = psiconv_read_u16(config,buf,lev+2,off+len,&res);
417 if (res) 473 if (res)
418 goto ERROR2; 474 goto ERROR2;
419 psiconv_debug(lev+2,off+len,"Picture hor. offset: %04x",
420 (*result)->picture_x_offset);
421 len += 0x02;
422 psiconv_progress(lev+2,off+len,"Going to read the picture ver. offset");
423 (*result)->picture_y_offset = psiconv_read_u16(buf,lev+2,off + len,&res);
424 if (res)
425 goto ERROR2;
426 psiconv_debug(lev+2,off+len,"Picture ver. offset: %04x",
427 (*result)->picture_y_offset);
428 len += 0x02;
429 psiconv_progress(lev+2,off+len,"Going to skip 5 words of zeros");
430 for (i = 0; i < 5; i++) {
431 temp = psiconv_read_u16(buf,lev+2,off+len,&res);
432 if (res)
433 goto ERROR2;
434 if (temp != 0) {
435 psiconv_warn(lev+2,off+len,
436 "Unexpected value in sketch section preamble (ignored)");
437 psiconv_debug(lev+2,off+len,"Word %d: Read %04x, expected %04x",i,
438 temp,0);
439 }
440 off += 0x02;
441 }
442 } else {
443 psiconv_progress(lev+2,off+len,"Going to read the displayed hor. size");
444 (*result)->picture_xsize = psiconv_read_u16(buf,lev+2,off + len,&res);
445 if (res)
446 goto ERROR2;
447 psiconv_debug(lev+2,off+len,"Displayed hor. size: %04x",
448 (*result)->picture_xsize);
449 len += 0x02;
450 psiconv_progress(lev+2,off+len,"Going to read the displayed ver. size");
451 (*result)->picture_ysize = psiconv_read_u16(buf,lev+2,off + len,&res);
452 if (res)
453 goto ERROR2;
454 psiconv_debug(lev+2,off+len,"Displayed ver. size: %04x",
455 (*result)->picture_ysize);
456 len += 0x02;
457
458 psiconv_progress(lev+2,off+len,"Going to skip 2 words of zeros");
459 for (i = 0; i < 2; i++) {
460 temp = psiconv_read_u16(buf,lev+2,off+len,&res);
461 if (res)
462 goto ERROR2;
463 if (temp != 0) {
464 psiconv_warn(lev+2,off+len,
465 "Unexpected value in sketch section preamble (ignored)");
466 psiconv_debug(lev+2,off+len,"Word %d: Read %04x, expected %04x",i,
467 temp,0);
468 }
469 off += 0x02;
470 }
471 psiconv_progress(lev+2,off+len,"Going to read the picture hor. offset");
472 (*result)->picture_x_offset = psiconv_read_u16(buf,lev+2,off + len,&res);
473 if (res)
474 goto ERROR2;
475 psiconv_debug(lev+2,off+len,"Picture hor. offset: %04x",
476 (*result)->picture_x_offset);
477 len += 0x02;
478 psiconv_progress(lev+2,off+len,"Going to read the picture ver. offset");
479 (*result)->picture_y_offset = psiconv_read_u16(buf,lev+2,off + len,&res);
480 if (res)
481 goto ERROR2;
482 psiconv_debug(lev+2,off+len,"Picture ver. offset: %04x",
483 (*result)->picture_y_offset);
484 len += 0x02;
485 psiconv_progress(lev+2,off+len,"Going to read the form hor. size");
486 (*result)->form_xsize = psiconv_read_u16(buf,lev+2,off + len,&res);
487 if (res)
488 goto ERROR2;
489 psiconv_debug(lev+2,off+len,"Form hor. size: %04x",
490 (*result)->form_xsize);
491 len += 0x02;
492 psiconv_progress(lev+2,off+len,"Going to read the form ver. size");
493 (*result)->form_ysize = psiconv_read_u16(buf,lev+2,off + len,&res);
494 if (res)
495 goto ERROR2;
496 psiconv_debug(lev+2,off+len,"Form ver. size: %04x",
497 (*result)->form_ysize);
498 len += 0x02;
499 psiconv_progress(lev+2,off+len,"Going to skip 1 zero word");
500 temp = psiconv_read_u16(buf,lev+2,off+len,&res);
501 if (res)
502 goto ERROR2;
503 if (temp != 0) { 475 if (temp != 0) {
504 psiconv_warn(lev+2,off+len, 476 psiconv_warn(config,lev+2,off+len,
505 "Unexpected value in sketch section preamble (ignored)"); 477 "Unexpected value in sketch section preamble (ignored)");
506 psiconv_debug(lev+2,off+len,"Read %04x, expected %04x",i, temp,0); 478 psiconv_debug(config,lev+2,off+len,"Read %04x, expected %04x",
479 temp,0);
507 } 480 }
508 off += 0x02; 481 off += 0x02;
509 }
510 482
511 psiconv_progress(lev+2,off+len,"Going to read the picture data"); 483 psiconv_progress(config,lev+2,off+len,"Going to read the picture data");
512 if ((res = psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,0, 484 if ((res = psiconv_parse_paint_data_section(config,buf,lev+2,off+len,&leng,0,
513 &((*result)->picture)))) 485 &((*result)->picture))))
514 goto ERROR2; 486 goto ERROR2;
515 off += leng; 487 off += leng;
516 if (!is_object) {
517 (*result)->picture_xsize = (*result)->picture->xsize;
518 (*result)->picture_ysize = (*result)->picture->ysize;
519 }
520 488
521 psiconv_progress(lev+2,off+len,"Going to read the hor. magnification"); 489 psiconv_progress(config,lev+2,off+len,"Going to read the hor. magnification");
522 (*result)->magnification_x = psiconv_read_u16(buf,lev+2,off+len,&res)/1000.0; 490 (*result)->magnification_x = psiconv_read_u16(config,buf,lev+2,off+len,&res)/1000.0;
523 if (res) 491 if (res)
524 goto ERROR3; 492 goto ERROR3;
525 psiconv_debug(lev+2,off+len,"Form hor. magnification: %f", 493 psiconv_debug(config,lev+2,off+len,"Form hor. magnification: %f",
526 (*result)->magnification_x); 494 (*result)->magnification_x);
527 len += 0x02; 495 len += 0x02;
528 psiconv_progress(lev+2,off+len,"Going to read the ver. magnification"); 496 psiconv_progress(config,lev+2,off+len,"Going to read the ver. magnification");
529 (*result)->magnification_y = psiconv_read_u16(buf,lev+2,off+len,&res)/1000.0; 497 (*result)->magnification_y = psiconv_read_u16(config,buf,lev+2,off+len,&res)/1000.0;
530 if (res) 498 if (res)
531 goto ERROR3; 499 goto ERROR3;
532 psiconv_debug(lev+2,off+len,"Form ver. magnification: %f", 500 psiconv_debug(config,lev+2,off+len,"Form ver. magnification: %f",
533 (*result)->magnification_y); 501 (*result)->magnification_y);
534 len += 0x02; 502 len += 0x02;
535 503
536 psiconv_progress(lev+2,off+len,"Going to read the left cut"); 504 psiconv_progress(config,lev+2,off+len,"Going to read the left cut");
537 temp = psiconv_read_u32(buf,lev+2,off + len,&res); 505 temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
538 if (res) 506 if (res)
539 goto ERROR3; 507 goto ERROR3;
540 (*result)->cut_left = (temp * 6.0) / (*result)->picture_xsize; 508 (*result)->cut_left = (temp * 6.0) / (*result)->displayed_xsize;
541 psiconv_debug(lev+2,off+len,"Left cut: raw %08x, real: %f", 509 psiconv_debug(config,lev+2,off+len,"Left cut: raw %08x, real: %f",
542 temp,(*result)->cut_left); 510 temp,(*result)->cut_left);
543 len += 0x04; 511 len += 0x04;
544 psiconv_progress(lev+2,off+len,"Going to read the right cut"); 512 psiconv_progress(config,lev+2,off+len,"Going to read the right cut");
545 temp = psiconv_read_u32(buf,lev+2,off + len,&res); 513 temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
546 if (res) 514 if (res)
547 goto ERROR3; 515 goto ERROR3;
548 (*result)->cut_right = (temp * 6.0) / (*result)->picture_xsize; 516 (*result)->cut_right = (temp * 6.0) / (*result)->displayed_xsize;
549 psiconv_debug(lev+2,off+len,"Right cut: raw %08x, real: %f", 517 psiconv_debug(config,lev+2,off+len,"Right cut: raw %08x, real: %f",
550 temp,(*result)->cut_right); 518 temp,(*result)->cut_right);
551 len += 0x04; 519 len += 0x04;
552 psiconv_progress(lev+2,off+len,"Going to read the top cut"); 520 psiconv_progress(config,lev+2,off+len,"Going to read the top cut");
553 temp = psiconv_read_u32(buf,lev+2,off + len,&res); 521 temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
554 if (res) 522 if (res)
555 goto ERROR3; 523 goto ERROR3;
556 (*result)->cut_top = (temp * 6.0) / (*result)->picture_ysize; 524 (*result)->cut_top = (temp * 6.0) / (*result)->displayed_ysize;
557 psiconv_debug(lev+2,off+len,"Top cut: raw %08x, real: %f", 525 psiconv_debug(config,lev+2,off+len,"Top cut: raw %08x, real: %f",
558 temp,(*result)->cut_top); 526 temp,(*result)->cut_top);
559 len += 0x04; 527 len += 0x04;
560 psiconv_progress(lev+2,off+len,"Going to read the bottom cut"); 528 psiconv_progress(config,lev+2,off+len,"Going to read the bottom cut");
561 temp = psiconv_read_u32(buf,lev+2,off + len,&res); 529 temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
562 if (res) 530 if (res)
563 goto ERROR3; 531 goto ERROR3;
564 (*result)->cut_bottom = (temp * 6.0) / (*result)->picture_ysize; 532 (*result)->cut_bottom = (temp * 6.0) / (*result)->displayed_ysize;
565 psiconv_debug(lev+2,off+len,"Bottom cut: raw %08x, real: %f", 533 psiconv_debug(config,lev+2,off+len,"Bottom cut: raw %08x, real: %f",
566 temp,(*result)->cut_bottom); 534 temp,(*result)->cut_bottom);
567 len += 0x04; 535 len += 0x04;
568 536
569 if (length) 537 if (length)
570 *length = len; 538 *length = len;
571 539
572 psiconv_progress(lev,off+len-1, 540 psiconv_progress(config,lev,off+len-1,
573 "End of sketch section (total length: %08x)", len); 541 "End of sketch section (total length: %08x)", len);
574 542
575 return res; 543 return res;
576ERROR3: 544ERROR3:
577 psiconv_free_paint_data_section((*result)->picture); 545 psiconv_free_paint_data_section((*result)->picture);
578ERROR2: 546ERROR2:
579 free (*result); 547 free (*result);
580ERROR1: 548ERROR1:
581 psiconv_warn(lev+1,off,"Reading of Sketch Section failed"); 549 psiconv_warn(config,lev+1,off,"Reading of Sketch Section failed");
582 if (length) 550 if (length)
583 *length = 0; 551 *length = 0;
584 if (!res) 552 if (!res)
585 return -PSICONV_E_NOMEM; 553 return -PSICONV_E_NOMEM;
586 else 554 else
587 return res; 555 return res;
588} 556}
589 557
590 558
591int psiconv_parse_clipart_section(const psiconv_buffer buf,int lev, 559int psiconv_parse_clipart_section(const psiconv_config config,
560 const psiconv_buffer buf,int lev,
592 psiconv_u32 off, int *length, 561 psiconv_u32 off, int *length,
593 psiconv_clipart_section *result) 562 psiconv_clipart_section *result)
594{ 563{
595 int res=0; 564 int res=0;
596 int len=0; 565 int len=0;
597 int leng; 566 int leng;
598 psiconv_u32 temp; 567 psiconv_u32 temp;
599 568
600 psiconv_progress(lev+1,off+len,"Going to read the clipart section"); 569 psiconv_progress(config,lev+1,off+len,"Going to read the clipart section");
601 if (!(*result = malloc(sizeof(**result)))) 570 if (!(*result = malloc(sizeof(**result))))
602 goto ERROR1; 571 goto ERROR1;
603 572
604 psiconv_progress(lev+2,off+len,"Going to read the section ID"); 573 psiconv_progress(config,lev+2,off+len,"Going to read the section ID");
605 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 574 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
606 if (res) 575 if (res)
607 goto ERROR2; 576 goto ERROR2;
608 if (temp != PSICONV_ID_CLIPART_ITEM) { 577 if (temp != PSICONV_ID_CLIPART_ITEM) {
609 psiconv_warn(lev+2,off+len, 578 psiconv_warn(config,lev+2,off+len,
610 "Unexpected value in clipart section preamble (ignored)"); 579 "Unexpected value in clipart section preamble (ignored)");
611 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 580 psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp,
612 PSICONV_ID_CLIPART_ITEM); 581 PSICONV_ID_CLIPART_ITEM);
613 } else 582 } else
614 psiconv_debug(lev+2,off+len,"Clipart ID: %08x", temp); 583 psiconv_debug(config,lev+2,off+len,"Clipart ID: %08x", temp);
615 off += 4; 584 off += 4;
616 585
617 psiconv_progress(lev+2,off+len,"Going to read an unknown long"); 586 psiconv_progress(config,lev+2,off+len,"Going to read an unknown long");
618 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 587 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
619 if (res) 588 if (res)
620 goto ERROR2; 589 goto ERROR2;
621 if (temp != 0x02) { 590 if (temp != 0x02) {
622 psiconv_warn(lev+2,off+len, 591 psiconv_warn(config,lev+2,off+len,
623 "Unexpected value in clipart section preamble (ignored)"); 592 "Unexpected value in clipart section preamble (ignored)");
624 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 593 psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp,
625 0x02); 594 0x02);
626 } else 595 } else
627 psiconv_debug(lev+2,off+len,"First unknown long: %08x", temp); 596 psiconv_debug(config,lev+2,off+len,"First unknown long: %08x", temp);
628 off += 4; 597 off += 4;
629 598
630 psiconv_progress(lev+2,off+len,"Going to read a second unknown long"); 599 psiconv_progress(config,lev+2,off+len,"Going to read a second unknown long");
631 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 600 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
632 if (res) 601 if (res)
633 goto ERROR2; 602 goto ERROR2;
634 if (temp != 0) { 603 if (temp != 0) {
635 psiconv_warn(lev+2,off+len, 604 psiconv_warn(config,lev+2,off+len,
636 "Unexpected value in clipart section preamble (ignored)"); 605 "Unexpected value in clipart section preamble (ignored)");
637 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); 606 psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp, 0);
638 } else 607 } else
639 psiconv_debug(lev+2,off+len,"Second unknown long: %08x", temp); 608 psiconv_debug(config,lev+2,off+len,"Second unknown long: %08x", temp);
640 off += 4; 609 off += 4;
641 610
642 psiconv_progress(lev+2,off+len,"Going to read a third unknown long"); 611 psiconv_progress(config,lev+2,off+len,"Going to read a third unknown long");
643 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 612 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
644 if (res) 613 if (res)
645 goto ERROR2; 614 goto ERROR2;
646 if (temp != 0) { 615 if (temp != 0) {
647 psiconv_warn(lev+2,off+len, 616 psiconv_warn(config,lev+2,off+len,
648 "Unexpected value in clipart section preamble (ignored)"); 617 "Unexpected value in clipart section preamble (ignored)");
649 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); 618 psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp, 0);
650 } else 619 } else
651 psiconv_debug(lev+2,off+len,"Third unknown long: %08x", temp); 620 psiconv_debug(config,lev+2,off+len,"Third unknown long: %08x", temp);
652 off += 4; 621 off += 4;
653 622
654 psiconv_progress(lev+2,off+len,"Going to read a fourth unknown long"); 623 psiconv_progress(config,lev+2,off+len,"Going to read a fourth unknown long");
655 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 624 temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
656 if (res) 625 if (res)
657 goto ERROR2; 626 goto ERROR2;
658 if ((temp != 0x0c) && (temp != 0x08)) { 627 if ((temp != 0x0c) && (temp != 0x08)) {
659 psiconv_warn(lev+2,off+len, 628 psiconv_warn(config,lev+2,off+len,
660 "Unexpected value in clipart section preamble (ignored)"); 629 "Unexpected value in clipart section preamble (ignored)");
661 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x or %08x",temp, 630 psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x or %08x",temp,
662 0x0c, 0x08); 631 0x0c, 0x08);
663 } else 632 } else
664 psiconv_debug(lev+2,off+len,"Fourth unknown long: %08x", temp); 633 psiconv_debug(config,lev+2,off+len,"Fourth unknown long: %08x", temp);
665 off += 4; 634 off += 4;
666 635
667 psiconv_progress(lev+2,off+len,"Going to read the Paint Data Section"); 636 psiconv_progress(config,lev+2,off+len,"Going to read the Paint Data Section");
668 if ((res = psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,1, 637 if ((res = psiconv_parse_paint_data_section(config,buf,lev+2,off+len,&leng,1,
669 &((*result)->picture)))) 638 &((*result)->picture))))
670 goto ERROR2; 639 goto ERROR2;
671 len += leng; 640 len += leng;
672 641
673 if (length) 642 if (length)
674 *length = len; 643 *length = len;
675 644
676 psiconv_progress(lev,off+len-1, 645 psiconv_progress(config,lev,off+len-1,
677 "End of clipart section (total length: %08x)", len); 646 "End of clipart section (total length: %08x)", len);
678 return 0; 647 return 0;
679 648
680ERROR2: 649ERROR2:
681 free (*result); 650 free (*result);
682ERROR1: 651ERROR1:
683 psiconv_warn(lev+1,off,"Reading of Font failed"); 652 psiconv_warn(config,lev+1,off,"Reading of Font failed");
684 if (length) 653 if (length)
685 *length = 0; 654 *length = 0;
686 if (!res) 655 if (!res)
687 return -PSICONV_E_NOMEM; 656 return -PSICONV_E_NOMEM;
688 else 657 else

Legend:
Removed from v.97  
changed lines
  Added in v.168

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