/[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 46 Revision 53
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.46  
changed lines
  Added in v.53

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