/[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 170 Revision 237
1/* 1/*
2 parse_driver.c - Part of psiconv, a PSION 5 file formats converter 2 parse_driver.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25 25
26#include "parse.h" 26#include "parse.h"
27#include "parse_routines.h" 27#include "parse_routines.h"
28#include "unicode.h"
28 29
29#ifdef DMALLOC 30#ifdef DMALLOC
30#include <dmalloc.h> 31#include <dmalloc.h>
31#endif 32#endif
32 33
34/* Compare whether application id names match.
35 Sought must be lower case; the comparison is case insensitive */
36static psiconv_bool_t applid_matches(psiconv_string_t found,
37 const char *sought)
38{
39 int i;
40 if (psiconv_unicode_strlen(found) != strlen(sought))
41 return psiconv_bool_false;
42 for (i = 0; i < strlen(sought); i++)
43 if ((found[i] != sought[i]) &&
44 ((sought[i] < 'a') || (sought[i] > 'z') ||
45 (found[i] != sought[i] + 'A' - 'a')))
46 return psiconv_bool_false;
47 return psiconv_bool_true;
48}
33 49
34psiconv_file_type_t psiconv_file_type(const psiconv_config config, 50psiconv_file_type_t psiconv_file_type(const psiconv_config config,
35 psiconv_buffer buf,int *length, 51 psiconv_buffer buf,int *length,
36 psiconv_header_section *result) 52 psiconv_header_section *result)
37{ 53{
93 return 0; 109 return 0;
94 110
95ERROR2: 111ERROR2:
96 free(*result); 112 free(*result);
97ERROR1: 113ERROR1:
98 psiconv_warn(config,lev+1,off,"Reading of Psion File failed"); 114 psiconv_error(config,lev+1,off,"Reading of Psion File failed");
99 if (res == 0) 115 if (res == 0)
100 return -PSICONV_E_NOMEM; 116 return -PSICONV_E_NOMEM;
101 else 117 else
102 return res; 118 return res;
103} 119}
129 psiconv_progress(config,lev+3,off,"Going to read clipart section %i",i); 145 psiconv_progress(config,lev+3,off,"Going to read clipart section %i",i);
130 if ((res = psiconv_parse_clipart_section(config,buf,lev+3,*entry,NULL,&clipart))) 146 if ((res = psiconv_parse_clipart_section(config,buf,lev+3,*entry,NULL,&clipart)))
131 goto ERROR4; 147 goto ERROR4;
132 if ((res = psiconv_list_add((*result)->sections,clipart))) 148 if ((res = psiconv_list_add((*result)->sections,clipart)))
133 goto ERROR5; 149 goto ERROR5;
150 free(clipart);
134 } 151 }
135 152
136 psiconv_free_jumptable_section(table); 153 psiconv_free_jumptable_section(table);
137 psiconv_progress(config,lev+1,off,"End of clipart file"); 154 psiconv_progress(config,lev+1,off,"End of clipart file");
138 return res; 155 return res;
139ERROR5: 156ERROR5:
140 psiconv_free_clipart_section(clipart); 157 psiconv_free_clipart_section(clipart);
141ERROR4: 158ERROR4:
142 for (i = 0; i < psiconv_list_length((*result)->sections); i++) { 159 for (i = 0; i < psiconv_list_length((*result)->sections); i++) {
143 if (!(clipart = psiconv_list_get((*result)->sections,i))) { 160 if (!(clipart = psiconv_list_get((*result)->sections,i))) {
144 psiconv_warn(config,lev+1,off,"Massive memory corruption"); 161 psiconv_error(config,lev+1,off,"Data structure corruption");
145 goto ERROR3; 162 goto ERROR3;
146 } 163 }
147 psiconv_free_clipart_section(clipart); 164 psiconv_free_clipart_section(clipart);
148 } 165 }
149 psiconv_list_free((*result)->sections); 166 psiconv_list_free((*result)->sections);
150ERROR3: 167ERROR3:
151 psiconv_free_jumptable_section(table); 168 psiconv_free_jumptable_section(table);
152ERROR2: 169ERROR2:
153 free(*result); 170 free(*result);
154ERROR1: 171ERROR1:
155 psiconv_warn(config,lev+1,off,"Reading of Clipart File failed"); 172 psiconv_error(config,lev+1,off,"Reading of Clipart File failed");
156 if (res == 0) 173 if (res == 0)
157 return -PSICONV_E_NOMEM; 174 return -PSICONV_E_NOMEM;
158 else 175 else
159 return res; 176 return res;
160} 177}
194 if ((res = psiconv_parse_paint_data_section(config,buf,lev+3,*entry,NULL, 211 if ((res = psiconv_parse_paint_data_section(config,buf,lev+3,*entry,NULL,
195 0,&paint))) 212 0,&paint)))
196 goto ERROR4; 213 goto ERROR4;
197 if ((res = psiconv_list_add((*result)->sections,paint))) 214 if ((res = psiconv_list_add((*result)->sections,paint)))
198 goto ERROR5; 215 goto ERROR5;
216 free(paint);
199 } 217 }
200 218
201 psiconv_free_jumptable_section(table); 219 psiconv_free_jumptable_section(table);
202 psiconv_progress(config,lev+1,off,"End of mbm file"); 220 psiconv_progress(config,lev+1,off,"End of mbm file");
203 return 0; 221 return 0;
204ERROR5: 222ERROR5:
205 psiconv_free_paint_data_section(paint); 223 psiconv_free_paint_data_section(paint);
206ERROR4: 224ERROR4:
207 for (i = 0; i < psiconv_list_length((*result)->sections); i++) { 225 for (i = 0; i < psiconv_list_length((*result)->sections); i++) {
208 if (!(paint = psiconv_list_get((*result)->sections,i))) { 226 if (!(paint = psiconv_list_get((*result)->sections,i))) {
209 psiconv_warn(config,lev+1,off,"Massive memory corruption"); 227 psiconv_error(config,lev+1,off,"Data structure corruption");
210 goto ERROR3; 228 goto ERROR3;
211 } 229 }
212 psiconv_free_paint_data_section(paint); 230 psiconv_free_paint_data_section(paint);
213 } 231 }
214 psiconv_list_free((*result)->sections); 232 psiconv_list_free((*result)->sections);
215ERROR3: 233ERROR3:
216 psiconv_free_jumptable_section(table); 234 psiconv_free_jumptable_section(table);
217ERROR2: 235ERROR2:
218 free(*result); 236 free(*result);
219ERROR1: 237ERROR1:
220 psiconv_warn(config,lev+1,off,"Reading of MBM File failed"); 238 psiconv_error(config,lev+1,off,"Reading of MBM File failed");
221 if (res == 0) 239 if (res == 0)
222 return -PSICONV_E_NOMEM; 240 return -PSICONV_E_NOMEM;
223 else 241 else
224 return res; 242 return res;
225} 243}
274 } 292 }
275 } 293 }
276 294
277 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section"); 295 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
278 if (! applid_sec) { 296 if (! applid_sec) {
279 psiconv_warn(config,lev+2,sto, 297 psiconv_error(config,lev+2,sto,
280 "Application ID section not found in the section table"); 298 "Application ID section not found in the section table");
281 res = -PSICONV_E_PARSE; 299 res = -PSICONV_E_PARSE;
282 goto ERROR3; 300 goto ERROR3;
283 } else { 301 } else {
284 psiconv_debug(config,lev+2,sto, 302 psiconv_debug(config,lev+2,sto,
286 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL, 304 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
287 &appl_id))) 305 &appl_id)))
288 goto ERROR3; 306 goto ERROR3;
289 } 307 }
290 if ((appl_id->id != PSICONV_ID_SKETCH) || 308 if ((appl_id->id != PSICONV_ID_SKETCH) ||
291 strcmp(appl_id->name,"Paint.app")) { 309 !applid_matches(appl_id->name,"paint.app")) {
292 psiconv_warn(config,lev+2,applid_sec, 310 psiconv_warn(config,lev+2,applid_sec,
293 "Application ID section contains unexpected data"); 311 "Application ID section contains unexpected data");
294 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", 312 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
295 PSICONV_ID_SKETCH,appl_id->id); 313 PSICONV_ID_SKETCH,appl_id->id);
296 if (!(temp_str = psiconv_make_printable(appl_id->name))) 314 if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
297 goto ERROR4; 315 goto ERROR4;
298 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found", 316 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
299 "Paint.app",temp_str); 317 "Paint.app",temp_str);
300 free(temp_str); 318 free(temp_str);
301 res = -PSICONV_E_PARSE; 319 res = -PSICONV_E_PARSE;
325ERROR3: 343ERROR3:
326 free(table); 344 free(table);
327ERROR2: 345ERROR2:
328 free(*result); 346 free(*result);
329ERROR1: 347ERROR1:
330 psiconv_warn(config,lev+1,off,"Reading of Sketch File failed"); 348 psiconv_error(config,lev+1,off,"Reading of Sketch File failed");
331 if (res == 0) 349 if (res == 0)
332 return -PSICONV_E_NOMEM; 350 return -PSICONV_E_NOMEM;
333 else 351 else
334 return res; 352 return res;
335} 353}
392 } 410 }
393 } 411 }
394 412
395 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section"); 413 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
396 if (! applid_sec) { 414 if (! applid_sec) {
397 psiconv_warn(config,lev+2,sto, 415 psiconv_error(config,lev+2,sto,
398 "Application ID section not found in the section table"); 416 "Application ID section not found in the section table");
399 res = -PSICONV_E_PARSE; 417 res = -PSICONV_E_PARSE;
400 goto ERROR3; 418 goto ERROR3;
401 } else { 419 } else {
402 psiconv_debug(config,lev+2,sto, 420 psiconv_debug(config,lev+2,sto,
403 "Application ID section at offset %08x",applid_sec); 421 "Application ID section at offset %08x",applid_sec);
404 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL, 422 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
405 &appl_id))) 423 &appl_id)))
406 goto ERROR3; 424 goto ERROR3;
407 } 425 }
426
408 if ((appl_id->id != PSICONV_ID_TEXTED) || 427 if ((appl_id->id != PSICONV_ID_TEXTED) ||
409 strcmp(appl_id->name,"TextEd.app")) { 428 !applid_matches(appl_id->name,"texted.app")) {
410 psiconv_warn(config,lev+2,applid_sec, 429 psiconv_warn(config,lev+2,applid_sec,
411 "Application ID section contains unexpected data"); 430 "Application ID section contains unexpected data");
412 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", 431 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
413 PSICONV_ID_TEXTED,appl_id->id); 432 PSICONV_ID_TEXTED,appl_id->id);
414 if (!(temp_str = psiconv_make_printable(appl_id->name))) 433 if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
415 goto ERROR4; 434 goto ERROR4;
416 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found", 435 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
417 "TextEd.app",temp_str); 436 "TextEd.app",temp_str);
418 free(temp_str); 437 free(temp_str);
419 res = -PSICONV_E_PARSE; 438 res = -PSICONV_E_PARSE;
421 } 440 }
422 441
423 psiconv_progress(config,lev+2,sto, 442 psiconv_progress(config,lev+2,sto,
424 "Looking for the Page layout section"); 443 "Looking for the Page layout section");
425 if (! page_sec) { 444 if (! page_sec) {
426 psiconv_warn(config,lev+2,sto, 445 psiconv_error(config,lev+2,sto,
427 "Page layout section not found in the section table"); 446 "Page layout section not found in the section table");
428 res = -PSICONV_E_PARSE; 447 res = -PSICONV_E_PARSE;
429 goto ERROR4; 448 goto ERROR4;
430 } else { 449 } else {
431 psiconv_debug(config,lev+2,sto, 450 psiconv_debug(config,lev+2,sto,
441 goto ERROR6; 460 goto ERROR6;
442 461
443 psiconv_progress(config,lev+2,sto, 462 psiconv_progress(config,lev+2,sto,
444 "Looking for the TextEd section"); 463 "Looking for the TextEd section");
445 if (! texted_sec) { 464 if (! texted_sec) {
446 psiconv_warn(config,lev+2,sto, 465 psiconv_error(config,lev+2,sto,
447 "TextEd section not found in the section table"); 466 "TextEd section not found in the section table");
448 res = -PSICONV_E_PARSE; 467 res = -PSICONV_E_PARSE;
449 goto ERROR7; 468 goto ERROR7;
450 } else { 469 } else {
451 psiconv_debug(config,lev+2,sto, "TextEd section at offset %08x",texted_sec); 470 psiconv_debug(config,lev+2,sto, "TextEd section at offset %08x",texted_sec);
474ERROR3: 493ERROR3:
475 psiconv_free_section_table_section(table); 494 psiconv_free_section_table_section(table);
476ERROR2: 495ERROR2:
477 free(*result); 496 free(*result);
478ERROR1: 497ERROR1:
479 psiconv_warn(config,lev+1,off,"Reading of TextEd File failed"); 498 psiconv_error(config,lev+1,off,"Reading of TextEd File failed");
480 if (res == 0) 499 if (res == 0)
481 return -PSICONV_E_NOMEM; 500 return -PSICONV_E_NOMEM;
482 else 501 else
483 return res; 502 return res;
484} 503}
535 psiconv_debug(config,lev+3,sto, "Found the Text section at %08x",text_sec); 554 psiconv_debug(config,lev+3,sto, "Found the Text section at %08x",text_sec);
536 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) { 555 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) {
537 pwd_sec = entry->offset; 556 pwd_sec = entry->offset;
538 psiconv_debug(config,lev+3,sto, 557 psiconv_debug(config,lev+3,sto,
539 "Found the Password section at %08x",pwd_sec); 558 "Found the Password section at %08x",pwd_sec);
540 psiconv_warn(config,lev+3,sto, 559 psiconv_error(config,lev+3,sto,
541 "Password section found - can't read encrypted data"); 560 "Password section found - can't read encrypted data");
542 res = -PSICONV_E_PARSE; 561 res = -PSICONV_E_PARSE;
543 goto ERROR3; 562 goto ERROR3;
544 } else if (entry->id == PSICONV_ID_WORD_STATUS_SECTION) { 563 } else if (entry->id == PSICONV_ID_WORD_STATUS_SECTION) {
545 status_sec = entry->offset; 564 status_sec = entry->offset;
563 582
564 583
565 psiconv_progress(config,lev+2,sto, 584 psiconv_progress(config,lev+2,sto,
566 "Looking for the Status section"); 585 "Looking for the Status section");
567 if (!status_sec) { 586 if (!status_sec) {
568 psiconv_warn(config,lev+2,sto, "Status section not found in the section table"); 587 psiconv_error(config,lev+2,sto, "Status section not found in the section table");
569 res = -PSICONV_E_PARSE; 588 res = -PSICONV_E_PARSE;
570 goto ERROR3; 589 goto ERROR3;
571 } else { 590 } else {
572 psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec); 591 psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec);
573 if ((res = psiconv_parse_word_status_section(config,buf,lev+2,status_sec,NULL, 592 if ((res = psiconv_parse_word_status_section(config,buf,lev+2,status_sec,NULL,
575 goto ERROR3; 594 goto ERROR3;
576 } 595 }
577 596
578 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section"); 597 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
579 if (! applid_sec) { 598 if (! applid_sec) {
580 psiconv_warn(config,lev+2,sto, 599 psiconv_error(config,lev+2,sto,
581 "Application ID section not found in the section table"); 600 "Application ID section not found in the section table");
582 res = -PSICONV_E_PARSE; 601 res = -PSICONV_E_PARSE;
583 goto ERROR4; 602 goto ERROR4;
584 } else { 603 } else {
585 psiconv_debug(config,lev+2,sto, 604 psiconv_debug(config,lev+2,sto,
587 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL, 606 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
588 &appl_id))) 607 &appl_id)))
589 goto ERROR4; 608 goto ERROR4;
590 } 609 }
591 if ((appl_id->id != PSICONV_ID_WORD) || 610 if ((appl_id->id != PSICONV_ID_WORD) ||
592 strcmp(appl_id->name,"Word.app")) { 611 !applid_matches(appl_id->name,"word.app")) {
593 psiconv_warn(config,lev+2,applid_sec, 612 psiconv_warn(config,lev+2,applid_sec,
594 "Application ID section contains unexpected data"); 613 "Application ID section contains unexpected data");
595 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", 614 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
596 PSICONV_ID_WORD,appl_id->id); 615 PSICONV_ID_WORD,appl_id->id);
597 if (!(temp_str = psiconv_make_printable(appl_id->name))) 616 if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
598 goto ERROR5; 617 goto ERROR5;
599 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found", 618 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
600 "Word.app",temp_str); 619 "Word.app",temp_str);
601 free(temp_str); 620 free(temp_str);
602 res = -PSICONV_E_PARSE; 621 res = -PSICONV_E_PARSE;
604 } 623 }
605 624
606 psiconv_progress(config,lev+2,sto, 625 psiconv_progress(config,lev+2,sto,
607 "Looking for the Page layout section"); 626 "Looking for the Page layout section");
608 if (! page_sec) { 627 if (! page_sec) {
609 psiconv_warn(config,lev+2,sto, 628 psiconv_error(config,lev+2,sto,
610 "Page layout section not found in the section table"); 629 "Page layout section not found in the section table");
611 res = -PSICONV_E_PARSE; 630 res = -PSICONV_E_PARSE;
612 goto ERROR5; 631 goto ERROR5;
613 } else { 632 } else {
614 psiconv_debug(config,lev+2,sto, 633 psiconv_debug(config,lev+2,sto,
619 } 638 }
620 639
621 psiconv_progress(config,lev+2,sto, 640 psiconv_progress(config,lev+2,sto,
622 "Looking for the Word Style section"); 641 "Looking for the Word Style section");
623 if (!styles_sec) { 642 if (!styles_sec) {
624 psiconv_warn(config,lev+2,sto, 643 psiconv_error(config,lev+2,sto,
625 "Word styles section not found in the section table"); 644 "Word styles section not found in the section table");
626 res = -PSICONV_E_PARSE; 645 res = -PSICONV_E_PARSE;
627 goto ERROR6; 646 goto ERROR6;
628 } else { 647 } else {
629 psiconv_debug(config,lev+2,sto, 648 psiconv_debug(config,lev+2,sto,
634 } 653 }
635 654
636 psiconv_progress(config,lev+2,sto, 655 psiconv_progress(config,lev+2,sto,
637 "Looking for the Text section"); 656 "Looking for the Text section");
638 if (!text_sec) { 657 if (!text_sec) {
639 psiconv_warn(config,lev+2,sto, "Text section not found in the section table"); 658 psiconv_error(config,lev+2,sto, "Text section not found in the section table");
640 res = -PSICONV_E_PARSE; 659 res = -PSICONV_E_PARSE;
641 goto ERROR7; 660 goto ERROR7;
642 } else { 661 } else {
643 psiconv_debug(config,lev+2,sto, 662 psiconv_debug(config,lev+2,sto,
644 "Text section at offset %08x",text_sec); 663 "Text section at offset %08x",text_sec);
679ERROR3: 698ERROR3:
680 psiconv_free_section_table_section(table); 699 psiconv_free_section_table_section(table);
681ERROR2: 700ERROR2:
682 free(*result); 701 free(*result);
683ERROR1: 702ERROR1:
684 psiconv_warn(config,lev+1,off,"Reading of Word File failed"); 703 psiconv_error(config,lev+1,off,"Reading of Word File failed");
685 if (res == 0) 704 if (res == 0)
686 return -PSICONV_E_NOMEM; 705 return -PSICONV_E_NOMEM;
687 else 706 else
688 return res; 707 return res;
689} 708}
735 "Found the Page Layout section at %08x",page_sec); 754 "Found the Page Layout section at %08x",page_sec);
736 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) { 755 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) {
737 pwd_sec = entry->offset; 756 pwd_sec = entry->offset;
738 psiconv_debug(config,lev+3,sto, 757 psiconv_debug(config,lev+3,sto,
739 "Found the Password section at %08x",pwd_sec); 758 "Found the Password section at %08x",pwd_sec);
740 psiconv_warn(config,lev+3,sto, 759 psiconv_error(config,lev+3,sto,
741 "Password section found - can't read encrypted data"); 760 "Password section found - can't read encrypted data");
742 res = -PSICONV_E_PARSE; 761 res = -PSICONV_E_PARSE;
743 goto ERROR3; 762 goto ERROR3;
744 } else if (entry->id == PSICONV_ID_SHEET_WORKBOOK_SECTION) { 763 } else if (entry->id == PSICONV_ID_SHEET_WORKBOOK_SECTION) {
745 workbook_sec = entry->offset; 764 workbook_sec = entry->offset;
759 778
760 779
761 psiconv_progress(config,lev+2,sto, 780 psiconv_progress(config,lev+2,sto,
762 "Looking for the Status section"); 781 "Looking for the Status section");
763 if (!status_sec) { 782 if (!status_sec) {
764 psiconv_warn(config,lev+2,sto, "Status section not found in the section table"); 783 psiconv_error(config,lev+2,sto, "Status section not found in the section table");
765 res = -PSICONV_E_PARSE; 784 res = -PSICONV_E_PARSE;
766 goto ERROR3; 785 goto ERROR3;
767 } else { 786 } else {
768 psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec); 787 psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec);
769 if ((res = psiconv_parse_sheet_status_section(config,buf,lev+2,status_sec,NULL, 788 if ((res = psiconv_parse_sheet_status_section(config,buf,lev+2,status_sec,NULL,
771 goto ERROR3; 790 goto ERROR3;
772 } 791 }
773 792
774 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section"); 793 psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
775 if (! applid_sec) { 794 if (! applid_sec) {
776 psiconv_warn(config,lev+2,sto, 795 psiconv_error(config,lev+2,sto,
777 "Application ID section not found in the section table"); 796 "Application ID section not found in the section table");
778 res = -PSICONV_E_PARSE; 797 res = -PSICONV_E_PARSE;
779 goto ERROR4; 798 goto ERROR4;
780 } else { 799 } else {
781 psiconv_debug(config,lev+2,sto, 800 psiconv_debug(config,lev+2,sto,
783 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL, 802 if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
784 &appl_id))) 803 &appl_id)))
785 goto ERROR4; 804 goto ERROR4;
786 } 805 }
787 if ((appl_id->id != PSICONV_ID_SHEET) || 806 if ((appl_id->id != PSICONV_ID_SHEET) ||
788 strcmp(appl_id->name,"Sheet.app")) { 807 !applid_matches(appl_id->name,"sheet.app")) {
789 psiconv_warn(config,lev+2,applid_sec, 808 psiconv_warn(config,lev+2,applid_sec,
790 "Application ID section contains unexpected data"); 809 "Application ID section contains unexpected data");
791 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", 810 psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
792 PSICONV_ID_SHEET,appl_id->id); 811 PSICONV_ID_SHEET,appl_id->id);
793 if (!(temp_str = psiconv_make_printable(appl_id->name))) 812 if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
794 goto ERROR5; 813 goto ERROR5;
795 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found", 814 psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
796 "Sheet.app",temp_str); 815 "Sheet.app",temp_str);
797 free(temp_str); 816 free(temp_str);
798 res = -PSICONV_E_PARSE; 817 res = -PSICONV_E_PARSE;
800 } 819 }
801 820
802 psiconv_progress(config,lev+2,sto, 821 psiconv_progress(config,lev+2,sto,
803 "Looking for the Page layout section"); 822 "Looking for the Page layout section");
804 if (! page_sec) { 823 if (! page_sec) {
805 psiconv_warn(config,lev+2,sto, 824 psiconv_error(config,lev+2,sto,
806 "Page layout section not found in the section table"); 825 "Page layout section not found in the section table");
807 res = -PSICONV_E_PARSE; 826 res = -PSICONV_E_PARSE;
808 goto ERROR5; 827 goto ERROR5;
809 } else { 828 } else {
810 psiconv_debug(config,lev+2,sto, 829 psiconv_debug(config,lev+2,sto,
815 } 834 }
816 835
817 psiconv_progress(config,lev+2,sto, 836 psiconv_progress(config,lev+2,sto,
818 "Looking for the Sheet Workbook section"); 837 "Looking for the Sheet Workbook section");
819 if (! workbook_sec) { 838 if (! workbook_sec) {
820 psiconv_warn(config,lev+2,sto, 839 psiconv_error(config,lev+2,sto,
821 "Sheet workbook section not found in the section table"); 840 "Sheet workbook section not found in the section table");
822 res = -PSICONV_E_PARSE; 841 res = -PSICONV_E_PARSE;
823 goto ERROR6; 842 goto ERROR6;
824 } else { 843 } else {
825 psiconv_debug(config,lev+2,sto, 844 psiconv_debug(config,lev+2,sto,
844ERROR3: 863ERROR3:
845 psiconv_free_section_table_section(table); 864 psiconv_free_section_table_section(table);
846ERROR2: 865ERROR2:
847 free(*result); 866 free(*result);
848ERROR1: 867ERROR1:
849 psiconv_warn(config,lev+1,off,"Reading of Sheet File failed"); 868 psiconv_error(config,lev+1,off,"Reading of Sheet File failed");
850 if (res == 0) 869 if (res == 0)
851 return -PSICONV_E_NOMEM; 870 return -PSICONV_E_NOMEM;
852 else 871 else
853 return res; 872 return res;
854} 873}

Legend:
Removed from v.170  
changed lines
  Added in v.237

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