/[public]/psiconv/trunk/lib/psiconv/parse_word.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_word.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.82  
changed lines
  Added in v.188

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