1 |
frodo |
88 |
/* |
2 |
|
|
empty.c - Part of psiconv, a PSION 5 file formats converter |
3 |
frodo |
270 |
Copyright (c) 1999-2004 Frodo Looijaard <frodo@frodo.looijaard.name> |
4 |
frodo |
88 |
|
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 |
frodo |
168 |
#include <stdlib.h> |
24 |
frodo |
88 |
|
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 |
frodo |
168 |
psiconv_config config; |
39 |
frodo |
88 |
|
40 |
frodo |
168 |
|
41 |
frodo |
88 |
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 |
frodo |
180 |
config = psiconv_config_default(); |
53 |
|
|
psiconv_config_read(NULL,&config); |
54 |
frodo |
88 |
psionfile = psiconv_empty_file(type); |
55 |
|
|
|
56 |
frodo |
168 |
if (psiconv_write(config,&buf,psionfile)) { |
57 |
frodo |
88 |
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 |
|
|
} |