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

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

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

Revision 168 Revision 171
55 PSICONV_ID_TEXTED))) 55 PSICONV_ID_TEXTED)))
56 goto ERROR; 56 goto ERROR;
57 if ((res =psiconv_write_texted_file(config,*buf, 57 if ((res =psiconv_write_texted_file(config,*buf,
58 (psiconv_texted_f) (value->file)))) 58 (psiconv_texted_f) (value->file))))
59 goto ERROR; 59 goto ERROR;
60#if 0
61 } else if (value->type == psiconv_sketch_file) { 60 } else if (value->type == psiconv_sketch_file) {
61 if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5,
62 PSICONV_ID_DATA_FILE,
63 PSICONV_ID_SKETCH)))
64 goto ERROR;
62 if ((res =psiconv_write_sketch_file(config,*buf, 65 if ((res =psiconv_write_sketch_file(config,*buf,
63 (psiconv_sketch_f) (value->file)))) 66 (psiconv_sketch_f) (value->file))))
64 goto ERROR; 67 goto ERROR;
65 } else if (value->type == psiconv_mbm_file) { 68 } else if (value->type == psiconv_mbm_file) {
69 if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5,
70 PSICONV_ID_MBM_FILE,
71 0x00000000)))
72 goto ERROR;
66 if ((res =psiconv_write_mbm_file(config,*buf, 73 if ((res =psiconv_write_mbm_file(config,*buf,
67 (psiconv_mbm_f) (value->file)))) 74 (psiconv_mbm_f) (value->file))))
68 goto ERROR; 75 goto ERROR;
76#if 0
69 } else if (value->type == psiconv_clipart_file) { 77 } else if (value->type == psiconv_clipart_file) {
70 if ((res =psiconv_write_clipart_file(config,*buf, 78 if ((res =psiconv_write_clipart_file(config,*buf,
71 (psiconv_clipart_f) (value->file)))) 79 (psiconv_clipart_f) (value->file))))
72 goto ERROR; 80 goto ERROR;
73#endif 81#endif
269ERROR2: 277ERROR2:
270 psiconv_list_free(section_table); 278 psiconv_list_free(section_table);
271ERROR1: 279ERROR1:
272 return res; 280 return res;
273} 281}
282
283int psiconv_write_sketch_file(const psiconv_config config,
284 psiconv_buffer buf,psiconv_sketch_f value)
285{
286 int res;
287 psiconv_section_table_section section_table;
288 psiconv_section_table_entry entry;
289 psiconv_u32 section_table_id;
290
291 if (!value) {
292 psiconv_warn(config,0,0,"Null Sketch file");
293 return -PSICONV_E_GENERATE;
294 }
295
296 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
297 res = -PSICONV_E_NOMEM;
298 goto ERROR1;
299 }
300
301 if (!(entry = malloc(sizeof(*entry)))) {
302 res = -PSICONV_E_NOMEM;
303 goto ERROR2;
304 }
305
306 section_table_id = psiconv_buffer_unique_id();
307 if ((res = psiconv_write_offset(config,buf,section_table_id)))
308 goto ERROR3;
309
310 entry->id = PSICONV_ID_APPL_ID_SECTION;
311 entry->offset = psiconv_buffer_unique_id();
312 if ((res = psiconv_list_add(section_table,entry)))
313 goto ERROR3;
314 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
315 goto ERROR3;
316 if ((res=psiconv_write_application_id_section(config,buf,
317 PSICONV_ID_SKETCH,"Paint.app")))
318 goto ERROR3;
319
320 entry->id = PSICONV_ID_SKETCH_SECTION;
321 entry->offset = psiconv_buffer_unique_id();
322 if ((res = psiconv_list_add(section_table,entry)))
323 goto ERROR3;
324 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
325 goto ERROR3;
326 if ((res = psiconv_write_sketch_section(config,buf,value->sketch_sec)))
327 goto ERROR3;
328
329 if ((res = psiconv_buffer_add_target(buf,section_table_id)))
330 goto ERROR3;
331 res = psiconv_write_section_table_section(config,buf,section_table);
332
333ERROR3:
334 free(entry);
335ERROR2:
336 psiconv_list_free(section_table);
337ERROR1:
338 return res;
339}
340
341int psiconv_write_mbm_file(const psiconv_config config,
342 psiconv_buffer buf,psiconv_mbm_f value)
343{
344 int res,i;
345 psiconv_jumptable_section jumptable;
346 psiconv_u32 *entry,id,table_id;
347 psiconv_paint_data_section section;
348
349 if (!value) {
350 psiconv_warn(config,0,0,"Null MBM file");
351 return -PSICONV_E_GENERATE;
352 }
353
354 if (!(jumptable = psiconv_list_new(sizeof(*entry)))) {
355 res = -PSICONV_E_NOMEM;
356 goto ERROR1;
357 }
358
359 table_id = psiconv_buffer_unique_id();
360 if ((res = psiconv_buffer_add_reference(buf,table_id)))
361 goto ERROR2;
362
363 for (i = 0; i < psiconv_list_length(value->sections); i++) {
364 if (!(section = psiconv_list_get(value->sections,i))) {
365 psiconv_warn(config,0,0,"Massive memory corruption");
366 res = -PSICONV_E_NOMEM;
367 goto ERROR2;
368 }
369 id = psiconv_buffer_unique_id();
370 psiconv_list_add(jumptable,&id);
371 if ((res = psiconv_buffer_add_target(buf,id)))
372 goto ERROR2;
373 if ((res = psiconv_write_paint_data_section(config,buf,section)))
374 goto ERROR2;
375 }
376
377 if ((res = psiconv_buffer_add_target(buf,table_id)))
378 goto ERROR2;
379 if ((res = psiconv_write_jumptable_section(config,buf,jumptable)))
380 goto ERROR2;
381
382
383ERROR2:
384 psiconv_list_free(jumptable);
385ERROR1:
386 return res;
387}

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

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