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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 351 - (show annotations)
Wed Oct 22 19:53:40 2014 UTC (9 years, 5 months ago) by frodo
File MIME type: text/plain
File size: 1881 byte(s)
(Frodo) Update copyright year in all source files

1 /*
2 empty.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999-2014 Frodo Looijaard <frodo@frodo.looijaard.name>
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/generate.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 void help(void)
26 {
27 fprintf(stderr,"Syntax: empty TYPE FILENAME\n"
28 " TYPE may be Word or TextEd; only the first character is checked\n");
29 exit(1);
30 }
31
32 int main(int argc, char *argv[])
33 {
34 FILE *fp;
35 psiconv_buffer buf;
36 psiconv_file psionfile;
37 psiconv_file_type_t type=0;
38 psiconv_config config;
39
40
41 if (argc < 3)
42 help();
43
44 if ((argv[1][0] == 't') || (argv[1][0] == 'T'))
45 type = psiconv_texted_file;
46 else if ((argv[1][0] == 'w') || (argv[1][0] == 'W'))
47 type = psiconv_word_file;
48 else {
49 help();
50 }
51
52 config = psiconv_config_default();
53 psiconv_config_read(NULL,&config);
54 psionfile = psiconv_empty_file(type);
55
56 if (psiconv_write(config,&buf,psionfile)) {
57 fprintf(stderr,"Generate error\n");
58 exit(1);
59 }
60 if (!(fp = fopen(argv[2],"w"))) {
61 perror("Can't open file");
62 exit(1);
63 }
64 if ((psiconv_buffer_fwrite_all(buf,fp))) {
65 perror("Can't fwrite file");
66 exit(1);
67 }
68 exit(0);
69 }

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