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

Legend:
Removed from v.64  
changed lines
  Added in v.175

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