/[public]/psiconv/trunk/program/extra/rewrite.c
ViewVC logotype

Diff of /psiconv/trunk/program/extra/rewrite.c

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

Revision 167 Revision 168
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/ 18*/
19 19
20#include <psiconv/parse.h> 20#include <psiconv/parse.h>
21#include <psiconv/generate.h> 21#include <psiconv/generate.h>
22#include <psiconv/configuration.h>
22 23
24#include <stdlib.h>
23#include <stdio.h> 25#include <stdio.h>
24 26
25int main(int argc, char *argv[]) 27int main(int argc, char *argv[])
26{ 28{
27 FILE *fp; 29 FILE *fp;
28 psiconv_buffer buf; 30 psiconv_buffer buf;
29 psiconv_file psionfile; 31 psiconv_file psionfile;
32 psiconv_config config;
30 33
31 /* psiconv_verbosity = PSICONV_VERB_DEBUG; */ 34 /* psiconv_verbosity = PSICONV_VERB_DEBUG; */
32 35
33 if (argc < 3) { 36 if (argc < 3) {
34 fprintf(stderr,"Not enough arguments\n"); 37 fprintf(stderr,"Not enough arguments\n");
35 fprintf(stderr,"Syntax: INFILE OUTFILE\n"); 38 fprintf(stderr,"Syntax: INFILE OUTFILE\n");
36 exit(1); 39 exit(1);
37 } 40 }
41 if (!(config = psiconv_config_read(NULL))) {
42 fprintf(stderr,"Can't get config\n");
43 exit(1);
44 }
38 if (!(fp = fopen(argv[1],"r"))) { 45 if (!(fp = fopen(argv[1],"r"))) {
39 perror("Can't open file"); 46 perror("Can't open file");
40 exit(1); 47 exit(1);
41 } 48 }
42 if (!(buf=psiconv_buffer_new())) { 49 if (!(buf=psiconv_buffer_new())) {
46 if ((psiconv_buffer_fread_all(buf,fp))) { 53 if ((psiconv_buffer_fread_all(buf,fp))) {
47 perror("Can't fread file"); 54 perror("Can't fread file");
48 exit(1); 55 exit(1);
49 } 56 }
50 fclose(fp); 57 fclose(fp);
51 if ((psiconv_parse(buf,&psionfile))) { 58 if ((psiconv_parse(config,buf,&psionfile))) {
52 fprintf(stderr,"Parse error\n"); 59 fprintf(stderr,"Parse error\n");
53 exit(1); 60 exit(1);
54 } 61 }
55 62
56 psiconv_buffer_free(buf); 63 psiconv_buffer_free(buf);
57 buf = NULL; 64 buf = NULL;
58 if (psiconv_write(&buf,psionfile)) { 65 if (psiconv_write(config,&buf,psionfile)) {
59 fprintf(stderr,"Generate error\n"); 66 fprintf(stderr,"Generate error\n");
60 exit(1); 67 exit(1);
61 } 68 }
62 psiconv_free_file(psionfile); 69 psiconv_free_file(psionfile);
63 if (!(fp = fopen(argv[2],"w"))) { 70 if (!(fp = fopen(argv[2],"w"))) {

Legend:
Removed from v.167  
changed lines
  Added in v.168

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