/[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 41
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;
81}
82
83int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev,
84 psiconv_u32 off, psiconv_clipart_f *result)
85{
86 (*result) = malloc(sizeof(**result));
87 return 0;
75} 88}
76 89
77int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 90int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off,
78 psiconv_mbm_f *result) 91 psiconv_mbm_f *result)
79{ 92{
105 118
106 psiconv_free_mbm_jumptable_section(table); 119 psiconv_free_mbm_jumptable_section(table);
107 psiconv_progress(lev+1,off,"End of mbm file"); 120 psiconv_progress(lev+1,off,"End of mbm file");
108 return res; 121 return res;
109} 122}
123
124int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev,
125 psiconv_u32 off,
126 psiconv_sketch_f *result)
127{
128 psiconv_section_table_section table;
129 psiconv_application_id_section appl_id;
130 psiconv_u32 applid_sec = 0;
131 psiconv_u32 sketch_sec = 0;
132 psiconv_u32 sto;
133 psiconv_section_table_entry entry;
134 int i;
135 int res=0;
136 char *temp_str;
137
138 psiconv_progress(lev+1,off,"Going to read a sketch file");
139 *result = malloc(sizeof(**result));
140
141 psiconv_progress(lev+2,off,
142 "Going to read the offset of the section table section");
143 sto = psiconv_read_u32(buf,lev+2,off);
144 psiconv_debug(lev+2,off,"Offset: %08x",sto);
145
146 psiconv_progress(lev+2,sto, "Going to read the section table section");
147 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
148
149 for (i = 0; i < psiconv_list_length(table); i ++) {
150 psiconv_progress(lev+2,sto, "Going to read entry %d",i);
151 entry = psiconv_list_get(table,i);
152 if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
153 applid_sec = entry->offset;
154 psiconv_debug(lev+3,sto,
155 "Found the Application ID section at %08x",applid_sec);
156 } else if (entry->id == PSICONV_ID_SKETCH_SECTION) {
157 sketch_sec = entry->offset;
158 psiconv_debug(lev+3,sto,
159 "Found the Sketch section at %08x",sketch_sec);
160 } else {
161 psiconv_warn(lev+3,sto,
162 "Found unknown section in the Section Table");
163 psiconv_debug(lev+3,sto,
164 "Section ID %08x, offset %08x",entry->id,entry->offset);
165 res = -1;
166 }
167 }
168
169 psiconv_progress(lev+2,sto, "Looking for the Application ID section");
170 if (! applid_sec) {
171 psiconv_warn(lev+2,sto,
172 "Application ID section not found in the section table");
173 res = -1;
174 } else {
175 psiconv_debug(lev+2,sto,
176 "Application ID section at offset %08x",applid_sec);
177 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL,
178 &appl_id);
179 }
180 if ((appl_id->id != PSICONV_ID_SKETCH) ||
181 strcmp(appl_id->name,"Paint.app")) {
182 psiconv_warn(lev+2,applid_sec,
183 "Application ID section contains unexpected data");
184 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
185 PSICONV_ID_SKETCH,appl_id->id);
186 temp_str = psiconv_make_printable(appl_id->name);
187 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
188 "Paint.app",temp_str);
189 free(temp_str);
190 }
191
192 psiconv_progress(lev+2,sto, "Looking for the Sketch section");
193 if (! sketch_sec) {
194 psiconv_warn(lev+2,sto,
195 "Sketch section not found in the section table");
196 res = -1;
197 } else {
198 psiconv_debug(lev+2,sto,
199 "Sketch section at offset %08x",applid_sec);
200 res |= psiconv_parse_sketch_section(buf,lev+2,sketch_sec,NULL,0,
201 &(*result)->sketch_sec);
202 }
203
204 psiconv_free_application_id_section(appl_id);
205 psiconv_free_section_table_section(table);
206
207 psiconv_progress(lev+1,off,"End of word file");
208 return res;
209}
210
211
110 212
111int psiconv_parse_texted_file(const psiconv_buffer buf,int lev, 213int psiconv_parse_texted_file(const psiconv_buffer buf,int lev,
112 psiconv_u32 off, 214 psiconv_u32 off,
113 psiconv_texted_f *result) 215 psiconv_texted_f *result)
114{ 216{
126 int i; 228 int i;
127 229
128 psiconv_progress(lev+1,off,"Going to read a texted file"); 230 psiconv_progress(lev+1,off,"Going to read a texted file");
129 *result = malloc(sizeof(**result)); 231 *result = malloc(sizeof(**result));
130 232
131 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); 233 psiconv_progress(lev+2,off,
234 "Going to read the offset of the section table section");
132 sto = psiconv_read_u32(buf,lev+2,off); 235 sto = psiconv_read_u32(buf,lev+2,off);
133 psiconv_debug(lev+2,off,"Offset: %08x",sto); 236 psiconv_debug(lev+2,off,"Offset: %08x",sto);
134 237
135 psiconv_progress(lev+2,sto, "Going to read the section table section"); 238 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); 239 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
176 "Application ID section contains unexpected data"); 279 "Application ID section contains unexpected data");
177 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 280 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
178 PSICONV_ID_TEXTED,appl_id->id); 281 PSICONV_ID_TEXTED,appl_id->id);
179 temp_str = psiconv_make_printable(appl_id->name); 282 temp_str = psiconv_make_printable(appl_id->name);
180 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 283 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
181 PSICONV_ID_TEXTED,temp_str); 284 "TextEd.app",temp_str);
182 free(temp_str); 285 free(temp_str);
183 } 286 }
184 287
185 psiconv_progress(lev+2,sto, 288 psiconv_progress(lev+2,sto,
186 "Looking for the Page layout section"); 289 "Looking for the Page layout section");
241 int i; 344 int i;
242 345
243 psiconv_progress(lev+1,off,"Going to read a word file"); 346 psiconv_progress(lev+1,off,"Going to read a word file");
244 *result = malloc(sizeof(**result)); 347 *result = malloc(sizeof(**result));
245 348
246 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); 349 psiconv_progress(lev+2,off,
350 "Going to read the offset of the section table section");
247 sto = psiconv_read_u32(buf,lev+2,off); 351 sto = psiconv_read_u32(buf,lev+2,off);
248 psiconv_debug(lev+2,off,"Offset: %08x",sto); 352 psiconv_debug(lev+2,off,"Offset: %08x",sto);
249 353
250 psiconv_progress(lev+2,sto, 354 psiconv_progress(lev+2,sto,
251 "Going to read the section table section"); 355 "Going to read the section table section");
322 "Application ID section contains unexpected data"); 426 "Application ID section contains unexpected data");
323 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 427 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
324 PSICONV_ID_WORD,appl_id->id); 428 PSICONV_ID_WORD,appl_id->id);
325 temp_str = psiconv_make_printable(appl_id->name); 429 temp_str = psiconv_make_printable(appl_id->name);
326 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 430 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
327 PSICONV_ID_WORD,temp_str); 431 "Word.app",temp_str);
328 free(temp_str); 432 free(temp_str);
329 } 433 }
330 434
331 psiconv_progress(lev+2,sto, 435 psiconv_progress(lev+2,sto,
332 "Looking for the Page layout section"); 436 "Looking for the Page layout section");

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

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