--- psiconv/trunk/program/psiconv/psiconv.c 2004/01/28 20:18:54 191 +++ psiconv/trunk/program/psiconv/psiconv.c 2004/02/02 20:43:04 192 @@ -17,22 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - 2002/Apr. Keita KAWABE - * Support for narrow build Asian Psions added. - - Now psiconv understands -u or --UTF8 option. - This option is passed to output_function as the fourth parameter - (thus the typedef of output_function was changed). - - If a called generator (gen_*.c) can handle UTF8, then it handles - the character conversion etc. accordingly. - - * psiconv seemed to want to take the argument of the options - case-insensitively (i.e. LaTeX -> LATEX), but that was not working - under my environment. Fixed it. -*/ - /* Driver program */ #include "config.h" @@ -71,14 +55,12 @@ puts("Syntax: psiconv [OPTIONS..] [FILE]"); puts("Convert the psion file FILE to other formats"); puts("If FILE is not specified, use stdin"); - puts(" -d, --debug Show debug information on stderr"); - puts(" -e, --encoding Output encoding (default: UTF8)"); + 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(" -s, --silent Do not even show warnings on stderr"); - puts(" -T, --type=FILETYPE Output type"); + puts(" -T, --type=FILETYPE Output type (default: XHTML or TIFF"); puts(" -V, --version Display the program version and exit"); - puts(" -v, --verbose Show progress indicators on stderr"); puts(""); puts("The following encodings are currently supported:"); puts(" UTF8 Variable length Unicode encoding"); @@ -86,12 +68,36 @@ puts(" Psion The encoding your Psion uses (as in psiconv.conf)"); puts(" ASCII 7-bit ASCII (other symbols are substituted by '?')"); puts(""); + puts("The following noise levels are currently supported:"); + puts(" 1 or F: Fatal errors only"); + puts(" 2 or E: Errors"); + puts(" 3 or W: Warnings"); + puts(" 4 or P: Progress indicators"); + puts(" 5 or D: Debug data"); + puts(""); + puts("The following abbreviations are used below:"); + puts(" C - processes ClipArt files"); + puts(" c - processes ClipArt files containing only one image"); + puts(" M - processes MBM files"); + puts(" m - processes MBM files containing only one image"); + puts(" S - processes Sketch files"); + puts(" T - processes TextEd files"); + puts(" W - processes Word files"); + puts(""); puts("The following output types are known:"); for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { ff = psiconv_list_get(fileformat_list,i); printf(" %s",ff->name); - for (j = strlen(ff->name); j < 15; j++) + for (j = strlen(ff->name); j < 10; j++) putchar(' '); + printf("[%c%c%c%c%c] ", + ff->supported_format & FORMAT_CLIPART_MULTIPLE?'C': + ff->supported_format & FORMAT_CLIPART_SINGLE?'c':' ', + ff->supported_format & FORMAT_MBM_MULTIPLE?'M': + ff->supported_format & FORMAT_MBM_SINGLE?'m':' ', + ff->supported_format & FORMAT_SKETCH?'S':' ', + ff->supported_format & FORMAT_TEXTED?'T':' ', + ff->supported_format & FORMAT_WORD?'W':' '); puts(ff->description); } puts(""); @@ -117,22 +123,20 @@ { {"help",no_argument,NULL,'h'}, {"version",no_argument,NULL,'V'}, - {"verbose",no_argument,NULL,'v'}, - {"debug",no_argument,NULL,'d'}, - {"silent",no_argument,NULL,'s'}, + {"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 = "hVvsdo:e:T:"; + const char* short_options = "hVn:o:e:T:"; int option_index; FILE * f; struct stat fbuf; const char *inputfilename = ""; const char *outputfilename = ""; - char *type = strdup("HTML4"); + char *type = NULL; encoding encoding_type=ENCODING_UTF8; psiconv_list outputlist; @@ -150,13 +154,9 @@ } init_txt(); - init_image(); - init_html(); -#if 0 + init_xhtml(); init_html4(); - init_latex(); - init_rtf(); -#endif + init_image(); while(1) { c = getopt_long(argc,argv,short_options, long_options, &option_index); @@ -165,11 +165,27 @@ switch(c) { case 'h': print_help(); exit(0); case 'V': print_version(); exit(0); - case 'v': if (config->verbosity < PSICONV_VERB_PROGRESS) - config->verbosity = PSICONV_VERB_PROGRESS; + case 'n': switch(optarg[0]) { + case '1': case 'F':case 'f': + config->verbosity=PSICONV_VERB_FATAL; + break; + case '2': case 'E':case 'e': + config->verbosity=PSICONV_VERB_ERROR; + break; + case '3': case 'W':case 'w': + config->verbosity=PSICONV_VERB_WARN; + break; + case '4': case 'P':case 'p': + config->verbosity=PSICONV_VERB_PROGRESS; + break; + case '5': case 'D':case 'd': + config->verbosity=PSICONV_VERB_DEBUG; + break; + default: + fputs("Unknown noise level\n",stderr); + exit(1); + } break; - case 'd': config->verbosity = PSICONV_VERB_DEBUG; break; - case 's': config->verbosity = PSICONV_VERB_ERROR; break; case 'o': outputfilename = strdup(optarg); break; case 'T': type = strdup(optarg); break; case 'e': if(!strcmp(optarg,"UTF8")) @@ -240,7 +256,20 @@ exit(1); } - strtoupper(type); + if (!type) { + switch(file->type) { + case psiconv_word_file: + case psiconv_texted_file: + default: + type = "XHTML"; break; + case psiconv_mbm_file: + case psiconv_clipart_file: + case psiconv_sketch_file: + type = "TIFF"; break; + } + } else + strtoupper(type); + for (i = 0; i < psiconv_list_length(fileformat_list); i ++) { ff = psiconv_list_get(fileformat_list,i); if (! strcasecmp(type,ff->name)) {