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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 80 - (show annotations)
Wed Dec 27 02:12:23 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 1848 byte(s)
(Frodo) Many changes. Layout sections now work!

* Added list_empty, list_replace
* Added relocation to buffers, removed base address
* Added buffer_resolve, buffer_add_reference, buffer_add_target,
  psiconv_unique_id functions
* Modifified other buffer functions to work with references
* Added comments to buffer.h
* Added write_offset function
* Added reference support in functions where needed
* Corrected extra/rewrite error message
* Corrected numerous bugs to make layouts work.

1 /*
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 /* psiconv_verbosity = PSICONV_VERB_DEBUG; */
32
33 if (argc < 3) {
34 fprintf(stderr,"Not enough arguments\n");
35 exit(1);
36 }
37 if (!(fp = fopen(argv[1],"r"))) {
38 perror("Can't open file");
39 exit(1);
40 }
41 if (!(buf=psiconv_buffer_new())) {
42 perror("Can't allocate buf");
43 exit(1);
44 }
45 if ((psiconv_buffer_fread_all(buf,fp))) {
46 perror("Can't fread file");
47 exit(1);
48 }
49 fclose(fp);
50 if ((psiconv_parse(buf,&psionfile))) {
51 fprintf(stderr,"Parse error\n");
52 exit(1);
53 }
54
55 psiconv_buffer_free(buf);
56 buf = NULL;
57 if (psiconv_write(&buf,psionfile)) {
58 fprintf(stderr,"Generate error\n");
59 exit(1);
60 }
61 if (!(fp = fopen(argv[2],"w"))) {
62 perror("Can't open file");
63 exit(1);
64 }
65 if ((psiconv_buffer_fwrite_all(buf,fp))) {
66 perror("Can't fwrite file");
67 exit(1);
68 }
69 exit(0);
70 }

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