… | |
… | |
29 | int len=0; |
29 | int len=0; |
30 | psiconv_u32 temp; |
30 | psiconv_u32 temp; |
31 | int leng; |
31 | int leng; |
32 | |
32 | |
33 | psiconv_progress(lev+1,off,"Going to read the word status section"); |
33 | psiconv_progress(lev+1,off,"Going to read the word status section"); |
34 | *result = malloc(sizeof(**result)); |
34 | if (!(*result = malloc(sizeof(**result)))) |
|
|
35 | goto ERROR1; |
35 | |
36 | |
36 | psiconv_progress(lev+2,off+len, |
37 | psiconv_progress(lev+2,off+len, |
37 | "Going to read the initial byte (%02x expected)",0x02); |
38 | "Going to read the initial byte (%02x expected)",0x02); |
38 | temp = psiconv_read_u8(buf,lev+2,off+len); |
39 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
40 | if (res) |
|
|
41 | goto ERROR2; |
39 | if (temp != 0x02) { |
42 | if (temp != 0x02) { |
40 | psiconv_warn(lev+2,off+len, |
43 | psiconv_warn(lev+2,off+len, |
41 | "Word status section initial byte unknown value"); |
44 | "Word status section initial byte unknown value (ignored)"); |
42 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
45 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
43 | res = -1; |
|
|
44 | } |
46 | } |
45 | len ++; |
47 | len ++; |
46 | |
48 | |
47 | psiconv_progress(lev+2,off+len, |
49 | psiconv_progress(lev+2,off+len, |
48 | "Going to read the first byte of display flags"); |
50 | "Going to read the first byte of display flags"); |
49 | temp = psiconv_read_u8(buf,lev+2,off+len); |
51 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
52 | if (res) |
|
|
53 | goto ERROR2; |
50 | |
54 | |
51 | (*result)->show_tabs = temp&0x01 ? psiconv_bool_true : psiconv_bool_false; |
55 | (*result)->show_tabs = temp&0x01 ? psiconv_bool_true : psiconv_bool_false; |
52 | psiconv_debug(lev+2,off+len,"Show tabs: %02x",(*result)->show_tabs); |
56 | psiconv_debug(lev+2,off+len,"Show tabs: %02x",(*result)->show_tabs); |
53 | (*result)->show_spaces = temp&0x02 ? psiconv_bool_true : psiconv_bool_false; |
57 | (*result)->show_spaces = temp&0x02 ? psiconv_bool_true : psiconv_bool_false; |
54 | psiconv_debug(lev+2,off+len,"Show spaces: %02x",(*result)->show_spaces); |
58 | psiconv_debug(lev+2,off+len,"Show spaces: %02x",(*result)->show_spaces); |
… | |
… | |
68 | psiconv_bool_false; |
72 | psiconv_bool_false; |
69 | psiconv_debug(lev+2,off+len,"Show hard space: %02x", |
73 | psiconv_debug(lev+2,off+len,"Show hard space: %02x", |
70 | (*result)->show_hard_space); |
74 | (*result)->show_hard_space); |
71 | if (temp & 0x90) { |
75 | if (temp & 0x90) { |
72 | psiconv_warn(lev+2,off+len,"Word status section first byte of display " |
76 | psiconv_warn(lev+2,off+len,"Word status section first byte of display " |
73 | "flags contains unknown flags"); |
77 | "flags contains unknown flags (ignored)"); |
74 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0x90); |
78 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0x90); |
75 | res = -1; |
|
|
76 | } |
79 | } |
77 | len ++; |
80 | len ++; |
78 | |
81 | |
79 | psiconv_progress(lev+2,off+len,"Going to read second byte of display flags"); |
82 | psiconv_progress(lev+2,off+len,"Going to read second byte of display flags"); |
80 | temp = psiconv_read_u8(buf,lev+2,off+len); |
83 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
84 | if (res) |
|
|
85 | goto ERROR2; |
81 | |
86 | |
82 | (*result)->show_full_pictures = temp & 0x01 ? psiconv_bool_true : |
87 | (*result)->show_full_pictures = temp & 0x01 ? psiconv_bool_true : |
83 | psiconv_bool_false; |
88 | psiconv_bool_false; |
84 | psiconv_debug(lev+2,off+len,"Show full pictures: %02x", |
89 | psiconv_debug(lev+2,off+len,"Show full pictures: %02x", |
85 | (*result)->show_full_pictures); |
90 | (*result)->show_full_pictures); |
… | |
… | |
87 | psiconv_bool_false; |
92 | psiconv_bool_false; |
88 | psiconv_debug(lev+2,off+len,"Show full graphs: %02x", |
93 | psiconv_debug(lev+2,off+len,"Show full graphs: %02x", |
89 | (*result)->show_full_graphs); |
94 | (*result)->show_full_graphs); |
90 | if (temp & 0xfc) { |
95 | if (temp & 0xfc) { |
91 | psiconv_warn(lev+2,off+len,"Word status section second byte of display " |
96 | psiconv_warn(lev+2,off+len,"Word status section second byte of display " |
92 | "flags contains unknown flags"); |
97 | "flags contains unknown flags (ignored)"); |
93 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xfc); |
98 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xfc); |
94 | res = -1; |
|
|
95 | } |
99 | } |
96 | len ++; |
100 | len ++; |
97 | |
101 | |
98 | psiconv_progress(lev+2,off+len,"Going to read top toolbar setting"); |
102 | psiconv_progress(lev+2,off+len,"Going to read top toolbar setting"); |
99 | psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->show_top_toolbar); |
103 | if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng, |
|
|
104 | &(*result)->show_top_toolbar))) |
|
|
105 | goto ERROR2; |
100 | len += leng; |
106 | len += leng; |
101 | |
107 | |
102 | psiconv_progress(lev+2,off+len,"Going to read side toolbar setting"); |
108 | psiconv_progress(lev+2,off+len,"Going to read side toolbar setting"); |
103 | psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->show_side_toolbar); |
109 | if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng, |
|
|
110 | &(*result)->show_side_toolbar))) |
|
|
111 | goto ERROR2; |
104 | len += leng; |
112 | len += leng; |
105 | |
113 | |
106 | psiconv_progress(lev+2,off+len,"Going to read operational flags"); |
114 | psiconv_progress(lev+2,off+len,"Going to read operational flags"); |
107 | temp = psiconv_read_u8(buf,lev+2,off+len); |
115 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
116 | if (res) |
|
|
117 | goto ERROR2; |
108 | (*result)->fit_lines_to_screen = temp & 0x08 ? psiconv_bool_true : |
118 | (*result)->fit_lines_to_screen = temp & 0x08 ? psiconv_bool_true : |
109 | psiconv_bool_false; |
119 | psiconv_bool_false; |
110 | psiconv_debug(lev+2,off+len,"Fit lines to screen: %02x", |
120 | psiconv_debug(lev+2,off+len,"Fit lines to screen: %02x", |
111 | (*result)->fit_lines_to_screen); |
121 | (*result)->fit_lines_to_screen); |
112 | if (temp & 0xf7) { |
122 | if (temp & 0xf7) { |
113 | psiconv_warn(lev+2,off+len,"Word status section operational flags " |
123 | psiconv_warn(lev+2,off+len,"Word status section operational flags " |
114 | "contains unknown flags"); |
124 | "contains unknown flags (ignored)"); |
115 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xfc); |
125 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xfc); |
116 | res = -1; |
|
|
117 | } |
126 | } |
118 | len ++; |
127 | len ++; |
119 | |
128 | |
120 | psiconv_progress(lev+2,off+len,"Going to read cursor position"); |
129 | psiconv_progress(lev+2,off+len,"Going to read cursor position"); |
121 | (*result)->cursor_position = psiconv_read_u32(buf,lev+2,off + len); |
130 | (*result)->cursor_position = psiconv_read_u32(buf,lev+2,off + len,&res); |
|
|
131 | if (res) |
|
|
132 | goto ERROR2; |
122 | psiconv_debug(lev+2,off+len,"Cursor position: %08x", |
133 | psiconv_debug(lev+2,off+len,"Cursor position: %08x", |
123 | (*result)->cursor_position); |
134 | (*result)->cursor_position); |
124 | len += 0x04; |
135 | len += 0x04; |
125 | |
136 | |
126 | psiconv_progress(lev+2,off+len,"Going to read display size"); |
137 | psiconv_progress(lev+2,off+len,"Going to read display size"); |
127 | (*result)->cursor_position = psiconv_read_u32(buf,lev+2,off + len); |
138 | (*result)->cursor_position = psiconv_read_u32(buf,lev+2,off + len,&res); |
|
|
139 | if (res) |
|
|
140 | goto ERROR2; |
128 | psiconv_debug(lev+2,off+len,"Display size: %08x", |
141 | psiconv_debug(lev+2,off+len,"Display size: %08x", |
129 | (*result)->cursor_position); |
142 | (*result)->cursor_position); |
130 | len += 0x04; |
143 | len += 0x04; |
131 | |
144 | |
132 | if (length) |
145 | if (length) |
133 | *length = len; |
146 | *length = len; |
134 | |
147 | |
135 | psiconv_progress(lev,off+len-1, |
148 | psiconv_progress(lev,off+len-1, |
136 | "End of word status section (total length: %08x)", len); |
149 | "End of word status section (total length: %08x)", len); |
|
|
150 | return 0; |
137 | |
151 | |
|
|
152 | ERROR2: |
|
|
153 | free (*result); |
|
|
154 | ERROR1: |
|
|
155 | psiconv_warn(lev+1,off,"Reading of Word Status Section failed"); |
|
|
156 | if (length) |
|
|
157 | *length = 0; |
|
|
158 | if (!res) |
|
|
159 | return -PSICONV_E_NOMEM; |
|
|
160 | else |
138 | return res; |
161 | return res; |
139 | } |
162 | } |
140 | |
163 | |
141 | int psiconv_parse_word_styles_section(const psiconv_buffer buf, int lev, |
164 | int psiconv_parse_word_styles_section(const psiconv_buffer buf, int lev, |
142 | psiconv_u32 off, int *length, |
165 | psiconv_u32 off, int *length, |
143 | psiconv_word_styles_section *result) |
166 | psiconv_word_styles_section *result) |
144 | { |
167 | { |
145 | int res=0; |
168 | int res=0; |
146 | int len=0; |
169 | int len=0; |
147 | int leng,i,nr; |
170 | int leng,i,nr,j; |
148 | psiconv_word_style style; |
171 | psiconv_word_style style; |
149 | psiconv_u32 temp; |
172 | psiconv_u32 temp; |
150 | |
173 | |
151 | psiconv_progress(lev+1,off,"Going to read the word styles section"); |
174 | psiconv_progress(lev+1,off,"Going to read the word styles section"); |
152 | *result = malloc(sizeof(**result)); |
175 | if (!(*result = malloc(sizeof(**result)))) |
|
|
176 | goto ERROR1; |
153 | |
177 | |
154 | psiconv_progress(lev+2,off+len,"Going to read style normal"); |
178 | psiconv_progress(lev+2,off+len,"Going to read style normal"); |
155 | style = malloc(sizeof(*style)); |
179 | if (!(style = malloc(sizeof(*style)))) |
|
|
180 | goto ERROR2; |
156 | style->name = NULL; |
181 | style->name = NULL; |
157 | style->paragraph = psiconv_basic_paragraph_layout(); |
182 | if (!(style->paragraph = psiconv_basic_paragraph_layout())) |
|
|
183 | goto ERROR2_1; |
158 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
184 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
159 | res |= psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
185 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
160 | style->paragraph); |
186 | style->paragraph))) |
|
|
187 | goto ERROR2_2; |
161 | len += leng; |
188 | len += leng; |
162 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
189 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
163 | style->character = psiconv_basic_character_layout(); |
190 | if (!(style->character = psiconv_basic_character_layout())) |
|
|
191 | goto ERROR2_2; |
164 | res |= psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
192 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
165 | style->character); |
193 | style->character))) |
|
|
194 | goto ERROR2_3; |
166 | len += leng; |
195 | len += leng; |
167 | psiconv_progress(lev+3,off+len,"Going to read the hotkey"); |
196 | psiconv_progress(lev+3,off+len,"Going to read the hotkey"); |
168 | temp = psiconv_read_u32(buf,lev+3,off+len); |
197 | temp = psiconv_read_u32(buf,lev+3,off+len,&res); |
|
|
198 | if (res) |
|
|
199 | goto ERROR2_3; |
169 | if (temp & 0xffffff00) { |
200 | if (temp & 0xffffff00) { |
170 | psiconv_warn(lev+3,off+len,"Normal style hotkey has unknown value"); |
201 | psiconv_warn(lev+3,off+len, |
|
|
202 | "Normal style hotkey has unknown value (ignored)"); |
171 | psiconv_debug(lev+3,off+len,"Hotkey value %08x",temp); |
203 | psiconv_debug(lev+3,off+len,"Hotkey value %08x",temp); |
172 | temp = 0; |
204 | temp = 0; |
173 | res = -1; |
|
|
174 | } |
205 | } |
175 | style->hotkey = temp; |
206 | style->hotkey = temp & 0x000000ff; |
176 | if ((style->hotkey >= 32) && (style->hotkey < 127)) |
207 | if ((style->hotkey >= 32) && (style->hotkey < 127)) |
177 | psiconv_debug(lev+3,off+len,"Hotkey: %c",style->hotkey); |
208 | psiconv_debug(lev+3,off+len,"Hotkey: %c",style->hotkey); |
178 | else if (style->hotkey == 0x00) |
209 | else if (style->hotkey == 0x00) |
179 | psiconv_debug(lev+3,off+len,"Hotkey: <none>"); |
210 | psiconv_debug(lev+3,off+len,"Hotkey: <none>"); |
180 | else |
211 | else |
181 | psiconv_debug(lev+3,off+len,"Hotkey: %02x",style->hotkey); |
212 | psiconv_debug(lev+3,off+len,"Hotkey: %02x",style->hotkey); |
182 | (*result)->normal = style; |
213 | (*result)->normal = style; |
183 | len += 0x04; |
214 | len += 0x04; |
184 | |
215 | |
185 | psiconv_progress(lev+2,off+len,"Going to read hotkeys list"); |
216 | psiconv_progress(lev+2,off+len,"Going to read hotkeys list"); |
186 | (*result)->styles = psiconv_list_new(sizeof(*style)); |
217 | if (!((*result)->styles = psiconv_list_new(sizeof(*style)))) |
|
|
218 | goto ERROR3; |
187 | style = malloc(sizeof(*style)); |
219 | if (!(style = malloc(sizeof(*style)))) { |
|
|
220 | goto ERROR3_1; |
|
|
221 | } |
|
|
222 | |
188 | psiconv_progress(lev+3,off+len,"Going to read the number of entries"); |
223 | psiconv_progress(lev+3,off+len,"Going to read the number of entries"); |
189 | nr = psiconv_read_u8(buf,lev+3,off+len); |
224 | nr = psiconv_read_u8(buf,lev+3,off+len,&res); |
|
|
225 | if (res) |
|
|
226 | goto ERROR3_2; |
190 | len ++; |
227 | len ++; |
191 | psiconv_debug(lev+3,off+len,"Nummer of hotkeys: %02x",nr); |
228 | psiconv_debug(lev+3,off+len,"Nummer of hotkeys: %02x",nr); |
192 | for (i = 0; i < nr; i ++) { |
229 | for (i = 0; i < nr; i ++) { |
193 | temp = psiconv_read_u32(buf,lev+2,off+len); |
230 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
231 | if (res) |
|
|
232 | goto ERROR3_2; |
194 | if (temp & 0xffffff00) { |
233 | if (temp & 0xffffff00) { |
195 | psiconv_warn(lev+3,off+len,"Style hotkey has unknown value"); |
234 | psiconv_warn(lev+3,off+len,"Style hotkey has unknown value (ignored)"); |
196 | psiconv_debug(lev+3,off+len,"Hotkey %d value %08x",i,temp); |
235 | psiconv_debug(lev+3,off+len,"Hotkey %d value %08x",i,temp); |
197 | temp = 0; |
236 | temp = 0; |
198 | res = -1; |
|
|
199 | } |
237 | } |
200 | style->hotkey = temp; |
238 | style->hotkey = temp & 0x000000ff; |
201 | if ((style->hotkey >= 32) && (style->hotkey < 127)) |
239 | if ((style->hotkey >= 32) && (style->hotkey < 127)) |
202 | psiconv_debug(lev+3,off+len,"Hotkey %d: %c",i,style->hotkey); |
240 | psiconv_debug(lev+3,off+len,"Hotkey %d: %c",i,style->hotkey); |
203 | else if (style->hotkey == 0x00) |
241 | else if (style->hotkey == 0x00) |
204 | psiconv_debug(lev+3,off+len,"Hotkey %d: <none>",i); |
242 | psiconv_debug(lev+3,off+len,"Hotkey %d: <none>",i); |
205 | else |
243 | else |
206 | psiconv_debug(lev+3,off+len,"Hotkey %d: %02x",i,style->hotkey); |
244 | psiconv_debug(lev+3,off+len,"Hotkey %d: %02x",i,style->hotkey); |
207 | psiconv_list_add((*result)->styles,style); |
245 | if ((res = psiconv_list_add((*result)->styles,style))) |
|
|
246 | goto ERROR3_2; |
208 | len += 0x04; |
247 | len += 0x04; |
209 | } |
248 | } |
210 | free(style); |
249 | free(style); |
211 | |
250 | |
212 | psiconv_progress(lev+2,off+len,"Going to read all other styles"); |
251 | psiconv_progress(lev+2,off+len,"Going to read all other styles"); |
213 | psiconv_progress(lev+2,off+len,"Going to read the number of styles"); |
252 | psiconv_progress(lev+2,off+len,"Going to read the number of styles"); |
214 | nr = psiconv_read_u8(buf,lev+3,off+len); |
253 | nr = psiconv_read_u8(buf,lev+3,off+len,&res); |
|
|
254 | if (res) |
|
|
255 | goto ERROR4; |
215 | if (nr != psiconv_list_length((*result)->styles)) { |
256 | if (nr != psiconv_list_length((*result)->styles)) { |
216 | psiconv_warn(lev+3,off+len,"Number of styles and hotkeys do not match"); |
257 | psiconv_warn(lev+3,off+len,"Number of styles and hotkeys do not match"); |
217 | psiconv_debug(lev+3,off+len,"%d hotkeys, %d styles", |
258 | psiconv_debug(lev+3,off+len,"%d hotkeys, %d styles", |
218 | psiconv_list_length((*result)->styles), nr); |
259 | psiconv_list_length((*result)->styles), nr); |
219 | res = -1; |
|
|
220 | } |
260 | } |
221 | len ++; |
261 | len ++; |
222 | |
262 | |
223 | for (i = 0; i < nr; i++) { |
263 | for (i = 0; i < nr; i++) { |
224 | psiconv_progress(lev+2,off+len,"Next style: %d",i); |
264 | psiconv_progress(lev+2,off+len,"Next style: %d",i); |
225 | if (i >= psiconv_list_length((*result)->styles)) { |
265 | if (i >= psiconv_list_length((*result)->styles)) { |
226 | style = malloc(sizeof(*style)); |
266 | if (!(style = malloc(sizeof(*style)))) |
|
|
267 | goto ERROR5; |
227 | style->hotkey = 0; |
268 | style->hotkey = 0; |
228 | psiconv_list_add((*result)->styles,style); |
269 | if (!(psiconv_list_add((*result)->styles,style))) { |
|
|
270 | free(style); |
|
|
271 | goto ERROR5; |
|
|
272 | } |
229 | psiconv_debug(lev+3,off+len,"New entry added in list"); |
273 | psiconv_debug(lev+3,off+len,"New entry added in list"); |
230 | free(style); |
274 | free(style); |
231 | } |
275 | } |
232 | style = psiconv_list_get((*result)->styles,i); |
276 | if (!(style = psiconv_list_get((*result)->styles,i))) |
|
|
277 | goto ERROR5; |
233 | psiconv_progress(lev+3,off+len,"Going to read the style name"); |
278 | psiconv_progress(lev+3,off+len,"Going to read the style name"); |
234 | style->name = psiconv_read_string(buf,lev+3,off+len,&leng); |
279 | style->name = psiconv_read_string(buf,lev+3,off+len,&leng,&res); |
|
|
280 | if (res) |
|
|
281 | goto ERROR5; |
235 | len += leng; |
282 | len += leng; |
236 | psiconv_progress(lev+3,off+len, |
283 | psiconv_progress(lev+3,off+len, |
237 | "Going to read whether this style is built-in"); |
284 | "Going to read whether this style is built-in"); |
238 | temp = psiconv_read_u32(buf,lev+2,off+len); |
285 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
286 | if (res) |
|
|
287 | goto ERROR6; |
|
|
288 | |
239 | if (temp == PSICONV_ID_STYLE_BUILT_IN) { |
289 | if (temp == PSICONV_ID_STYLE_BUILT_IN) { |
240 | style->built_in = psiconv_bool_true; |
290 | style->built_in = psiconv_bool_true; |
241 | psiconv_debug(lev+3,off+len,"Built-in style"); |
291 | psiconv_debug(lev+3,off+len,"Built-in style"); |
242 | } else if (temp == PSICONV_ID_STYLE_REMOVABLE) { |
292 | } else if (temp == PSICONV_ID_STYLE_REMOVABLE) { |
243 | style->built_in = psiconv_bool_false; |
293 | style->built_in = psiconv_bool_false; |
244 | psiconv_debug(lev+3,off+len,"Removable style"); |
294 | psiconv_debug(lev+3,off+len,"Removable style"); |
245 | } else { |
295 | } else { |
246 | psiconv_warn(lev+3,off+len,"Word styles section unknown style id"); |
296 | psiconv_warn(lev+3,off+len, |
|
|
297 | "Word styles section unknown style id (treated as built-in)"); |
247 | psiconv_debug(lev+3,off+len,"Unknown id: %08x",temp); |
298 | psiconv_debug(lev+3,off+len,"Unknown id: %08x",temp); |
248 | style->built_in = psiconv_bool_false; |
299 | style->built_in = psiconv_bool_false; |
249 | res = -1; |
|
|
250 | } |
300 | } |
251 | len += 4; |
301 | len += 4; |
252 | psiconv_progress(lev+3,off+len,"Going to read outline level"); |
302 | psiconv_progress(lev+3,off+len,"Going to read outline level"); |
253 | style->outline_level = psiconv_read_u32(buf,lev+3,off+len); |
303 | style->outline_level = psiconv_read_u32(buf,lev+3,off+len,&res); |
|
|
304 | if (res) |
|
|
305 | goto ERROR6; |
254 | psiconv_debug(lev+3,off+len,"Outline Level: %08x", style->outline_level); |
306 | psiconv_debug(lev+3,off+len,"Outline Level: %08x", style->outline_level); |
255 | len += 4; |
307 | len += 4; |
256 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
308 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
257 | style->character = psiconv_basic_character_layout(); |
309 | if (!(style->character = psiconv_basic_character_layout())) |
|
|
310 | goto ERROR6; |
258 | res |= psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
311 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
259 | style->character); |
312 | style->character))) |
|
|
313 | goto ERROR7; |
260 | len += leng; |
314 | len += leng; |
261 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
315 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
262 | style->paragraph = psiconv_basic_paragraph_layout(); |
316 | if (!(style->paragraph = psiconv_basic_paragraph_layout())) |
|
|
317 | goto ERROR7; |
263 | res |= psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
318 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
264 | style->paragraph); |
319 | style->paragraph))) |
|
|
320 | goto ERROR8; |
265 | len += leng; |
321 | len += leng; |
266 | } |
322 | } |
267 | |
323 | |
268 | if (length) |
324 | if (length) |
269 | *length = len; |
325 | *length = len; |
270 | |
326 | |
271 | psiconv_progress(lev,off+len-1, |
327 | psiconv_progress(lev,off+len-1, |
272 | "End of word styles section (total length: %08x)", len); |
328 | "End of word styles section (total length: %08x)", len); |
273 | |
329 | |
274 | return res; |
330 | return res; |
|
|
331 | |
|
|
332 | |
|
|
333 | ERROR3_2: |
|
|
334 | free(style); |
|
|
335 | ERROR3_1: |
|
|
336 | psiconv_list_free((*result)->styles); |
|
|
337 | goto ERROR3; |
|
|
338 | |
|
|
339 | ERROR2_3: |
|
|
340 | psiconv_free_character_layout(style->character); |
|
|
341 | ERROR2_2: |
|
|
342 | psiconv_free_paragraph_layout(style->paragraph); |
|
|
343 | ERROR2_1: |
|
|
344 | free (style); |
|
|
345 | goto ERROR2; |
|
|
346 | |
|
|
347 | ERROR8: |
|
|
348 | psiconv_free_paragraph_layout(style->paragraph); |
|
|
349 | ERROR7: |
|
|
350 | psiconv_free_character_layout(style->character); |
|
|
351 | ERROR6: |
|
|
352 | free(style->name); |
|
|
353 | ERROR5: |
|
|
354 | for (j = 0; j < i ;j++) { |
|
|
355 | if (!(style = psiconv_list_get((*result)->styles,j))) { |
|
|
356 | psiconv_warn(lev+1,off,"Massive memory corruption"); |
|
|
357 | goto ERROR4; |
|
|
358 | } |
|
|
359 | psiconv_free_character_layout(style->character); |
|
|
360 | psiconv_free_paragraph_layout(style->paragraph); |
|
|
361 | free(style->name); |
|
|
362 | } |
|
|
363 | ERROR4: |
|
|
364 | psiconv_list_free((*result)->styles); |
|
|
365 | ERROR3: |
|
|
366 | psiconv_free_word_style((*result)->normal); |
|
|
367 | ERROR2: |
|
|
368 | free (*result); |
|
|
369 | ERROR1: |
|
|
370 | psiconv_warn(lev+1,off,"Reading of Word Status Section failed"); |
|
|
371 | if (length) |
|
|
372 | *length = 0; |
|
|
373 | if (!res) |
|
|
374 | return -PSICONV_E_NOMEM; |
|
|
375 | else |
|
|
376 | return res; |
275 | } |
377 | } |
276 | |
378 | |
277 | |
379 | |
|
|
380 | |