… | |
… | |
108 | psiconv_u32 section_table_id; |
108 | psiconv_u32 section_table_id; |
109 | psiconv_buffer buf_texted; |
109 | psiconv_buffer buf_texted; |
110 | |
110 | |
111 | psiconv_progress(config,lev,0,"Writing texted file"); |
111 | psiconv_progress(config,lev,0,"Writing texted file"); |
112 | if (!value) { |
112 | if (!value) { |
113 | psiconv_error(config,0,0,"Null TextEd file"); |
113 | psiconv_error(config,lev,0,"Null TextEd file"); |
114 | return -PSICONV_E_GENERATE; |
114 | res = -PSICONV_E_GENERATE; |
|
|
115 | goto ERROR1; |
115 | } |
116 | } |
116 | |
117 | |
117 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
118 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
118 | res = -PSICONV_E_NOMEM; |
119 | res = -PSICONV_E_NOMEM; |
119 | goto ERROR1; |
120 | goto ERROR1; |
… | |
… | |
184 | ERROR3: |
185 | ERROR3: |
185 | free(entry); |
186 | free(entry); |
186 | ERROR2: |
187 | ERROR2: |
187 | psiconv_list_free(section_table); |
188 | psiconv_list_free(section_table); |
188 | ERROR1: |
189 | ERROR1: |
|
|
190 | if (res) |
|
|
191 | psiconv_error(config,lev,0,"Writing of texted file failed"); |
|
|
192 | else |
|
|
193 | psiconv_progress(config,lev,0,"End of texted file"); |
189 | return res; |
194 | return res; |
190 | } |
195 | } |
191 | |
196 | |
192 | int psiconv_write_word_file(const psiconv_config config, |
197 | int psiconv_write_word_file(const psiconv_config config, |
193 | psiconv_buffer buf,int lev,psiconv_word_f value) |
198 | psiconv_buffer buf,int lev,psiconv_word_f value) |
… | |
… | |
197 | psiconv_section_table_entry entry; |
202 | psiconv_section_table_entry entry; |
198 | psiconv_u32 section_table_id; |
203 | psiconv_u32 section_table_id; |
199 | |
204 | |
200 | psiconv_progress(config,lev,0,"Writing word file"); |
205 | psiconv_progress(config,lev,0,"Writing word file"); |
201 | if (!value) { |
206 | if (!value) { |
202 | psiconv_error(config,0,0,"Null Word file"); |
207 | psiconv_error(config,lev,0,"Null Word file"); |
203 | return -PSICONV_E_GENERATE; |
208 | res = -PSICONV_E_GENERATE; |
|
|
209 | goto ERROR1; |
204 | } |
210 | } |
205 | |
211 | |
206 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
212 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
207 | res = -PSICONV_E_NOMEM; |
213 | res = -PSICONV_E_NOMEM; |
208 | goto ERROR1; |
214 | goto ERROR1; |
… | |
… | |
281 | ERROR3: |
287 | ERROR3: |
282 | free(entry); |
288 | free(entry); |
283 | ERROR2: |
289 | ERROR2: |
284 | psiconv_list_free(section_table); |
290 | psiconv_list_free(section_table); |
285 | ERROR1: |
291 | ERROR1: |
|
|
292 | if (res) |
|
|
293 | psiconv_error(config,lev,0,"Writing of word file failed"); |
|
|
294 | else |
|
|
295 | psiconv_progress(config,lev,0,"End of word file"); |
286 | return res; |
296 | return res; |
287 | } |
297 | } |
288 | |
298 | |
289 | int psiconv_write_sketch_file(const psiconv_config config, |
299 | int psiconv_write_sketch_file(const psiconv_config config, |
290 | psiconv_buffer buf,int lev,psiconv_sketch_f value) |
300 | psiconv_buffer buf,int lev,psiconv_sketch_f value) |
… | |
… | |
294 | psiconv_section_table_entry entry; |
304 | psiconv_section_table_entry entry; |
295 | psiconv_u32 section_table_id; |
305 | psiconv_u32 section_table_id; |
296 | |
306 | |
297 | psiconv_progress(config,lev,0,"Writing sketch file"); |
307 | psiconv_progress(config,lev,0,"Writing sketch file"); |
298 | if (!value) { |
308 | if (!value) { |
299 | psiconv_error(config,0,0,"Null Sketch file"); |
309 | psiconv_error(config,lev,0,"Null Sketch file"); |
300 | return -PSICONV_E_GENERATE; |
310 | res = -PSICONV_E_GENERATE; |
|
|
311 | goto ERROR1; |
301 | } |
312 | } |
302 | |
313 | |
303 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
314 | if (!(section_table = psiconv_list_new(sizeof(*entry)))) { |
304 | res = -PSICONV_E_NOMEM; |
315 | res = -PSICONV_E_NOMEM; |
305 | goto ERROR1; |
316 | goto ERROR1; |
… | |
… | |
340 | ERROR3: |
351 | ERROR3: |
341 | free(entry); |
352 | free(entry); |
342 | ERROR2: |
353 | ERROR2: |
343 | psiconv_list_free(section_table); |
354 | psiconv_list_free(section_table); |
344 | ERROR1: |
355 | ERROR1: |
|
|
356 | if (res) |
|
|
357 | psiconv_error(config,lev,0,"Writing of sketch file failed"); |
|
|
358 | else |
|
|
359 | psiconv_progress(config,lev,0,"End of sketch file"); |
345 | return res; |
360 | return res; |
346 | } |
361 | } |
347 | |
362 | |
348 | int psiconv_write_mbm_file(const psiconv_config config, |
363 | int psiconv_write_mbm_file(const psiconv_config config, |
349 | psiconv_buffer buf,int lev,psiconv_mbm_f value) |
364 | psiconv_buffer buf,int lev,psiconv_mbm_f value) |
… | |
… | |
353 | psiconv_u32 *entry,id,table_id; |
368 | psiconv_u32 *entry,id,table_id; |
354 | psiconv_paint_data_section section; |
369 | psiconv_paint_data_section section; |
355 | |
370 | |
356 | psiconv_progress(config,lev,0,"Writing mbm file"); |
371 | psiconv_progress(config,lev,0,"Writing mbm file"); |
357 | if (!value) { |
372 | if (!value) { |
358 | psiconv_error(config,0,0,"Null MBM file"); |
373 | psiconv_error(config,lev,0,"Null MBM file"); |
359 | return -PSICONV_E_GENERATE; |
374 | res = -PSICONV_E_GENERATE; |
|
|
375 | goto ERROR1; |
360 | } |
376 | } |
361 | |
377 | |
362 | if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { |
378 | if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { |
363 | res = -PSICONV_E_NOMEM; |
379 | res = -PSICONV_E_NOMEM; |
364 | goto ERROR1; |
380 | goto ERROR1; |
… | |
… | |
368 | if ((res = psiconv_buffer_add_reference(buf,table_id))) |
384 | if ((res = psiconv_buffer_add_reference(buf,table_id))) |
369 | goto ERROR2; |
385 | goto ERROR2; |
370 | |
386 | |
371 | for (i = 0; i < psiconv_list_length(value->sections); i++) { |
387 | for (i = 0; i < psiconv_list_length(value->sections); i++) { |
372 | if (!(section = psiconv_list_get(value->sections,i))) { |
388 | if (!(section = psiconv_list_get(value->sections,i))) { |
373 | psiconv_error(config,0,0,"Massive memory corruption"); |
389 | psiconv_error(config,lev,0,"Massive memory corruption"); |
374 | res = -PSICONV_E_NOMEM; |
390 | res = -PSICONV_E_NOMEM; |
375 | goto ERROR2; |
391 | goto ERROR2; |
376 | } |
392 | } |
377 | id = psiconv_buffer_unique_id(); |
393 | id = psiconv_buffer_unique_id(); |
378 | psiconv_list_add(jumptable,&id); |
394 | psiconv_list_add(jumptable,&id); |
… | |
… | |
389 | |
405 | |
390 | |
406 | |
391 | ERROR2: |
407 | ERROR2: |
392 | psiconv_list_free(jumptable); |
408 | psiconv_list_free(jumptable); |
393 | ERROR1: |
409 | ERROR1: |
|
|
410 | if (res) |
|
|
411 | psiconv_error(config,lev,0,"Writing of mbm file failed"); |
|
|
412 | else |
|
|
413 | psiconv_progress(config,lev,0,"End of mbm file"); |
394 | return res; |
414 | return res; |
395 | } |
415 | } |
396 | |
416 | |
397 | /* Note: this file is special, because it does not have a complete header! */ |
417 | /* Note: this file is special, because it does not have a complete header! */ |
398 | int psiconv_write_clipart_file(const psiconv_config config, |
418 | int psiconv_write_clipart_file(const psiconv_config config, |
… | |
… | |
404 | psiconv_clipart_section section; |
424 | psiconv_clipart_section section; |
405 | psiconv_buffer sec_buf; |
425 | psiconv_buffer sec_buf; |
406 | |
426 | |
407 | psiconv_progress(config,lev,0,"Writing clipart file"); |
427 | psiconv_progress(config,lev,0,"Writing clipart file"); |
408 | if (!value) { |
428 | if (!value) { |
409 | psiconv_error(config,0,0,"Null Clipart file"); |
429 | psiconv_error(config,lev,0,"Null Clipart file"); |
410 | return -PSICONV_E_GENERATE; |
430 | res = -PSICONV_E_GENERATE; |
|
|
431 | goto ERROR1; |
411 | } |
432 | } |
412 | |
433 | |
413 | if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { |
434 | if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { |
414 | res = -PSICONV_E_NOMEM; |
435 | res = -PSICONV_E_NOMEM; |
415 | goto ERROR1; |
436 | goto ERROR1; |
… | |
… | |
423 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART))) |
444 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART))) |
424 | goto ERROR3; |
445 | goto ERROR3; |
425 | |
446 | |
426 | for (i = 0; i < psiconv_list_length(value->sections); i++) { |
447 | for (i = 0; i < psiconv_list_length(value->sections); i++) { |
427 | if (!(section = psiconv_list_get(value->sections,i))) { |
448 | if (!(section = psiconv_list_get(value->sections,i))) { |
428 | psiconv_error(config,0,0,"Massive memory corruption"); |
449 | psiconv_error(config,lev,0,"Massive memory corruption"); |
429 | res = -PSICONV_E_NOMEM; |
450 | res = -PSICONV_E_NOMEM; |
430 | goto ERROR3; |
451 | goto ERROR3; |
431 | } |
452 | } |
432 | id = psiconv_buffer_unique_id(); |
453 | id = psiconv_buffer_unique_id(); |
433 | psiconv_list_add(jumptable,&id); |
454 | psiconv_list_add(jumptable,&id); |
… | |
… | |
447 | ERROR3: |
468 | ERROR3: |
448 | psiconv_buffer_free(sec_buf); |
469 | psiconv_buffer_free(sec_buf); |
449 | ERROR2: |
470 | ERROR2: |
450 | psiconv_list_free(jumptable); |
471 | psiconv_list_free(jumptable); |
451 | ERROR1: |
472 | ERROR1: |
|
|
473 | if (res) |
|
|
474 | psiconv_error(config,lev,0,"Writing of clipart file failed"); |
|
|
475 | else |
|
|
476 | psiconv_progress(config,lev,0,"End of clipart file"); |
452 | return res; |
477 | return res; |
453 | } |
478 | } |