1 | /* |
1 | /* |
2 | rewrite.c - Part of psiconv, a PSION 5 file formats converter |
2 | rewrite.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2014 Frodo Looijaard <frodo@frodo.looijaard.name> |
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. |
… | |
… | |
36 | if (argc < 3) { |
36 | if (argc < 3) { |
37 | fprintf(stderr,"Not enough arguments\n"); |
37 | fprintf(stderr,"Not enough arguments\n"); |
38 | fprintf(stderr,"Syntax: INFILE OUTFILE\n"); |
38 | fprintf(stderr,"Syntax: INFILE OUTFILE\n"); |
39 | exit(1); |
39 | exit(1); |
40 | } |
40 | } |
41 | if (!(config = psiconv_config_read(NULL))) { |
41 | |
42 | fprintf(stderr,"Can't get config\n"); |
42 | config = psiconv_config_default(); |
43 | exit(1); |
43 | psiconv_config_read(NULL,&config); |
44 | } |
44 | |
45 | if (!(fp = fopen(argv[1],"r"))) { |
45 | if (!(fp = fopen(argv[1],"r"))) { |
46 | perror("Can't open file"); |
46 | perror("Can't open file"); |
47 | exit(1); |
47 | exit(1); |
48 | } |
48 | } |
49 | if (!(buf=psiconv_buffer_new())) { |
49 | if (!(buf=psiconv_buffer_new())) { |
… | |
… | |
75 | perror("Can't fwrite file"); |
75 | perror("Can't fwrite file"); |
76 | exit(1); |
76 | exit(1); |
77 | } |
77 | } |
78 | fclose(fp); |
78 | fclose(fp); |
79 | psiconv_buffer_free(buf); |
79 | psiconv_buffer_free(buf); |
|
|
80 | psiconv_config_free(config); |
80 | exit(0); |
81 | exit(0); |
81 | } |
82 | } |