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