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

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

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

Revision 18 Revision 45
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)));
71 else if ((*result)->type == psiconv_clipart_file)
72 res = psiconv_parse_clipart_file(buf,lev+2,leng,
73 (psiconv_clipart_f *)(&((*result)->file)));
68 else { 74 else {
69 psiconv_warn(lev+1,off,"Can't parse this file yet!"); 75 psiconv_warn(lev+1,off,"Can't parse this file yet!");
70 (*result)->file = NULL; 76 (*result)->file = NULL;
71 } 77 }
72 res = -1; 78 res = -1;
73 79
74 return res; 80 return res;
75} 81}
76 82
83int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev,
84 psiconv_u32 off, psiconv_clipart_f *result)
85{
86 int res=0;
87 int i;
88 psiconv_jumptable_section table;
89 psiconv_clipart_section clipart;
90 psiconv_u32 *entry;
91
92 psiconv_progress(lev+1,off,"Going to read a clipart file");
93 (*result) = malloc(sizeof(**result));
94
95 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
96 res |= psiconv_parse_jumptable_section(buf,lev+2,off, NULL,&table);
97
98 psiconv_progress(lev+2,off,"Going to read the clipart sections");
99 (*result)->sections = psiconv_list_new(sizeof(*clipart));
100 for (i = 0; i < psiconv_list_length(table); i ++) {
101 entry = psiconv_list_get(table,i);
102 psiconv_progress(lev+3,off,"Going to read clipart section %i",i);
103 psiconv_parse_clipart_section(buf,lev+3,*entry,NULL,&clipart);
104 psiconv_list_add((*result)->sections,clipart);
105 }
106
107 psiconv_free_jumptable_section(table);
108 psiconv_progress(lev+1,off,"End of clipart file");
109 return res;
110}
111
77int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 112int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off,
78 psiconv_mbm_f *result) 113 psiconv_mbm_f *result)
79{ 114{
80 int res=0; 115 int res=0;
81 int i; 116 int i;
82 psiconv_mbm_jumptable_section table; 117 psiconv_jumptable_section table;
83 psiconv_paint_data_section paint; 118 psiconv_paint_data_section paint;
84 psiconv_u32 *entry; 119 psiconv_u32 *entry;
85 psiconv_u32 sto; 120 psiconv_u32 sto;
86 121
87 psiconv_progress(lev+1,off,"Going to read a mbm file"); 122 psiconv_progress(lev+1,off,"Going to read a mbm file");
90 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); 125 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable");
91 sto = psiconv_read_u32(buf,lev+2,off); 126 sto = psiconv_read_u32(buf,lev+2,off);
92 psiconv_debug(lev+2,off,"Offset: %08x",sto); 127 psiconv_debug(lev+2,off,"Offset: %08x",sto);
93 128
94 psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); 129 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
95 res |= psiconv_parse_mbm_jumptable_section(buf,lev+2,sto, NULL,&table); 130 res |= psiconv_parse_jumptable_section(buf,lev+2,sto, NULL,&table);
96 131
97 psiconv_progress(lev+2,off,"Going to read the picture sections"); 132 psiconv_progress(lev+2,off,"Going to read the picture sections");
98 (*result)->sections = psiconv_list_new(sizeof(*paint)); 133 (*result)->sections = psiconv_list_new(sizeof(*paint));
99 for (i = 0; i < psiconv_list_length(table); i ++) { 134 for (i = 0; i < psiconv_list_length(table); i ++) {
100 entry = psiconv_list_get(table,i); 135 entry = psiconv_list_get(table,i);
101 psiconv_progress(lev+3,off,"Going to read picture section %i",i); 136 psiconv_progress(lev+3,off,"Going to read picture section %i",i);
102 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint); 137 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,0,&paint);
103 psiconv_list_add((*result)->sections,paint); 138 psiconv_list_add((*result)->sections,paint);
104 } 139 }
105 140
106 psiconv_free_mbm_jumptable_section(table); 141 psiconv_free_jumptable_section(table);
107 psiconv_progress(lev+1,off,"End of mbm file"); 142 psiconv_progress(lev+1,off,"End of mbm file");
108 return res; 143 return res;
109} 144}
145
146int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev,
147 psiconv_u32 off,
148 psiconv_sketch_f *result)
149{
150 psiconv_section_table_section table;
151 psiconv_application_id_section appl_id;
152 psiconv_u32 applid_sec = 0;
153 psiconv_u32 sketch_sec = 0;
154 psiconv_u32 sto;
155 psiconv_section_table_entry entry;
156 int i;
157 int res=0;
158 char *temp_str;
159
160 psiconv_progress(lev+1,off,"Going to read a sketch file");
161 *result = malloc(sizeof(**result));
162
163 psiconv_progress(lev+2,off,
164 "Going to read the offset of the section table section");
165 sto = psiconv_read_u32(buf,lev+2,off);
166 psiconv_debug(lev+2,off,"Offset: %08x",sto);
167
168 psiconv_progress(lev+2,sto, "Going to read the section table section");
169 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
170
171 for (i = 0; i < psiconv_list_length(table); i ++) {
172 psiconv_progress(lev+2,sto, "Going to read entry %d",i);
173 entry = psiconv_list_get(table,i);
174 if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
175 applid_sec = entry->offset;
176 psiconv_debug(lev+3,sto,
177 "Found the Application ID section at %08x",applid_sec);
178 } else if (entry->id == PSICONV_ID_SKETCH_SECTION) {
179 sketch_sec = entry->offset;
180 psiconv_debug(lev+3,sto,
181 "Found the Sketch section at %08x",sketch_sec);
182 } else {
183 psiconv_warn(lev+3,sto,
184 "Found unknown section in the Section Table");
185 psiconv_debug(lev+3,sto,
186 "Section ID %08x, offset %08x",entry->id,entry->offset);
187 res = -1;
188 }
189 }
190
191 psiconv_progress(lev+2,sto, "Looking for the Application ID section");
192 if (! applid_sec) {
193 psiconv_warn(lev+2,sto,
194 "Application ID section not found in the section table");
195 res = -1;
196 } else {
197 psiconv_debug(lev+2,sto,
198 "Application ID section at offset %08x",applid_sec);
199 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL,
200 &appl_id);
201 }
202 if ((appl_id->id != PSICONV_ID_SKETCH) ||
203 strcmp(appl_id->name,"Paint.app")) {
204 psiconv_warn(lev+2,applid_sec,
205 "Application ID section contains unexpected data");
206 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
207 PSICONV_ID_SKETCH,appl_id->id);
208 temp_str = psiconv_make_printable(appl_id->name);
209 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
210 "Paint.app",temp_str);
211 free(temp_str);
212 }
213
214 psiconv_progress(lev+2,sto, "Looking for the Sketch section");
215 if (! sketch_sec) {
216 psiconv_warn(lev+2,sto,
217 "Sketch section not found in the section table");
218 res = -1;
219 } else {
220 psiconv_debug(lev+2,sto,
221 "Sketch section at offset %08x",applid_sec);
222 res |= psiconv_parse_sketch_section(buf,lev+2,sketch_sec,NULL,0,
223 &(*result)->sketch_sec);
224 }
225
226 psiconv_free_application_id_section(appl_id);
227 psiconv_free_section_table_section(table);
228
229 psiconv_progress(lev+1,off,"End of word file");
230 return res;
231}
232
233
110 234
111int psiconv_parse_texted_file(const psiconv_buffer buf,int lev, 235int psiconv_parse_texted_file(const psiconv_buffer buf,int lev,
112 psiconv_u32 off, 236 psiconv_u32 off,
113 psiconv_texted_f *result) 237 psiconv_texted_f *result)
114{ 238{
126 int i; 250 int i;
127 251
128 psiconv_progress(lev+1,off,"Going to read a texted file"); 252 psiconv_progress(lev+1,off,"Going to read a texted file");
129 *result = malloc(sizeof(**result)); 253 *result = malloc(sizeof(**result));
130 254
131 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); 255 psiconv_progress(lev+2,off,
256 "Going to read the offset of the section table section");
132 sto = psiconv_read_u32(buf,lev+2,off); 257 sto = psiconv_read_u32(buf,lev+2,off);
133 psiconv_debug(lev+2,off,"Offset: %08x",sto); 258 psiconv_debug(lev+2,off,"Offset: %08x",sto);
134 259
135 psiconv_progress(lev+2,sto, "Going to read the section table section"); 260 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); 261 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
176 "Application ID section contains unexpected data"); 301 "Application ID section contains unexpected data");
177 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 302 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
178 PSICONV_ID_TEXTED,appl_id->id); 303 PSICONV_ID_TEXTED,appl_id->id);
179 temp_str = psiconv_make_printable(appl_id->name); 304 temp_str = psiconv_make_printable(appl_id->name);
180 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 305 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
181 PSICONV_ID_TEXTED,temp_str); 306 "TextEd.app",temp_str);
182 free(temp_str); 307 free(temp_str);
183 } 308 }
184 309
185 psiconv_progress(lev+2,sto, 310 psiconv_progress(lev+2,sto,
186 "Looking for the Page layout section"); 311 "Looking for the Page layout section");
241 int i; 366 int i;
242 367
243 psiconv_progress(lev+1,off,"Going to read a word file"); 368 psiconv_progress(lev+1,off,"Going to read a word file");
244 *result = malloc(sizeof(**result)); 369 *result = malloc(sizeof(**result));
245 370
246 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); 371 psiconv_progress(lev+2,off,
372 "Going to read the offset of the section table section");
247 sto = psiconv_read_u32(buf,lev+2,off); 373 sto = psiconv_read_u32(buf,lev+2,off);
248 psiconv_debug(lev+2,off,"Offset: %08x",sto); 374 psiconv_debug(lev+2,off,"Offset: %08x",sto);
249 375
250 psiconv_progress(lev+2,sto, 376 psiconv_progress(lev+2,sto,
251 "Going to read the section table section"); 377 "Going to read the section table section");
322 "Application ID section contains unexpected data"); 448 "Application ID section contains unexpected data");
323 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 449 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
324 PSICONV_ID_WORD,appl_id->id); 450 PSICONV_ID_WORD,appl_id->id);
325 temp_str = psiconv_make_printable(appl_id->name); 451 temp_str = psiconv_make_printable(appl_id->name);
326 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 452 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
327 PSICONV_ID_WORD,temp_str); 453 "Word.app",temp_str);
328 free(temp_str); 454 free(temp_str);
329 } 455 }
330 456
331 psiconv_progress(lev+2,sto, 457 psiconv_progress(lev+2,sto,
332 "Looking for the Page layout section"); 458 "Looking for the Page layout section");

Legend:
Removed from v.18  
changed lines
  Added in v.45

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