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

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

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

Revision 25 Revision 43
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#include "data.h" 23#include "data.h"
24#include "parse_routines.h" 24#include "parse_routines.h"
25 25
26int psiconv_parse_mbm_jumptable_section(const psiconv_buffer buf,int lev, 26int psiconv_parse_jumptable_section(const psiconv_buffer buf,int lev,
27 psiconv_u32 off, int *length, 27 psiconv_u32 off, int *length,
28 psiconv_mbm_jumptable_section *result) 28 psiconv_jumptable_section *result)
29{ 29{
30 int res = 0; 30 int res = 0;
31 int len = 0; 31 int len = 0;
32 psiconv_u32 listlen,temp; 32 psiconv_u32 listlen,temp;
33 int i; 33 int i;
34 34
35 psiconv_progress(lev+1,off+len,"Going to read the mbm jumptable section"); 35 psiconv_progress(lev+1,off+len,"Going to read the jumptable section");
36 (*result) = psiconv_list_new(sizeof(psiconv_u32)); 36 (*result) = psiconv_list_new(sizeof(psiconv_u32));
37 37
38 psiconv_progress(lev+2,off+len,"Going to read the list length"); 38 psiconv_progress(lev+2,off+len,"Going to read the list length");
39 listlen = psiconv_read_u32(buf,lev+2,off+len); 39 listlen = psiconv_read_u32(buf,lev+2,off+len);
40 psiconv_debug(lev+2,off+len,"List length: %08x",listlen); 40 psiconv_debug(lev+2,off+len,"List length: %08x",listlen);
49 } 49 }
50 50
51 if (length) 51 if (length)
52 *length = len; 52 *length = len;
53 53
54 psiconv_progress(lev+1,off+len-1,"End of mbm jumptable section " 54 psiconv_progress(lev+1,off+len-1,"End of jumptable section "
55 "(total length: %08x)", len); 55 "(total length: %08x)", len);
56 56
57 return res; 57 return res;
58} 58}
59 59
446 "End of sketch section (total length: %08x)", len); 446 "End of sketch section (total length: %08x)", len);
447 447
448 return res; 448 return res;
449} 449}
450 450
451
452int psiconv_parse_clipart_section(const psiconv_buffer buf,int lev,
453 psiconv_u32 off, int *length,
454 psiconv_clipart_section *result)
455{
456 int res=0;
457 int len=0;
458 int leng;
459 psiconv_u32 temp;
460
461 psiconv_progress(lev+1,off+len,"Going to read the clipart section");
462 *result = malloc(sizeof(**result));
463
464 psiconv_progress(lev+2,off+len,"Going to read the section ID");
465 temp = psiconv_read_u32(buf,lev+2,off+len);
466 if (temp != PSICONV_ID_CLIPART_ITEM) {
467 psiconv_warn(lev+2,off+len,
468 "Unexpected value in clipart section preamble");
469 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp,
470 PSICONV_ID_CLIPART_ITEM);
471 res = -1;
472 } else
473 psiconv_debug(lev+2,off+len,"Clipart ID: %08x", temp);
474 off += 4;
475
476 psiconv_progress(lev+2,off+len,"Going to read an unknown long");
477 temp = psiconv_read_u32(buf,lev+2,off+len);
478 if (temp != 0x02) {
479 psiconv_warn(lev+2,off+len,
480 "Unexpected value in clipart section preamble");
481 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp,
482 0x02);
483 res = -1;
484 } else
485 psiconv_debug(lev+2,off+len,"First unknown long: %08x", temp);
486 off += 4;
487
488 psiconv_progress(lev+2,off+len,"Going to read a second unknown long");
489 temp = psiconv_read_u32(buf,lev+2,off+len);
490 if (temp != 0) {
491 psiconv_warn(lev+2,off+len,
492 "Unexpected value in clipart section preamble");
493 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0);
494 res = -1;
495 } else
496 psiconv_debug(lev+2,off+len,"Second unknown long: %08x", temp);
497 off += 4;
498
499 psiconv_progress(lev+2,off+len,"Going to read a third unknown long");
500 temp = psiconv_read_u32(buf,lev+2,off+len);
501 if (temp != 0) {
502 psiconv_warn(lev+2,off+len,
503 "Unexpected value in clipart section preamble");
504 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0);
505 res = -1;
506 } else
507 psiconv_debug(lev+2,off+len,"Third unknown long: %08x", temp);
508 off += 4;
509
510 psiconv_progress(lev+2,off+len,"Going to read a fourth unknown long");
511 temp = psiconv_read_u32(buf,lev+2,off+len);
512 if ((temp != 0x0c) && (temp != 0x08)) {
513 psiconv_warn(lev+2,off+len,
514 "Unexpected value in clipart section preamble");
515 psiconv_debug(lev+2,off+len,"Read %08x, expected %08x or %08x",temp,
516 0x0c, 0x08);
517 res = -1;
518 } else
519 psiconv_debug(lev+2,off+len,"Fourth unknown long: %08x", temp);
520 off += 4;
521
522 psiconv_progress(lev+2,off+len,"Going to read the Paint Data Section");
523 res |= psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,
524 &((*result)->picture));
525 len += leng;
526
527 if (length)
528 *length = len;
529
530 psiconv_progress(lev,off+len-1,
531 "End of clipart section (total length: %08x)", len);
532
533 return res;
534}

Legend:
Removed from v.25  
changed lines
  Added in v.43

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