--- psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/25 17:59:01 169 +++ psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/25 22:08:48 170 @@ -57,11 +57,15 @@ if ((res =psiconv_write_texted_file(config,*buf, (psiconv_texted_f) (value->file)))) goto ERROR; -#if 0 } else if (value->type == psiconv_sketch_file) { + if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5, + PSICONV_ID_DATA_FILE, + PSICONV_ID_SKETCH))) + goto ERROR; if ((res =psiconv_write_sketch_file(config,*buf, (psiconv_sketch_f) (value->file)))) goto ERROR; +#if 0 } else if (value->type == psiconv_mbm_file) { if ((res =psiconv_write_mbm_file(config,*buf, (psiconv_mbm_f) (value->file)))) @@ -265,6 +269,64 @@ res = psiconv_write_section_table_section(config,buf,section_table); ERROR3: + free(entry); +ERROR2: + psiconv_list_free(section_table); +ERROR1: + return res; +} + +int psiconv_write_sketch_file(const psiconv_config config, + psiconv_buffer buf,psiconv_sketch_f value) +{ + int res; + psiconv_section_table_section section_table; + psiconv_section_table_entry entry; + psiconv_u32 section_table_id; + + if (!value) { + psiconv_warn(config,0,0,"Null Sketch file"); + return -PSICONV_E_GENERATE; + } + + if (!(section_table = psiconv_list_new(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR1; + } + + if (!(entry = malloc(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR2; + } + + section_table_id = psiconv_buffer_unique_id(); + if ((res = psiconv_write_offset(config,buf,section_table_id))) + goto ERROR3; + + entry->id = PSICONV_ID_APPL_ID_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res=psiconv_write_application_id_section(config,buf, + PSICONV_ID_SKETCH,"Paint.app"))) + goto ERROR3; + + entry->id = PSICONV_ID_SKETCH_SECTION; + entry->offset = psiconv_buffer_unique_id(); + if ((res = psiconv_list_add(section_table,entry))) + goto ERROR3; + if ((res = psiconv_buffer_add_target(buf,entry->offset))) + goto ERROR3; + if ((res = psiconv_write_sketch_section(config,buf,value->sketch_sec))) + goto ERROR3; + + if ((res = psiconv_buffer_add_target(buf,section_table_id))) + goto ERROR3; + res = psiconv_write_section_table_section(config,buf,section_table); + +ERROR3: free(entry); ERROR2: psiconv_list_free(section_table);