/[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 80 Revision 166
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "error.h" 25#include "error.h"
26#include "generate_routines.h" 26#include "generate_routines.h"
27 27
28#ifdef DMALLOC
29#include <dmalloc.h>
30#endif
31
28 32
29int psiconv_write(psiconv_buffer *buf,const psiconv_file value) 33int psiconv_write(psiconv_buffer *buf,const psiconv_file value)
30{ 34{
31 int res; 35 int res;
32 36
35 return -PSICONV_E_OTHER; 39 return -PSICONV_E_OTHER;
36 } 40 }
37 if (!(*buf = psiconv_buffer_new())) 41 if (!(*buf = psiconv_buffer_new()))
38 return -PSICONV_E_NOMEM; 42 return -PSICONV_E_NOMEM;
39 43
40#if 0
41 if (value->type == psiconv_word_file) { 44 if (value->type == psiconv_word_file) {
45 if ((res = psiconv_write_header_section(*buf,PSICONV_ID_PSION5,
46 PSICONV_ID_DATA_FILE,
47 PSICONV_ID_WORD)))
48 goto ERROR;
42 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) 49 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file))))
43 goto ERROR; 50 goto ERROR;
44 } else
45#endif
46 if (value->type == psiconv_texted_file) { 51 } else if (value->type == psiconv_texted_file) {
52 if ((res = psiconv_write_header_section(*buf,PSICONV_ID_PSION5,
53 PSICONV_ID_DATA_FILE,
54 PSICONV_ID_TEXTED)))
55 goto ERROR;
47 if ((res =psiconv_write_texted_file(*buf, 56 if ((res =psiconv_write_texted_file(*buf,
48 (psiconv_texted_f) (value->file)))) 57 (psiconv_texted_f) (value->file))))
49 goto ERROR; 58 goto ERROR;
50#if 0 59#if 0
51 } else if (value->type == psiconv_sketch_file) { 60 } else if (value->type == psiconv_sketch_file) {
106 } 115 }
107 if (!(base_para = psiconv_basic_paragraph_layout())) { 116 if (!(base_para = psiconv_basic_paragraph_layout())) {
108 res = -PSICONV_E_NOMEM; 117 res = -PSICONV_E_NOMEM;
109 goto ERROR4; 118 goto ERROR4;
110 } 119 }
111
112 if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5,
113 PSICONV_ID_DATA_FILE,
114 PSICONV_ID_TEXTED)))
115 goto ERROR5;
116 120
117 section_table_id = psiconv_buffer_unique_id(); 121 section_table_id = psiconv_buffer_unique_id();
118 if ((res = psiconv_write_offset(buf,section_table_id))) 122 if ((res = psiconv_write_offset(buf,section_table_id)))
119 goto ERROR5; 123 goto ERROR5;
120 124
167ERROR2: 171ERROR2:
168 psiconv_list_free(section_table); 172 psiconv_list_free(section_table);
169ERROR1: 173ERROR1:
170 return res; 174 return res;
171} 175}
176
177int psiconv_write_word_file(psiconv_buffer buf,psiconv_word_f value)
178{
179 int res;
180 psiconv_section_table_section section_table;
181 psiconv_section_table_entry entry;
182 psiconv_u32 section_table_id;
183
184 if (!value) {
185 psiconv_warn(0,0,"Null Word file");
186 return -PSICONV_E_GENERATE;
187 }
188
189 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
190 res = -PSICONV_E_NOMEM;
191 goto ERROR1;
192 }
193
194 if (!(entry = malloc(sizeof(*entry)))) {
195 res = -PSICONV_E_NOMEM;
196 goto ERROR2;
197 }
198
199 section_table_id = psiconv_buffer_unique_id();
200 if ((res = psiconv_write_offset(buf,section_table_id)))
201 goto ERROR3;
202
203 entry->id = PSICONV_ID_APPL_ID_SECTION;
204 entry->offset = psiconv_buffer_unique_id();
205 if ((res = psiconv_list_add(section_table,entry)))
206 goto ERROR3;
207 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
208 goto ERROR3;
209 if ((res=psiconv_write_application_id_section(buf,
210 PSICONV_ID_WORD,"Word.app")))
211 goto ERROR3;
212
213 entry->id = PSICONV_ID_WORD_STATUS_SECTION;
214 entry->offset = psiconv_buffer_unique_id();
215 if ((res = psiconv_list_add(section_table,entry)))
216 goto ERROR3;
217 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
218 goto ERROR3;
219 if ((res = psiconv_write_word_status_section(buf,value->status_sec)))
220 goto ERROR3;
221
222 entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
223 entry->offset = psiconv_buffer_unique_id();
224 if ((res = psiconv_list_add(section_table,entry)))
225 goto ERROR3;
226 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
227 goto ERROR3;
228 if ((res = psiconv_write_page_layout_section(buf,value->page_sec)))
229 goto ERROR3;
230
231 entry->id = PSICONV_ID_WORD_STYLES_SECTION;
232 entry->offset = psiconv_buffer_unique_id();
233 if ((res = psiconv_list_add(section_table,entry)))
234 goto ERROR3;
235 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
236 goto ERROR3;
237 if ((res = psiconv_write_word_styles_section(buf,value->styles_sec)))
238 goto ERROR3;
239
240 entry->id = PSICONV_ID_TEXT_SECTION;
241 entry->offset = psiconv_buffer_unique_id();
242 if ((res = psiconv_list_add(section_table,entry)))
243 goto ERROR3;
244 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
245 goto ERROR3;
246 if ((res = psiconv_write_text_section(buf,value->paragraphs)))
247 goto ERROR3;
248
249 entry->id = PSICONV_ID_LAYOUT_SECTION;
250 entry->offset = psiconv_buffer_unique_id();
251 if ((res = psiconv_list_add(section_table,entry)))
252 goto ERROR3;
253 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
254 goto ERROR3;
255 if ((res = psiconv_write_styled_layout_section(buf,value->paragraphs,
256 value->styles_sec)))
257 goto ERROR3;
258
259 if ((res = psiconv_buffer_add_target(buf,section_table_id)))
260 goto ERROR3;
261
262 res = psiconv_write_section_table_section(buf,section_table);
263
264ERROR3:
265 free(entry);
266ERROR2:
267 psiconv_list_free(section_table);
268ERROR1:
269 return res;
270}

Legend:
Removed from v.80  
changed lines
  Added in v.166

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