--- psiconv/trunk/program/extra/rewrite.c 2000/12/25 00:26:53 76 +++ psiconv/trunk/program/extra/rewrite.c 2005/11/15 15:52:34 270 @@ -1,6 +1,6 @@ /* rewrite.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999 Frodo Looijaard + Copyright (c) 1999-2004 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,9 @@ #include #include +#include +#include #include int main(int argc, char *argv[]) @@ -27,41 +29,54 @@ FILE *fp; psiconv_buffer buf; psiconv_file psionfile; + psiconv_config config; + + /* psiconv_verbosity = PSICONV_VERB_DEBUG; */ if (argc < 3) { fprintf(stderr,"Not enough arguments\n"); + fprintf(stderr,"Syntax: INFILE OUTFILE\n"); exit(1); } + + config = psiconv_config_default(); + psiconv_config_read(NULL,&config); + if (!(fp = fopen(argv[1],"r"))) { perror("Can't open file"); exit(1); } - if (!(buf=psiconv_new_buffer())) { + if (!(buf=psiconv_buffer_new())) { perror("Can't allocate buf"); exit(1); } - if ((psiconv_list_fread_all(buf,fp))) { + if ((psiconv_buffer_fread_all(buf,fp))) { perror("Can't fread file"); exit(1); } fclose(fp); - if ((psiconv_parse(buf,&psionfile))) { + if ((psiconv_parse(config,buf,&psionfile))) { fprintf(stderr,"Parse error\n"); exit(1); } - psiconv_free_buffer(buf); + + psiconv_buffer_free(buf); buf = NULL; - if (psiconv_write(&buf,psionfile)) { - fprintf(stderr,"Parse error\n"); + if (psiconv_write(config,&buf,psionfile)) { + fprintf(stderr,"Generate error\n"); exit(1); } + psiconv_free_file(psionfile); if (!(fp = fopen(argv[2],"w"))) { perror("Can't open file"); exit(1); } - if ((psiconv_list_fwrite_all(buf,fp))) { + if ((psiconv_buffer_fwrite_all(buf,fp))) { perror("Can't fwrite file"); exit(1); } + fclose(fp); + psiconv_buffer_free(buf); + psiconv_config_free(config); exit(0); }