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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 75 - (hide annotations)
Sun Dec 24 17:26:24 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 1792 byte(s)
(Frodo) Several things:

 * Added the extra directory to the build process, added a README.
 * Made checkuid compile cleanly
 * Added rewrite utility

1 frodo 75 /*
2     rewrite.c - Part of psiconv, a PSION 5 file formats converter
3     Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl>
4    
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
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18     */
19    
20     #include <psiconv/parse.h>
21     #include <psiconv/generate.h>
22    
23     #include <stdio.h>
24    
25     int main(int argc, char *argv[])
26     {
27     FILE *fp;
28     psiconv_buffer buf;
29     psiconv_file psionfile;
30    
31     if (argc < 3) {
32     fprintf(stderr,"Not enough arguments\n");
33     exit(1);
34     }
35     if (!(fp = fopen(argv[1],"r"))) {
36     perror("Can't open file");
37     exit(1);
38     }
39     if (!(buf=psiconv_new_buffer())) {
40     perror("Can't allocate buf");
41     exit(1);
42     }
43     if (!(psiconv_list_fread_all(buf,fp))) {
44     perror("Can't fread file");
45     exit(1);
46     }
47     fclose(fp);
48     if ((psiconv_parse(buf,&psionfile))) {
49     fprintf(stderr,"Parse error\n");
50     exit(1);
51     }
52     psiconv_free_buffer(buf);
53     buf = NULL;
54     if (psiconv_write(&buf,psionfile)) {
55     fprintf(stderr,"Parse error\n");
56     exit(1);
57     }
58     if (!(fp = fopen(argv[2],"w"))) {
59     perror("Can't open file");
60     exit(1);
61     }
62     if ((psiconv_list_fwrite_all(buf,fp))) {
63     perror("Can't fwrite file");
64     exit(1);
65     }
66     exit(0);
67     }

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