--- psiconv/trunk/program/psiconv/psiconv.c 1999/12/04 21:46:45 46 +++ psiconv/trunk/program/psiconv/psiconv.c 2000/12/15 01:16:43 65 @@ -36,8 +36,8 @@ #include #endif -#include "data.h" -#include "parse.h" +#include "psiconv/data.h" +#include "psiconv/parse.h" #include "gen.h" #include "psiconv.h" @@ -45,8 +45,6 @@ static void print_version(void); static void strtoupper(char *str); -int psiconv_verbosity = PSICONV_VERB_WARN; - void print_help(void) { psiconv_fileformat ff; @@ -115,7 +113,9 @@ psiconv_file file; psiconv_fileformat ff; - fileformat_list = psiconv_list_new(sizeof(struct psiconv_fileformat)); + psiconv_verbosity = PSICONV_VERB_WARN; + + fileformat_list = psiconv_list_new(sizeof(struct psiconv_fileformat_s)); init_txt(); init_html(); init_html4(); @@ -133,7 +133,7 @@ psiconv_verbosity = PSICONV_VERB_PROGRESS; break; case 'd': psiconv_verbosity = PSICONV_VERB_DEBUG; break; - case 's': psiconv_verbosity = PSICONV_VERB_SILENT; break; + case 's': psiconv_verbosity = PSICONV_VERB_FATAL; break; case 'e': exact = 1; break; case 'o': outputfilename = strdup(optarg); break; case 'T': type = strdup(optarg); break; @@ -151,6 +151,7 @@ } else if (optind == argc-1) inputfilename = strdup(argv[optind]); + /* Open inputfile for reading */ if (strlen(inputfilename) != 0) { @@ -180,22 +181,15 @@ if(exact) exit(1); - /* Open outputfile for writing */ - if (strlen(outputfilename) != 0) { - f = fopen(outputfilename,"w"); - if (! f) { - perror(outputfilename); - exit(1); - } - } else - f = stdout; + /* Set correct output file */ + if (strlen(outputfilename) == 0) + outputfilename = "/dev/stdout"; - strtoupper(type); for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { ff = psiconv_list_get(fileformat_list,i); if (! strcmp(type,ff->name)) { - res = ff->output(f,file,type); + res = ff->output(outputfilename,file,type); if (res) { fprintf(stderr, "Output format `%s' not permitted for this file type\n",type); @@ -210,12 +204,6 @@ exit(1); } - if (strlen(outputfilename) != 0) - if (fclose(f)) { - perror(outputfilename); - exit(1); - } - psiconv_free_file(file); exit(0);