--- psiconv/trunk/lib/psiconv/generate_driver.c 2002/01/29 18:38:38 142 +++ psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/25 17:57:05 168 @@ -30,40 +30,49 @@ #endif -int psiconv_write(psiconv_buffer *buf,const psiconv_file value) +int psiconv_write(const psiconv_config config, psiconv_buffer *buf, + const psiconv_file value) { int res; if (!value) { - psiconv_warn(0,0,"Can't parse to an empty buffer!"); + psiconv_warn(config,0,0,"Can't parse to an empty buffer!"); return -PSICONV_E_OTHER; } if (!(*buf = psiconv_buffer_new())) return -PSICONV_E_NOMEM; if (value->type == psiconv_word_file) { - if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) + if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5, + PSICONV_ID_DATA_FILE, + PSICONV_ID_WORD))) + goto ERROR; + if ((res =psiconv_write_word_file(config,*buf,(psiconv_word_f) (value->file)))) goto ERROR; } else if (value->type == psiconv_texted_file) { - if ((res =psiconv_write_texted_file(*buf, + if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5, + PSICONV_ID_DATA_FILE, + PSICONV_ID_TEXTED))) + goto ERROR; + 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_sketch_file(*buf, + if ((res =psiconv_write_sketch_file(config,*buf, (psiconv_sketch_f) (value->file)))) goto ERROR; } else if (value->type == psiconv_mbm_file) { - if ((res =psiconv_write_mbm_file(*buf, + if ((res =psiconv_write_mbm_file(config,*buf, (psiconv_mbm_f) (value->file)))) goto ERROR; } else if (value->type == psiconv_clipart_file) { - if ((res =psiconv_write_clipart_file(*buf, + if ((res =psiconv_write_clipart_file(config,*buf, (psiconv_clipart_f) (value->file)))) goto ERROR; #endif } else { - psiconv_warn(0,0,"Unknown or unsupported file type"); + psiconv_warn(config,0,0,"Unknown or unsupported file type"); res = -PSICONV_E_GENERATE; goto ERROR; } @@ -76,7 +85,8 @@ return res; } -int psiconv_write_texted_file(psiconv_buffer buf,psiconv_texted_f value) +int psiconv_write_texted_file(const psiconv_config config, + psiconv_buffer buf,psiconv_texted_f value) { psiconv_character_layout base_char; psiconv_paragraph_layout base_para; @@ -87,7 +97,7 @@ psiconv_buffer buf_texted; if (!value) { - psiconv_warn(0,0,"Null TextEd file"); + psiconv_warn(config,0,0,"Null TextEd file"); return -PSICONV_E_GENERATE; } @@ -110,13 +120,8 @@ goto ERROR4; } - if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5, - PSICONV_ID_DATA_FILE, - PSICONV_ID_TEXTED))) - goto ERROR5; - section_table_id = psiconv_buffer_unique_id(); - if ((res = psiconv_write_offset(buf,section_table_id))) + if ((res = psiconv_write_offset(config,buf,section_table_id))) goto ERROR5; entry->id = PSICONV_ID_APPL_ID_SECTION; @@ -125,7 +130,7 @@ goto ERROR5; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR5; - if ((res=psiconv_write_application_id_section(buf, + if ((res=psiconv_write_application_id_section(config,buf, PSICONV_ID_TEXTED,"TextEd.app"))) goto ERROR5; @@ -135,7 +140,7 @@ goto ERROR5; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR5; - if ((res = psiconv_write_page_layout_section(buf,value->page_sec))) + if ((res = psiconv_write_page_layout_section(config,buf,value->page_sec))) goto ERROR5; entry->id = PSICONV_ID_TEXTED; @@ -144,7 +149,7 @@ goto ERROR5; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR5; - if ((res = psiconv_write_texted_section(buf,value->texted_sec, + if ((res = psiconv_write_texted_section(config,buf,value->texted_sec, base_char,base_para,&buf_texted))) goto ERROR5; @@ -155,7 +160,7 @@ if ((res = psiconv_buffer_add_target(buf,section_table_id))) goto ERROR6; - res = psiconv_write_section_table_section(buf,section_table); + res = psiconv_write_section_table_section(config,buf,section_table); ERROR6: psiconv_buffer_free(buf_texted); @@ -171,7 +176,8 @@ return res; } -int psiconv_write_word_file(psiconv_buffer buf,psiconv_word_f value) +int psiconv_write_word_file(const psiconv_config config, + psiconv_buffer buf,psiconv_word_f value) { int res; psiconv_section_table_section section_table; @@ -179,7 +185,7 @@ psiconv_u32 section_table_id; if (!value) { - psiconv_warn(0,0,"Null Word file"); + psiconv_warn(config,0,0,"Null Word file"); return -PSICONV_E_GENERATE; } @@ -193,13 +199,8 @@ goto ERROR2; } - if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5, - PSICONV_ID_DATA_FILE, - PSICONV_ID_WORD))) - goto ERROR3; - section_table_id = psiconv_buffer_unique_id(); - if ((res = psiconv_write_offset(buf,section_table_id))) + if ((res = psiconv_write_offset(config,buf,section_table_id))) goto ERROR3; entry->id = PSICONV_ID_APPL_ID_SECTION; @@ -208,7 +209,7 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res=psiconv_write_application_id_section(buf, + if ((res=psiconv_write_application_id_section(config,buf, PSICONV_ID_WORD,"Word.app"))) goto ERROR3; @@ -218,7 +219,7 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res = psiconv_write_word_status_section(buf,value->status_sec))) + if ((res = psiconv_write_word_status_section(config,buf,value->status_sec))) goto ERROR3; entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION; @@ -227,7 +228,7 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res = psiconv_write_page_layout_section(buf,value->page_sec))) + if ((res = psiconv_write_page_layout_section(config,buf,value->page_sec))) goto ERROR3; entry->id = PSICONV_ID_WORD_STYLES_SECTION; @@ -236,7 +237,7 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res = psiconv_write_word_styles_section(buf,value->styles_sec))) + if ((res = psiconv_write_word_styles_section(config,buf,value->styles_sec))) goto ERROR3; entry->id = PSICONV_ID_TEXT_SECTION; @@ -245,7 +246,7 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res = psiconv_write_text_section(buf,value->paragraphs))) + if ((res = psiconv_write_text_section(config,buf,value->paragraphs))) goto ERROR3; entry->id = PSICONV_ID_LAYOUT_SECTION; @@ -254,14 +255,14 @@ goto ERROR3; if ((res = psiconv_buffer_add_target(buf,entry->offset))) goto ERROR3; - if ((res = psiconv_write_styled_layout_section(buf,value->paragraphs, + if ((res = psiconv_write_styled_layout_section(config,buf,value->paragraphs, value->styles_sec))) goto ERROR3; if ((res = psiconv_buffer_add_target(buf,section_table_id))) goto ERROR3; - res = psiconv_write_section_table_section(buf,section_table); + res = psiconv_write_section_table_section(config,buf,section_table); ERROR3: free(entry);