/[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 142
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) {
42 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) 45 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file))))
43 goto ERROR; 46 goto ERROR;
44 } else
45#endif
46 if (value->type == psiconv_texted_file) { 47 } else if (value->type == psiconv_texted_file) {
47 if ((res =psiconv_write_texted_file(*buf, 48 if ((res =psiconv_write_texted_file(*buf,
48 (psiconv_texted_f) (value->file)))) 49 (psiconv_texted_f) (value->file))))
49 goto ERROR; 50 goto ERROR;
50#if 0 51#if 0
51 } else if (value->type == psiconv_sketch_file) { 52 } else if (value->type == psiconv_sketch_file) {
167ERROR2: 168ERROR2:
168 psiconv_list_free(section_table); 169 psiconv_list_free(section_table);
169ERROR1: 170ERROR1:
170 return res; 171 return res;
171} 172}
173
174int psiconv_write_word_file(psiconv_buffer buf,psiconv_word_f value)
175{
176 int res;
177 psiconv_section_table_section section_table;
178 psiconv_section_table_entry entry;
179 psiconv_u32 section_table_id;
180
181 if (!value) {
182 psiconv_warn(0,0,"Null Word file");
183 return -PSICONV_E_GENERATE;
184 }
185
186 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
187 res = -PSICONV_E_NOMEM;
188 goto ERROR1;
189 }
190
191 if (!(entry = malloc(sizeof(*entry)))) {
192 res = -PSICONV_E_NOMEM;
193 goto ERROR2;
194 }
195
196 if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5,
197 PSICONV_ID_DATA_FILE,
198 PSICONV_ID_WORD)))
199 goto ERROR3;
200
201 section_table_id = psiconv_buffer_unique_id();
202 if ((res = psiconv_write_offset(buf,section_table_id)))
203 goto ERROR3;
204
205 entry->id = PSICONV_ID_APPL_ID_SECTION;
206 entry->offset = psiconv_buffer_unique_id();
207 if ((res = psiconv_list_add(section_table,entry)))
208 goto ERROR3;
209 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
210 goto ERROR3;
211 if ((res=psiconv_write_application_id_section(buf,
212 PSICONV_ID_WORD,"Word.app")))
213 goto ERROR3;
214
215 entry->id = PSICONV_ID_WORD_STATUS_SECTION;
216 entry->offset = psiconv_buffer_unique_id();
217 if ((res = psiconv_list_add(section_table,entry)))
218 goto ERROR3;
219 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
220 goto ERROR3;
221 if ((res = psiconv_write_word_status_section(buf,value->status_sec)))
222 goto ERROR3;
223
224 entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
225 entry->offset = psiconv_buffer_unique_id();
226 if ((res = psiconv_list_add(section_table,entry)))
227 goto ERROR3;
228 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
229 goto ERROR3;
230 if ((res = psiconv_write_page_layout_section(buf,value->page_sec)))
231 goto ERROR3;
232
233 entry->id = PSICONV_ID_WORD_STYLES_SECTION;
234 entry->offset = psiconv_buffer_unique_id();
235 if ((res = psiconv_list_add(section_table,entry)))
236 goto ERROR3;
237 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
238 goto ERROR3;
239 if ((res = psiconv_write_word_styles_section(buf,value->styles_sec)))
240 goto ERROR3;
241
242 entry->id = PSICONV_ID_TEXT_SECTION;
243 entry->offset = psiconv_buffer_unique_id();
244 if ((res = psiconv_list_add(section_table,entry)))
245 goto ERROR3;
246 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
247 goto ERROR3;
248 if ((res = psiconv_write_text_section(buf,value->paragraphs)))
249 goto ERROR3;
250
251 entry->id = PSICONV_ID_LAYOUT_SECTION;
252 entry->offset = psiconv_buffer_unique_id();
253 if ((res = psiconv_list_add(section_table,entry)))
254 goto ERROR3;
255 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
256 goto ERROR3;
257 if ((res = psiconv_write_styled_layout_section(buf,value->paragraphs,
258 value->styles_sec)))
259 goto ERROR3;
260
261 if ((res = psiconv_buffer_add_target(buf,section_table_id)))
262 goto ERROR3;
263
264 res = psiconv_write_section_table_section(buf,section_table);
265
266ERROR3:
267 free(entry);
268ERROR2:
269 psiconv_list_free(section_table);
270ERROR1:
271 return res;
272}

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

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