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

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

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