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

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

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

Revision 230 Revision 231
108 psiconv_u32 section_table_id; 108 psiconv_u32 section_table_id;
109 psiconv_buffer buf_texted; 109 psiconv_buffer buf_texted;
110 110
111 psiconv_progress(config,lev,0,"Writing texted file"); 111 psiconv_progress(config,lev,0,"Writing texted file");
112 if (!value) { 112 if (!value) {
113 psiconv_error(config,0,0,"Null TextEd file"); 113 psiconv_error(config,lev,0,"Null TextEd file");
114 return -PSICONV_E_GENERATE; 114 res = -PSICONV_E_GENERATE;
115 goto ERROR1;
115 } 116 }
116 117
117 if (!(section_table = psiconv_list_new(sizeof(*entry)))) { 118 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
118 res = -PSICONV_E_NOMEM; 119 res = -PSICONV_E_NOMEM;
119 goto ERROR1; 120 goto ERROR1;
184ERROR3: 185ERROR3:
185 free(entry); 186 free(entry);
186ERROR2: 187ERROR2:
187 psiconv_list_free(section_table); 188 psiconv_list_free(section_table);
188ERROR1: 189ERROR1:
190 if (res)
191 psiconv_error(config,lev,0,"Writing of texted file failed");
192 else
193 psiconv_progress(config,lev,0,"End of texted file");
189 return res; 194 return res;
190} 195}
191 196
192int psiconv_write_word_file(const psiconv_config config, 197int psiconv_write_word_file(const psiconv_config config,
193 psiconv_buffer buf,int lev,psiconv_word_f value) 198 psiconv_buffer buf,int lev,psiconv_word_f value)
197 psiconv_section_table_entry entry; 202 psiconv_section_table_entry entry;
198 psiconv_u32 section_table_id; 203 psiconv_u32 section_table_id;
199 204
200 psiconv_progress(config,lev,0,"Writing word file"); 205 psiconv_progress(config,lev,0,"Writing word file");
201 if (!value) { 206 if (!value) {
202 psiconv_error(config,0,0,"Null Word file"); 207 psiconv_error(config,lev,0,"Null Word file");
203 return -PSICONV_E_GENERATE; 208 res = -PSICONV_E_GENERATE;
209 goto ERROR1;
204 } 210 }
205 211
206 if (!(section_table = psiconv_list_new(sizeof(*entry)))) { 212 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
207 res = -PSICONV_E_NOMEM; 213 res = -PSICONV_E_NOMEM;
208 goto ERROR1; 214 goto ERROR1;
281ERROR3: 287ERROR3:
282 free(entry); 288 free(entry);
283ERROR2: 289ERROR2:
284 psiconv_list_free(section_table); 290 psiconv_list_free(section_table);
285ERROR1: 291ERROR1:
292 if (res)
293 psiconv_error(config,lev,0,"Writing of word file failed");
294 else
295 psiconv_progress(config,lev,0,"End of word file");
286 return res; 296 return res;
287} 297}
288 298
289int psiconv_write_sketch_file(const psiconv_config config, 299int psiconv_write_sketch_file(const psiconv_config config,
290 psiconv_buffer buf,int lev,psiconv_sketch_f value) 300 psiconv_buffer buf,int lev,psiconv_sketch_f value)
294 psiconv_section_table_entry entry; 304 psiconv_section_table_entry entry;
295 psiconv_u32 section_table_id; 305 psiconv_u32 section_table_id;
296 306
297 psiconv_progress(config,lev,0,"Writing sketch file"); 307 psiconv_progress(config,lev,0,"Writing sketch file");
298 if (!value) { 308 if (!value) {
299 psiconv_error(config,0,0,"Null Sketch file"); 309 psiconv_error(config,lev,0,"Null Sketch file");
300 return -PSICONV_E_GENERATE; 310 res = -PSICONV_E_GENERATE;
311 goto ERROR1;
301 } 312 }
302 313
303 if (!(section_table = psiconv_list_new(sizeof(*entry)))) { 314 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
304 res = -PSICONV_E_NOMEM; 315 res = -PSICONV_E_NOMEM;
305 goto ERROR1; 316 goto ERROR1;
340ERROR3: 351ERROR3:
341 free(entry); 352 free(entry);
342ERROR2: 353ERROR2:
343 psiconv_list_free(section_table); 354 psiconv_list_free(section_table);
344ERROR1: 355ERROR1:
356 if (res)
357 psiconv_error(config,lev,0,"Writing of sketch file failed");
358 else
359 psiconv_progress(config,lev,0,"End of sketch file");
345 return res; 360 return res;
346} 361}
347 362
348int psiconv_write_mbm_file(const psiconv_config config, 363int psiconv_write_mbm_file(const psiconv_config config,
349 psiconv_buffer buf,int lev,psiconv_mbm_f value) 364 psiconv_buffer buf,int lev,psiconv_mbm_f value)
353 psiconv_u32 *entry,id,table_id; 368 psiconv_u32 *entry,id,table_id;
354 psiconv_paint_data_section section; 369 psiconv_paint_data_section section;
355 370
356 psiconv_progress(config,lev,0,"Writing mbm file"); 371 psiconv_progress(config,lev,0,"Writing mbm file");
357 if (!value) { 372 if (!value) {
358 psiconv_error(config,0,0,"Null MBM file"); 373 psiconv_error(config,lev,0,"Null MBM file");
359 return -PSICONV_E_GENERATE; 374 res = -PSICONV_E_GENERATE;
375 goto ERROR1;
360 } 376 }
361 377
362 if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { 378 if (!(jumptable = psiconv_list_new(sizeof(*entry)))) {
363 res = -PSICONV_E_NOMEM; 379 res = -PSICONV_E_NOMEM;
364 goto ERROR1; 380 goto ERROR1;
368 if ((res = psiconv_buffer_add_reference(buf,table_id))) 384 if ((res = psiconv_buffer_add_reference(buf,table_id)))
369 goto ERROR2; 385 goto ERROR2;
370 386
371 for (i = 0; i < psiconv_list_length(value->sections); i++) { 387 for (i = 0; i < psiconv_list_length(value->sections); i++) {
372 if (!(section = psiconv_list_get(value->sections,i))) { 388 if (!(section = psiconv_list_get(value->sections,i))) {
373 psiconv_error(config,0,0,"Massive memory corruption"); 389 psiconv_error(config,lev,0,"Massive memory corruption");
374 res = -PSICONV_E_NOMEM; 390 res = -PSICONV_E_NOMEM;
375 goto ERROR2; 391 goto ERROR2;
376 } 392 }
377 id = psiconv_buffer_unique_id(); 393 id = psiconv_buffer_unique_id();
378 psiconv_list_add(jumptable,&id); 394 psiconv_list_add(jumptable,&id);
389 405
390 406
391ERROR2: 407ERROR2:
392 psiconv_list_free(jumptable); 408 psiconv_list_free(jumptable);
393ERROR1: 409ERROR1:
410 if (res)
411 psiconv_error(config,lev,0,"Writing of mbm file failed");
412 else
413 psiconv_progress(config,lev,0,"End of mbm file");
394 return res; 414 return res;
395} 415}
396 416
397/* Note: this file is special, because it does not have a complete header! */ 417/* Note: this file is special, because it does not have a complete header! */
398int psiconv_write_clipart_file(const psiconv_config config, 418int psiconv_write_clipart_file(const psiconv_config config,
404 psiconv_clipart_section section; 424 psiconv_clipart_section section;
405 psiconv_buffer sec_buf; 425 psiconv_buffer sec_buf;
406 426
407 psiconv_progress(config,lev,0,"Writing clipart file"); 427 psiconv_progress(config,lev,0,"Writing clipart file");
408 if (!value) { 428 if (!value) {
409 psiconv_error(config,0,0,"Null Clipart file"); 429 psiconv_error(config,lev,0,"Null Clipart file");
410 return -PSICONV_E_GENERATE; 430 res = -PSICONV_E_GENERATE;
431 goto ERROR1;
411 } 432 }
412 433
413 if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { 434 if (!(jumptable = psiconv_list_new(sizeof(*entry)))) {
414 res = -PSICONV_E_NOMEM; 435 res = -PSICONV_E_NOMEM;
415 goto ERROR1; 436 goto ERROR1;
423 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART))) 444 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART)))
424 goto ERROR3; 445 goto ERROR3;
425 446
426 for (i = 0; i < psiconv_list_length(value->sections); i++) { 447 for (i = 0; i < psiconv_list_length(value->sections); i++) {
427 if (!(section = psiconv_list_get(value->sections,i))) { 448 if (!(section = psiconv_list_get(value->sections,i))) {
428 psiconv_error(config,0,0,"Massive memory corruption"); 449 psiconv_error(config,lev,0,"Massive memory corruption");
429 res = -PSICONV_E_NOMEM; 450 res = -PSICONV_E_NOMEM;
430 goto ERROR3; 451 goto ERROR3;
431 } 452 }
432 id = psiconv_buffer_unique_id(); 453 id = psiconv_buffer_unique_id();
433 psiconv_list_add(jumptable,&id); 454 psiconv_list_add(jumptable,&id);
447ERROR3: 468ERROR3:
448 psiconv_buffer_free(sec_buf); 469 psiconv_buffer_free(sec_buf);
449ERROR2: 470ERROR2:
450 psiconv_list_free(jumptable); 471 psiconv_list_free(jumptable);
451ERROR1: 472ERROR1:
473 if (res)
474 psiconv_error(config,lev,0,"Writing of clipart file failed");
475 else
476 psiconv_progress(config,lev,0,"End of clipart file");
452 return res; 477 return res;
453} 478}

Legend:
Removed from v.230  
changed lines
  Added in v.231

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