--- psiconv/trunk/program/psiconv/psiconv.c 2004/02/22 22:32:04 218 +++ psiconv/trunk/program/psiconv/psiconv.c 2004/02/23 13:08:32 219 @@ -56,12 +56,13 @@ puts("Syntax: psiconv [OPTIONS..] [FILE]"); puts("Convert the psion file FILE to other formats"); puts("If FILE is not specified, use stdin"); - puts(" -e, --encoding=ENC Output encoding (default: UTF8)"); - puts(" -h, --help Display this help and exit"); - puts(" -n, --noise=LEVEL Select what to print on stderr (overrides psiconv.conf)"); - puts(" -o, --outputfile Output to file instead of stdout"); - puts(" -T, --type=FILETYPE Output type (default: XHTML or TIFF"); - puts(" -V, --version Display the program version and exit"); + puts(" -c, --configfile=FILE Read extra configuration file after normal ones"); + puts(" -e, --encoding=ENC Output encoding (default: UTF8)"); + puts(" -h, --help Display this help and exit"); + puts(" -n, --noise=LEVEL Select what to print on stderr (overrides psiconv.conf)"); + puts(" -o, --outputfile Output to file instead of stdout"); + puts(" -T, --type=FILETYPE Output type (default: XHTML or TIFF"); + puts(" -V, --version Display the program version and exit"); puts(""); puts("The following encodings are currently supported:"); puts(" UTF8 Variable length Unicode encoding"); @@ -76,7 +77,7 @@ puts(" 4 or P: Progress indicators"); puts(" 5 or D: Debug data"); puts(""); - puts("The following abbreviations are used below:"); + puts("The following abbreviations are used in the output types list:"); puts(" C - processes ClipArt files"); puts(" c - processes ClipArt files containing only one image"); puts(" M - processes MBM files"); @@ -124,31 +125,31 @@ { {"help",no_argument,NULL,'h'}, {"version",no_argument,NULL,'V'}, + {"configfile",required_argument,NULL,'c'}, {"noise",required_argument,NULL,'n'}, {"outputfile",required_argument,NULL,'o'}, {"type",required_argument,NULL,'T'}, {"encoding",no_argument,NULL,'e'}, {0,0,0,0} }; - const char* short_options = "hVn:o:e:T:"; + const char* short_options = "hVn:o:e:T:c:"; int option_index; FILE * f; struct stat fbuf; const char *inputfilename = ""; const char *outputfilename = ""; + const char *extra_configfile = NULL; char *type = NULL; encoding encoding_type=ENCODING_UTF8; psiconv_list outputlist; + int verbosity = 0; int c,i,res; psiconv_buffer buf; psiconv_file file; fileformat ff = NULL; - psiconv_config config = psiconv_config_default(); - psiconv_config_read(NULL,&config); - if (!(fileformat_list = psiconv_list_new(sizeof(struct fileformat_s)))) { fputs("Out of memory error",stderr); exit(1); @@ -168,19 +169,19 @@ case 'V': print_version(); exit(0); case 'n': switch(optarg[0]) { case '1': case 'F':case 'f': - config->verbosity=PSICONV_VERB_FATAL; + verbosity=PSICONV_VERB_FATAL; break; case '2': case 'E':case 'e': - config->verbosity=PSICONV_VERB_ERROR; + verbosity=PSICONV_VERB_ERROR; break; case '3': case 'W':case 'w': - config->verbosity=PSICONV_VERB_WARN; + verbosity=PSICONV_VERB_WARN; break; case '4': case 'P':case 'p': - config->verbosity=PSICONV_VERB_PROGRESS; + verbosity=PSICONV_VERB_PROGRESS; break; case '5': case 'D':case 'd': - config->verbosity=PSICONV_VERB_DEBUG; + verbosity=PSICONV_VERB_DEBUG; break; default: fputs("Unknown noise level\n",stderr); @@ -203,6 +204,7 @@ exit(1); } break; + case 'c': extra_configfile = strdup(optarg); break; case '?': case ':': fputs("Try `-h' for more information\n",stderr); exit(1); default: fprintf(stderr,"Internal error: getopt_long returned character " @@ -220,6 +222,10 @@ exit(1); } + psiconv_config config = psiconv_config_default(); + psiconv_config_read(extra_configfile,&config); + if (verbosity) + config->verbosity = verbosity; /* Open inputfile for reading */