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

Diff of /psiconv/trunk/program/psiconv/psiconv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 34 Revision 61
34 34
35#ifdef IMAGEMAGICK 35#ifdef IMAGEMAGICK
36#include <magick/magick.h> 36#include <magick/magick.h>
37#endif 37#endif
38 38
39#include "data.h" 39#include "psiconv/data.h"
40#include "parse.h" 40#include "psiconv/parse.h"
41#include "gen.h" 41#include "gen.h"
42#include "psiconv.h" 42#include "psiconv.h"
43 43
44static void print_help(void); 44static void print_help(void);
45static void print_version(void); 45static void print_version(void);
105 FILE * f; 105 FILE * f;
106 struct stat fbuf; 106 struct stat fbuf;
107 107
108 const char *inputfilename = ""; 108 const char *inputfilename = "";
109 const char *outputfilename = ""; 109 const char *outputfilename = "";
110 char *type = strdup("HTML"); 110 char *type = strdup("HTML3");
111 int exact=0; 111 int exact=0;
112 112
113 int c,i,res; 113 int c,i,res;
114 psiconv_buffer buf; 114 psiconv_buffer buf;
115 psiconv_file file; 115 psiconv_file file;
116 psiconv_fileformat ff; 116 psiconv_fileformat ff;
117 117
118 fileformat_list = psiconv_list_new(sizeof(struct psiconv_fileformat)); 118 fileformat_list = psiconv_list_new(sizeof(struct psiconv_fileformat_s));
119 init_txt(); 119 init_txt();
120 init_html(); 120 init_html();
121 init_html4(); 121 init_html4();
122 init_rtf(); 122 init_rtf();
123 init_image(); 123 init_image();
131 case 'V': print_version(); exit(0); 131 case 'V': print_version(); exit(0);
132 case 'v': if (psiconv_verbosity < PSICONV_VERB_PROGRESS) 132 case 'v': if (psiconv_verbosity < PSICONV_VERB_PROGRESS)
133 psiconv_verbosity = PSICONV_VERB_PROGRESS; 133 psiconv_verbosity = PSICONV_VERB_PROGRESS;
134 break; 134 break;
135 case 'd': psiconv_verbosity = PSICONV_VERB_DEBUG; break; 135 case 'd': psiconv_verbosity = PSICONV_VERB_DEBUG; break;
136 case 's': psiconv_verbosity = PSICONV_VERB_SILENT; break; 136 case 's': psiconv_verbosity = PSICONV_VERB_FATAL; break;
137 case 'e': exact = 1; break; 137 case 'e': exact = 1; break;
138 case 'o': outputfilename = strdup(optarg); break; 138 case 'o': outputfilename = strdup(optarg); break;
139 case 'T': type = strdup(optarg); break; 139 case 'T': type = strdup(optarg); break;
140 case '?': case ':': fputs("Try `-h' for more information\n",stderr); 140 case '?': case ':': fputs("Try `-h' for more information\n",stderr);
141 exit(1); 141 exit(1);
178 178
179 if (psiconv_parse(buf,&file)) 179 if (psiconv_parse(buf,&file))
180 if(exact) 180 if(exact)
181 exit(1); 181 exit(1);
182 182
183 /* Open outputfile for writing */ 183 /* Set correct output file */
184 if (strlen(outputfilename) != 0) { 184 if (strlen(outputfilename) == 0)
185 f = fopen(outputfilename,"w"); 185 outputfilename = "/dev/stdout";
186 if (! f) {
187 perror(outputfilename);
188 exit(1);
189 }
190 } else
191 f = stdout;
192 186
193
194 strtoupper(type); 187 strtoupper(type);
195 for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { 188 for (i = 0; i < psiconv_list_length(fileformat_list); i ++) {
196 ff = psiconv_list_get(fileformat_list,i); 189 ff = psiconv_list_get(fileformat_list,i);
197 if (! strcmp(type,ff->name)) { 190 if (! strcmp(type,ff->name)) {
198 res = ff->output(f,file,type); 191 res = ff->output(outputfilename,file,type);
199 if (res) { 192 if (res) {
200 fprintf(stderr, 193 fprintf(stderr,
201 "Output format `%s' not permitted for this file type\n",type); 194 "Output format `%s' not permitted for this file type\n",type);
202 exit(1); 195 exit(1);
203 } 196 }
208 if (i == psiconv_list_length(fileformat_list)) { 201 if (i == psiconv_list_length(fileformat_list)) {
209 fprintf(stderr,"Unknown output type: `%s'\n",type); 202 fprintf(stderr,"Unknown output type: `%s'\n",type);
210 exit(1); 203 exit(1);
211 } 204 }
212 205
213 if (strlen(outputfilename) != 0)
214 if (fclose(f)) {
215 perror(outputfilename);
216 exit(1);
217 }
218
219 psiconv_free_file(file); 206 psiconv_free_file(file);
220 207
221 exit(0); 208 exit(0);
222} 209}

Legend:
Removed from v.34  
changed lines
  Added in v.61

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