/[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 60
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#include "parse.h" 23#include "parse.h"
24#include "parse_routines.h" 24#include "parse_routines.h"
25#include "data.h" 25#include "data.h"
26
27int psiconv_verbosity = PSICONV_VERB_WARN;
26 28
27psiconv_file_type_t psiconv_file_type(psiconv_buffer buf,int *length, 29psiconv_file_type_t psiconv_file_type(psiconv_buffer buf,int *length,
28 psiconv_header_section *result) 30 psiconv_header_section *result)
29{ 31{
30 psiconv_header_section header; 32 psiconv_header_section header;
66 res = psiconv_parse_mbm_file(buf,lev+2,leng, 68 res = psiconv_parse_mbm_file(buf,lev+2,leng,
67 (psiconv_mbm_f *)(&((*result)->file))); 69 (psiconv_mbm_f *)(&((*result)->file)));
68 else if ((*result)->type == psiconv_sketch_file) 70 else if ((*result)->type == psiconv_sketch_file)
69 res = psiconv_parse_sketch_file(buf,lev+2,leng, 71 res = psiconv_parse_sketch_file(buf,lev+2,leng,
70 (psiconv_sketch_f *)(&((*result)->file))); 72 (psiconv_sketch_f *)(&((*result)->file)));
73 else if ((*result)->type == psiconv_clipart_file)
74 res = psiconv_parse_clipart_file(buf,lev+2,leng,
75 (psiconv_clipart_f *)(&((*result)->file)));
71 else { 76 else {
72 psiconv_warn(lev+1,off,"Can't parse this file yet!"); 77 psiconv_warn(lev+1,off,"Can't parse this file yet!");
73 (*result)->file = NULL; 78 (*result)->file = NULL;
74 } 79 }
75 res = -1; 80 res = -1;
76 81
77 return res; 82 return res;
78} 83}
79 84
85int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev,
86 psiconv_u32 off, psiconv_clipart_f *result)
87{
88 int res=0;
89 int i;
90 psiconv_jumptable_section table;
91 psiconv_clipart_section clipart;
92 psiconv_u32 *entry;
93
94 psiconv_progress(lev+1,off,"Going to read a clipart file");
95 (*result) = malloc(sizeof(**result));
96
97 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
98 res |= psiconv_parse_jumptable_section(buf,lev+2,off, NULL,&table);
99
100 psiconv_progress(lev+2,off,"Going to read the clipart sections");
101 (*result)->sections = psiconv_list_new(sizeof(*clipart));
102 for (i = 0; i < psiconv_list_length(table); i ++) {
103 entry = psiconv_list_get(table,i);
104 psiconv_progress(lev+3,off,"Going to read clipart section %i",i);
105 psiconv_parse_clipart_section(buf,lev+3,*entry,NULL,&clipart);
106 psiconv_list_add((*result)->sections,clipart);
107 }
108
109 psiconv_free_jumptable_section(table);
110 psiconv_progress(lev+1,off,"End of clipart file");
111 return res;
112}
113
80int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 114int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off,
81 psiconv_mbm_f *result) 115 psiconv_mbm_f *result)
82{ 116{
83 int res=0; 117 int res=0;
84 int i; 118 int i;
85 psiconv_mbm_jumptable_section table; 119 psiconv_jumptable_section table;
86 psiconv_paint_data_section paint; 120 psiconv_paint_data_section paint;
87 psiconv_u32 *entry; 121 psiconv_u32 *entry;
88 psiconv_u32 sto; 122 psiconv_u32 sto;
89 123
90 psiconv_progress(lev+1,off,"Going to read a mbm file"); 124 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"); 127 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable");
94 sto = psiconv_read_u32(buf,lev+2,off); 128 sto = psiconv_read_u32(buf,lev+2,off);
95 psiconv_debug(lev+2,off,"Offset: %08x",sto); 129 psiconv_debug(lev+2,off,"Offset: %08x",sto);
96 130
97 psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); 131 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
98 res |= psiconv_parse_mbm_jumptable_section(buf,lev+2,sto, NULL,&table); 132 res |= psiconv_parse_jumptable_section(buf,lev+2,sto, NULL,&table);
99 133
100 psiconv_progress(lev+2,off,"Going to read the picture sections"); 134 psiconv_progress(lev+2,off,"Going to read the picture sections");
101 (*result)->sections = psiconv_list_new(sizeof(*paint)); 135 (*result)->sections = psiconv_list_new(sizeof(*paint));
102 for (i = 0; i < psiconv_list_length(table); i ++) { 136 for (i = 0; i < psiconv_list_length(table); i ++) {
103 entry = psiconv_list_get(table,i); 137 entry = psiconv_list_get(table,i);
104 psiconv_progress(lev+3,off,"Going to read picture section %i",i); 138 psiconv_progress(lev+3,off,"Going to read picture section %i",i);
105 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint); 139 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,0,&paint);
106 psiconv_list_add((*result)->sections,paint); 140 psiconv_list_add((*result)->sections,paint);
107 } 141 }
108 142
109 psiconv_free_mbm_jumptable_section(table); 143 psiconv_free_jumptable_section(table);
110 psiconv_progress(lev+1,off,"End of mbm file"); 144 psiconv_progress(lev+1,off,"End of mbm file");
111 return res; 145 return res;
112} 146}
113 147
114int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev, 148int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev,

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

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