… | |
… | |
63 | res = psiconv_parse_texted_file(buf,lev+2,leng, |
63 | res = psiconv_parse_texted_file(buf,lev+2,leng, |
64 | (psiconv_texted_f *)(&((*result)->file))); |
64 | (psiconv_texted_f *)(&((*result)->file))); |
65 | else if ((*result)->type == psiconv_mbm_file) |
65 | else if ((*result)->type == psiconv_mbm_file) |
66 | res = psiconv_parse_mbm_file(buf,lev+2,leng, |
66 | res = psiconv_parse_mbm_file(buf,lev+2,leng, |
67 | (psiconv_mbm_f *)(&((*result)->file))); |
67 | (psiconv_mbm_f *)(&((*result)->file))); |
|
|
68 | else if ((*result)->type == psiconv_sketch_file) |
|
|
69 | res = psiconv_parse_sketch_file(buf,lev+2,leng, |
|
|
70 | (psiconv_sketch_f *)(&((*result)->file))); |
68 | else { |
71 | else { |
69 | psiconv_warn(lev+1,off,"Can't parse this file yet!"); |
72 | psiconv_warn(lev+1,off,"Can't parse this file yet!"); |
70 | (*result)->file = NULL; |
73 | (*result)->file = NULL; |
71 | } |
74 | } |
72 | res = -1; |
75 | res = -1; |
… | |
… | |
105 | |
108 | |
106 | psiconv_free_mbm_jumptable_section(table); |
109 | psiconv_free_mbm_jumptable_section(table); |
107 | psiconv_progress(lev+1,off,"End of mbm file"); |
110 | psiconv_progress(lev+1,off,"End of mbm file"); |
108 | return res; |
111 | return res; |
109 | } |
112 | } |
|
|
113 | |
|
|
114 | int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev, |
|
|
115 | psiconv_u32 off, |
|
|
116 | psiconv_sketch_f *result) |
|
|
117 | { |
|
|
118 | psiconv_section_table_section table; |
|
|
119 | psiconv_application_id_section appl_id; |
|
|
120 | psiconv_u32 applid_sec = 0; |
|
|
121 | psiconv_u32 sketch_sec = 0; |
|
|
122 | psiconv_u32 sto; |
|
|
123 | psiconv_section_table_entry entry; |
|
|
124 | int i; |
|
|
125 | int res=0; |
|
|
126 | char *temp_str; |
|
|
127 | |
|
|
128 | psiconv_progress(lev+1,off,"Going to read a sketch file"); |
|
|
129 | *result = malloc(sizeof(**result)); |
|
|
130 | |
|
|
131 | psiconv_progress(lev+2,off, |
|
|
132 | "Going to read the offset of the section table section"); |
|
|
133 | sto = psiconv_read_u32(buf,lev+2,off); |
|
|
134 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
|
|
135 | |
|
|
136 | psiconv_progress(lev+2,sto, "Going to read the section table section"); |
|
|
137 | res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table); |
|
|
138 | |
|
|
139 | for (i = 0; i < psiconv_list_length(table); i ++) { |
|
|
140 | psiconv_progress(lev+2,sto, "Going to read entry %d",i); |
|
|
141 | entry = psiconv_list_get(table,i); |
|
|
142 | if (entry->id == PSICONV_ID_APPL_ID_SECTION) { |
|
|
143 | applid_sec = entry->offset; |
|
|
144 | psiconv_debug(lev+3,sto, |
|
|
145 | "Found the Application ID section at %08x",applid_sec); |
|
|
146 | } else if (entry->id == PSICONV_ID_SKETCH_SECTION) { |
|
|
147 | sketch_sec = entry->offset; |
|
|
148 | psiconv_debug(lev+3,sto, |
|
|
149 | "Found the Sketch section at %08x",sketch_sec); |
|
|
150 | } else { |
|
|
151 | psiconv_warn(lev+3,sto, |
|
|
152 | "Found unknown section in the Section Table"); |
|
|
153 | psiconv_debug(lev+3,sto, |
|
|
154 | "Section ID %08x, offset %08x",entry->id,entry->offset); |
|
|
155 | res = -1; |
|
|
156 | } |
|
|
157 | } |
|
|
158 | |
|
|
159 | psiconv_progress(lev+2,sto, "Looking for the Application ID section"); |
|
|
160 | if (! applid_sec) { |
|
|
161 | psiconv_warn(lev+2,sto, |
|
|
162 | "Application ID section not found in the section table"); |
|
|
163 | res = -1; |
|
|
164 | } else { |
|
|
165 | psiconv_debug(lev+2,sto, |
|
|
166 | "Application ID section at offset %08x",applid_sec); |
|
|
167 | res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL, |
|
|
168 | &appl_id); |
|
|
169 | } |
|
|
170 | if ((appl_id->id != PSICONV_ID_SKETCH) || |
|
|
171 | strcmp(appl_id->name,"Paint.app")) { |
|
|
172 | psiconv_warn(lev+2,applid_sec, |
|
|
173 | "Application ID section contains unexpected data"); |
|
|
174 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
|
|
175 | PSICONV_ID_SKETCH,appl_id->id); |
|
|
176 | temp_str = psiconv_make_printable(appl_id->name); |
|
|
177 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
|
|
178 | "Paint.app",temp_str); |
|
|
179 | free(temp_str); |
|
|
180 | } |
|
|
181 | |
|
|
182 | psiconv_progress(lev+2,sto, "Looking for the Sketch section"); |
|
|
183 | if (! sketch_sec) { |
|
|
184 | psiconv_warn(lev+2,sto, |
|
|
185 | "Sketch section not found in the section table"); |
|
|
186 | res = -1; |
|
|
187 | } else { |
|
|
188 | psiconv_debug(lev+2,sto, |
|
|
189 | "Sketch section at offset %08x",applid_sec); |
|
|
190 | res |= psiconv_parse_sketch_section(buf,lev+2,sketch_sec,NULL,0, |
|
|
191 | &(*result)->sketch_sec); |
|
|
192 | } |
|
|
193 | |
|
|
194 | psiconv_free_application_id_section(appl_id); |
|
|
195 | psiconv_free_section_table_section(table); |
|
|
196 | |
|
|
197 | psiconv_progress(lev+1,off,"End of word file"); |
|
|
198 | return res; |
|
|
199 | } |
|
|
200 | |
|
|
201 | |
110 | |
202 | |
111 | int psiconv_parse_texted_file(const psiconv_buffer buf,int lev, |
203 | int psiconv_parse_texted_file(const psiconv_buffer buf,int lev, |
112 | psiconv_u32 off, |
204 | psiconv_u32 off, |
113 | psiconv_texted_f *result) |
205 | psiconv_texted_f *result) |
114 | { |
206 | { |
… | |
… | |
126 | int i; |
218 | int i; |
127 | |
219 | |
128 | psiconv_progress(lev+1,off,"Going to read a texted file"); |
220 | psiconv_progress(lev+1,off,"Going to read a texted file"); |
129 | *result = malloc(sizeof(**result)); |
221 | *result = malloc(sizeof(**result)); |
130 | |
222 | |
131 | psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); |
223 | psiconv_progress(lev+2,off, |
|
|
224 | "Going to read the offset of the section table section"); |
132 | sto = psiconv_read_u32(buf,lev+2,off); |
225 | sto = psiconv_read_u32(buf,lev+2,off); |
133 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
226 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
134 | |
227 | |
135 | psiconv_progress(lev+2,sto, "Going to read the section table section"); |
228 | psiconv_progress(lev+2,sto, "Going to read the section table section"); |
136 | res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table); |
229 | res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table); |
… | |
… | |
176 | "Application ID section contains unexpected data"); |
269 | "Application ID section contains unexpected data"); |
177 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
270 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
178 | PSICONV_ID_TEXTED,appl_id->id); |
271 | PSICONV_ID_TEXTED,appl_id->id); |
179 | temp_str = psiconv_make_printable(appl_id->name); |
272 | temp_str = psiconv_make_printable(appl_id->name); |
180 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
273 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
181 | PSICONV_ID_TEXTED,temp_str); |
274 | "TextEd.app",temp_str); |
182 | free(temp_str); |
275 | free(temp_str); |
183 | } |
276 | } |
184 | |
277 | |
185 | psiconv_progress(lev+2,sto, |
278 | psiconv_progress(lev+2,sto, |
186 | "Looking for the Page layout section"); |
279 | "Looking for the Page layout section"); |
… | |
… | |
241 | int i; |
334 | int i; |
242 | |
335 | |
243 | psiconv_progress(lev+1,off,"Going to read a word file"); |
336 | psiconv_progress(lev+1,off,"Going to read a word file"); |
244 | *result = malloc(sizeof(**result)); |
337 | *result = malloc(sizeof(**result)); |
245 | |
338 | |
246 | psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); |
339 | psiconv_progress(lev+2,off, |
|
|
340 | "Going to read the offset of the section table section"); |
247 | sto = psiconv_read_u32(buf,lev+2,off); |
341 | sto = psiconv_read_u32(buf,lev+2,off); |
248 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
342 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
249 | |
343 | |
250 | psiconv_progress(lev+2,sto, |
344 | psiconv_progress(lev+2,sto, |
251 | "Going to read the section table section"); |
345 | "Going to read the section table section"); |
… | |
… | |
322 | "Application ID section contains unexpected data"); |
416 | "Application ID section contains unexpected data"); |
323 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
417 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
324 | PSICONV_ID_WORD,appl_id->id); |
418 | PSICONV_ID_WORD,appl_id->id); |
325 | temp_str = psiconv_make_printable(appl_id->name); |
419 | temp_str = psiconv_make_printable(appl_id->name); |
326 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
420 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
327 | PSICONV_ID_WORD,temp_str); |
421 | "Word.app",temp_str); |
328 | free(temp_str); |
422 | free(temp_str); |
329 | } |
423 | } |
330 | |
424 | |
331 | psiconv_progress(lev+2,sto, |
425 | psiconv_progress(lev+2,sto, |
332 | "Looking for the Page layout section"); |
426 | "Looking for the Page layout section"); |