/[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 24 Revision 63
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 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999, 2000 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.
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) 68 else if ((*result)->type == psiconv_sketch_file)
69 res = psiconv_parse_sketch_file(buf,lev+2,leng, 69 res = psiconv_parse_sketch_file(buf,lev+2,leng,
70 (psiconv_sketch_f *)(&((*result)->file))); 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)));
71 else { 74 else {
72 psiconv_warn(lev+1,off,"Can't parse this file yet!"); 75 psiconv_warn(lev+1,off,"Can't parse this file yet!");
73 (*result)->file = NULL; 76 (*result)->file = NULL;
74 } 77 }
75 res = -1; 78 res = -1;
76 79
77 return res; 80 return res;
78} 81}
79 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
80int 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,
81 psiconv_mbm_f *result) 113 psiconv_mbm_f *result)
82{ 114{
83 int res=0; 115 int res=0;
84 int i; 116 int i;
85 psiconv_mbm_jumptable_section table; 117 psiconv_jumptable_section table;
86 psiconv_paint_data_section paint; 118 psiconv_paint_data_section paint;
87 psiconv_u32 *entry; 119 psiconv_u32 *entry;
88 psiconv_u32 sto; 120 psiconv_u32 sto;
89 121
90 psiconv_progress(lev+1,off,"Going to read a mbm file"); 122 psiconv_progress(lev+1,off,"Going to read a mbm file");
93 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");
94 sto = psiconv_read_u32(buf,lev+2,off); 126 sto = psiconv_read_u32(buf,lev+2,off);
95 psiconv_debug(lev+2,off,"Offset: %08x",sto); 127 psiconv_debug(lev+2,off,"Offset: %08x",sto);
96 128
97 psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); 129 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
98 res |= psiconv_parse_mbm_jumptable_section(buf,lev+2,sto, NULL,&table); 130 res |= psiconv_parse_jumptable_section(buf,lev+2,sto, NULL,&table);
99 131
100 psiconv_progress(lev+2,off,"Going to read the picture sections"); 132 psiconv_progress(lev+2,off,"Going to read the picture sections");
101 (*result)->sections = psiconv_list_new(sizeof(*paint)); 133 (*result)->sections = psiconv_list_new(sizeof(*paint));
102 for (i = 0; i < psiconv_list_length(table); i ++) { 134 for (i = 0; i < psiconv_list_length(table); i ++) {
103 entry = psiconv_list_get(table,i); 135 entry = psiconv_list_get(table,i);
104 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);
105 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint); 137 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,0,&paint);
106 psiconv_list_add((*result)->sections,paint); 138 psiconv_list_add((*result)->sections,paint);
107 } 139 }
108 140
109 psiconv_free_mbm_jumptable_section(table); 141 psiconv_free_jumptable_section(table);
110 psiconv_progress(lev+1,off,"End of mbm file"); 142 psiconv_progress(lev+1,off,"End of mbm file");
111 return res; 143 return res;
112} 144}
113 145
114int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev, 146int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev,

Legend:
Removed from v.24  
changed lines
  Added in v.63

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