--- psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/27 11:43:51 173 +++ psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/27 12:08:13 174 @@ -73,12 +73,11 @@ if ((res =psiconv_write_mbm_file(config,*buf, (psiconv_mbm_f) (value->file)))) goto ERROR; -#if 0 } else if (value->type == psiconv_clipart_file) { + /* No complete header section, so we do it all in the below function */ if ((res =psiconv_write_clipart_file(config,*buf, (psiconv_clipart_f) (value->file)))) goto ERROR; -#endif } else { psiconv_warn(config,0,0,"Unknown or unsupported file type"); res = -PSICONV_E_GENERATE; @@ -370,7 +369,7 @@ psiconv_list_add(jumptable,&id); if ((res = psiconv_buffer_add_target(buf,id))) goto ERROR2; - if ((res = psiconv_write_paint_data_section(config,buf,section))) + if ((res = psiconv_write_paint_data_section(config,buf,section,0))) goto ERROR2; } @@ -383,5 +382,62 @@ ERROR2: psiconv_list_free(jumptable); ERROR1: + return res; +} + +/* Note: this file is special, because it does not have a complete header! */ +int psiconv_write_clipart_file(const psiconv_config config, + psiconv_buffer buf,psiconv_clipart_f value) +{ + int res,i; + psiconv_jumptable_section jumptable; + psiconv_u32 *entry,id; + psiconv_clipart_section section; + psiconv_buffer sec_buf; + + if (!value) { + psiconv_warn(config,0,0,"Null Clipart file"); + return -PSICONV_E_GENERATE; + } + + if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR1; + } + + if (!(sec_buf = psiconv_buffer_new())) { + res = -PSICONV_E_NOMEM; + goto ERROR2; + } + + if ((res = psiconv_write_u32(config,buf,PSICONV_ID_CLIPART))) + goto ERROR3; + + for (i = 0; i < psiconv_list_length(value->sections); i++) { + if (!(section = psiconv_list_get(value->sections,i))) { + psiconv_warn(config,0,0,"Massive memory corruption"); + res = -PSICONV_E_NOMEM; + goto ERROR3; + } + id = psiconv_buffer_unique_id(); + psiconv_list_add(jumptable,&id); + if ((res = psiconv_buffer_add_target(sec_buf,id))) + goto ERROR3; + if ((res = psiconv_write_clipart_section(config,sec_buf, section))) + goto ERROR3; + } + + if ((res = psiconv_write_jumptable_section(config,buf,jumptable))) + goto ERROR3; + + if ((res = psiconv_buffer_concat(buf,sec_buf))) + goto ERROR3; + + +ERROR3: + psiconv_buffer_free(sec_buf); +ERROR2: + psiconv_list_free(jumptable); +ERROR1: return res; }