… | |
… | |
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 | |
29 | int psiconv_write(psiconv_buffer *buf,const psiconv_file value) |
33 | int psiconv_write(psiconv_buffer *buf,const psiconv_file value) |
30 | { |
34 | { |
31 | int res; |
35 | int res; |
32 | |
36 | |
… | |
… | |
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 (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; |
41 | 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)))) |
42 | goto ERROR; |
50 | goto ERROR; |
43 | } else 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; |
44 | if ((res =psiconv_write_texted_file(*buf, |
56 | if ((res =psiconv_write_texted_file(*buf, |
45 | (psiconv_texted_f) (value->file)))) |
57 | (psiconv_texted_f) (value->file)))) |
46 | goto ERROR; |
58 | goto ERROR; |
47 | #if 0 |
59 | #if 0 |
48 | } else if (value->type == psiconv_sketch_file) { |
60 | } else if (value->type == psiconv_sketch_file) { |
… | |
… | |
103 | } |
115 | } |
104 | if (!(base_para = psiconv_basic_paragraph_layout())) { |
116 | if (!(base_para = psiconv_basic_paragraph_layout())) { |
105 | res = -PSICONV_E_NOMEM; |
117 | res = -PSICONV_E_NOMEM; |
106 | goto ERROR4; |
118 | goto ERROR4; |
107 | } |
119 | } |
108 | |
|
|
109 | if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5, |
|
|
110 | PSICONV_ID_DATA_FILE, |
|
|
111 | PSICONV_ID_TEXTED))) |
|
|
112 | goto ERROR5; |
|
|
113 | |
120 | |
114 | section_table_id = psiconv_buffer_unique_id(); |
121 | section_table_id = psiconv_buffer_unique_id(); |
115 | if ((res = psiconv_write_offset(buf,section_table_id))) |
122 | if ((res = psiconv_write_offset(buf,section_table_id))) |
116 | goto ERROR5; |
123 | goto ERROR5; |
117 | |
124 | |
… | |
… | |
187 | if (!(entry = malloc(sizeof(*entry)))) { |
194 | if (!(entry = malloc(sizeof(*entry)))) { |
188 | res = -PSICONV_E_NOMEM; |
195 | res = -PSICONV_E_NOMEM; |
189 | goto ERROR2; |
196 | goto ERROR2; |
190 | } |
197 | } |
191 | |
198 | |
192 | if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5, |
|
|
193 | PSICONV_ID_DATA_FILE, |
|
|
194 | PSICONV_ID_WORD))) |
|
|
195 | goto ERROR3; |
|
|
196 | |
|
|
197 | section_table_id = psiconv_buffer_unique_id(); |
199 | section_table_id = psiconv_buffer_unique_id(); |
198 | if ((res = psiconv_write_offset(buf,section_table_id))) |
200 | if ((res = psiconv_write_offset(buf,section_table_id))) |
199 | goto ERROR3; |
201 | goto ERROR3; |
200 | |
202 | |
201 | entry->id = PSICONV_ID_APPL_ID_SECTION; |
203 | entry->id = PSICONV_ID_APPL_ID_SECTION; |