/[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 76 Revision 79
32 32
33 if (!value) { 33 if (!value) {
34 psiconv_warn(0,0,"Can't parse to an empty buffer!"); 34 psiconv_warn(0,0,"Can't parse to an empty buffer!");
35 return -PSICONV_E_OTHER; 35 return -PSICONV_E_OTHER;
36 } 36 }
37 if (!(*buf = psiconv_new_buffer())) 37 if (!(*buf = psiconv_buffer_new(0)))
38 return -PSICONV_E_NOMEM; 38 return -PSICONV_E_NOMEM;
39 39
40#if 0 40#if 0
41 if (value->type == psiconv_word_file) { 41 if (value->type == psiconv_word_file) {
42 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) 42 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file))))
67 goto ERROR; 67 goto ERROR;
68 } 68 }
69 return -PSICONV_E_OK; 69 return -PSICONV_E_OK;
70 70
71ERROR: 71ERROR:
72 psiconv_free_buffer(*buf); 72 psiconv_buffer_free(*buf);
73 return res; 73 return res;
74} 74}
75 75
76int psiconv_write_texted_file(psiconv_buffer buf,psiconv_texted_f value) 76int psiconv_write_texted_file(psiconv_buffer buf,psiconv_texted_f value)
77{ 77{
95 if (!(entry = malloc(sizeof(*entry)))) { 95 if (!(entry = malloc(sizeof(*entry)))) {
96 res = -PSICONV_E_NOMEM; 96 res = -PSICONV_E_NOMEM;
97 goto ERROR2; 97 goto ERROR2;
98 } 98 }
99 99
100 /* Base offset is 0x18: 0x10 header section plus the section table offset */
100 if (!(extra_buf = psiconv_new_buffer())) { 101 if (!(extra_buf = psiconv_buffer_new(0x14))) {
101 res = -PSICONV_E_NOMEM; 102 res = -PSICONV_E_NOMEM;
102 goto ERROR3; 103 goto ERROR3;
103 } 104 }
104 105
105 if (!(base_char = psiconv_basic_character_layout())) { 106 if (!(base_char = psiconv_basic_character_layout())) {
116 PSICONV_ID_TEXTED))) 117 PSICONV_ID_TEXTED)))
117 goto ERROR6; 118 goto ERROR6;
118 119
119 120
120 entry->id = PSICONV_ID_APPL_ID_SECTION; 121 entry->id = PSICONV_ID_APPL_ID_SECTION;
121 entry->offset = psiconv_list_length(extra_buf) + 0x14; 122 entry->offset = psiconv_buffer_length(extra_buf) +
123 psiconv_buffer_base_offset(extra_buf);
122 if ((res = psiconv_list_add(section_table,entry))) 124 if ((res = psiconv_list_add(section_table,entry)))
123 goto ERROR6; 125 goto ERROR6;
124 if ((res=psiconv_write_application_id_section(extra_buf, 126 if ((res=psiconv_write_application_id_section(extra_buf,
125 PSICONV_ID_TEXTED,"TextEd.app"))) 127 PSICONV_ID_TEXTED,"TextEd.app")))
126 goto ERROR6; 128 goto ERROR6;
127 129
128 entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION; 130 entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
129 entry->offset = psiconv_list_length(extra_buf) + 0x14; 131 entry->offset = psiconv_buffer_length(extra_buf) +
132 psiconv_buffer_base_offset(extra_buf);
130 if ((res = psiconv_list_add(section_table,entry))) 133 if ((res = psiconv_list_add(section_table,entry)))
131 goto ERROR6; 134 goto ERROR6;
132 if ((res = psiconv_write_page_layout_section(extra_buf,value->page_sec))) 135 if ((res = psiconv_write_page_layout_section(extra_buf,value->page_sec)))
133 goto ERROR6; 136 goto ERROR6;
134 137
135 entry->id = PSICONV_ID_TEXTED; 138 entry->id = PSICONV_ID_TEXTED;
136 entry->offset = psiconv_list_length(extra_buf) + 0x14; 139 entry->offset = psiconv_buffer_length(extra_buf) +
140 psiconv_buffer_base_offset(extra_buf);
137 if ((res = psiconv_list_add(section_table,entry))) 141 if ((res = psiconv_list_add(section_table,entry)))
138 goto ERROR6; 142 goto ERROR6;
139 if ((res = psiconv_write_texted_section(extra_buf,value->texted_sec, 143 if ((res = psiconv_write_texted_section(extra_buf,value->texted_sec,
140 base_char,base_para))) 144 base_char,base_para)))
141 goto ERROR6; 145 goto ERROR6;
142 146
143 if ((res = psiconv_write_u32(buf,psiconv_list_length(extra_buf) + 0x14))) 147 if ((res = psiconv_write_u32(buf,psiconv_buffer_length(extra_buf) +
148 psiconv_buffer_base_offset(extra_buf))))
144 goto ERROR6; 149 goto ERROR6;
145 150
146 if ((res = psiconv_list_concat(buf,extra_buf))) 151 if ((res = psiconv_buffer_concat(buf,extra_buf)))
147 goto ERROR6; 152 goto ERROR6;
148 153
149 res = psiconv_write_section_table_section(buf,section_table); 154 res = psiconv_write_section_table_section(buf,section_table);
150 155
151ERROR6: 156ERROR6:
152 psiconv_free_paragraph_layout(base_para); 157 psiconv_free_paragraph_layout(base_para);
153ERROR5: 158ERROR5:
154 psiconv_free_character_layout(base_char); 159 psiconv_free_character_layout(base_char);
155ERROR4: 160ERROR4:
156 psiconv_free_buffer(extra_buf); 161 psiconv_buffer_free(extra_buf);
157ERROR3: 162ERROR3:
158 free(entry); 163 free(entry);
159ERROR2: 164ERROR2:
160 psiconv_list_free(section_table); 165 psiconv_list_free(section_table);
161ERROR1: 166ERROR1:

Legend:
Removed from v.76  
changed lines
  Added in v.79

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