--- psiconv/trunk/program/extra/rewrite.c 2002/01/29 18:38:38 142 +++ 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,13 +29,19 @@ 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); @@ -47,14 +55,14 @@ exit(1); } fclose(fp); - if ((psiconv_parse(buf,&psionfile))) { + if ((psiconv_parse(config,buf,&psionfile))) { fprintf(stderr,"Parse error\n"); exit(1); } psiconv_buffer_free(buf); buf = NULL; - if (psiconv_write(&buf,psionfile)) { + if (psiconv_write(config,&buf,psionfile)) { fprintf(stderr,"Generate error\n"); exit(1); } @@ -67,6 +75,8 @@ perror("Can't fwrite file"); exit(1); } + fclose(fp); psiconv_buffer_free(buf); + psiconv_config_free(config); exit(0); }