… | |
… | |
34 | } |
34 | } |
35 | if (!(fp = fopen(argv[1],"r"))) { |
35 | if (!(fp = fopen(argv[1],"r"))) { |
36 | perror("Can't open file"); |
36 | perror("Can't open file"); |
37 | exit(1); |
37 | exit(1); |
38 | } |
38 | } |
39 | if (!(buf=psiconv_new_buffer())) { |
39 | if (!(buf=psiconv_buffer_new(0))) { |
40 | perror("Can't allocate buf"); |
40 | perror("Can't allocate buf"); |
41 | exit(1); |
41 | exit(1); |
42 | } |
42 | } |
43 | if ((psiconv_list_fread_all(buf,fp))) { |
43 | if ((psiconv_buffer_fread_all(buf,fp))) { |
44 | perror("Can't fread file"); |
44 | perror("Can't fread file"); |
45 | exit(1); |
45 | exit(1); |
46 | } |
46 | } |
47 | fclose(fp); |
47 | fclose(fp); |
48 | if ((psiconv_parse(buf,&psionfile))) { |
48 | if ((psiconv_parse(buf,&psionfile))) { |
49 | fprintf(stderr,"Parse error\n"); |
49 | fprintf(stderr,"Parse error\n"); |
50 | exit(1); |
50 | exit(1); |
51 | } |
51 | } |
52 | psiconv_free_buffer(buf); |
52 | psiconv_buffer_free(buf); |
53 | buf = NULL; |
53 | buf = NULL; |
54 | if (psiconv_write(&buf,psionfile)) { |
54 | if (psiconv_write(&buf,psionfile)) { |
55 | fprintf(stderr,"Parse error\n"); |
55 | fprintf(stderr,"Parse error\n"); |
56 | exit(1); |
56 | exit(1); |
57 | } |
57 | } |
58 | if (!(fp = fopen(argv[2],"w"))) { |
58 | if (!(fp = fopen(argv[2],"w"))) { |
59 | perror("Can't open file"); |
59 | perror("Can't open file"); |
60 | exit(1); |
60 | exit(1); |
61 | } |
61 | } |
62 | if ((psiconv_list_fwrite_all(buf,fp))) { |
62 | if ((psiconv_buffer_fwrite_all(buf,fp))) { |
63 | perror("Can't fwrite file"); |
63 | perror("Can't fwrite file"); |
64 | exit(1); |
64 | exit(1); |
65 | } |
65 | } |
66 | exit(0); |
66 | exit(0); |
67 | } |
67 | } |