/[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 65 Revision 66
52 52
53 puts("Syntax: psiconv [OPTIONS..] [FILE]"); 53 puts("Syntax: psiconv [OPTIONS..] [FILE]");
54 puts("Convert the psion Word file FILE to a HTML file"); 54 puts("Convert the psion Word file FILE to a HTML file");
55 puts("If FILE is not specified, use stdin"); 55 puts("If FILE is not specified, use stdin");
56 puts(" -d, --debug Show debug information on stderr"); 56 puts(" -d, --debug Show debug information on stderr");
57 puts(" -e, --exact Quit on any parse errors or warnings");
58 puts(" -h, --help Display this help and exit"); 57 puts(" -h, --help Display this help and exit");
59 puts(" -o, --outputfile Output to file instead of stdout"); 58 puts(" -o, --outputfile Output to file instead of stdout");
60 puts(" -s, --silent Do not even show warnings on stderr"); 59 puts(" -s, --silent Do not even show warnings on stderr");
61 puts(" -T, --type=FILETYPE Output type"); 60 puts(" -T, --type=FILETYPE Output type");
62 puts(" -V, --version Display the program version and exit"); 61 puts(" -V, --version Display the program version and exit");
93 {"verbose",no_argument,NULL,'v'}, 92 {"verbose",no_argument,NULL,'v'},
94 {"debug",no_argument,NULL,'d'}, 93 {"debug",no_argument,NULL,'d'},
95 {"silent",no_argument,NULL,'s'}, 94 {"silent",no_argument,NULL,'s'},
96 {"outputfile",required_argument,NULL,'o'}, 95 {"outputfile",required_argument,NULL,'o'},
97 {"type",required_argument,NULL,'T'}, 96 {"type",required_argument,NULL,'T'},
98 {"exact",no_argument,NULL,'e'},
99 {0,0,0,0} 97 {0,0,0,0}
100 }; 98 };
101 const char* short_options = "hVvsdo:eT:"; 99 const char* short_options = "hVvsdo:eT:";
102 int option_index; 100 int option_index;
103 FILE * f; 101 FILE * f;
104 struct stat fbuf; 102 struct stat fbuf;
105 103
106 const char *inputfilename = ""; 104 const char *inputfilename = "";
107 const char *outputfilename = ""; 105 const char *outputfilename = "";
108 char *type = strdup("HTML3"); 106 char *type = strdup("HTML3");
109 int exact=0;
110 107
111 int c,i,res; 108 int c,i,res;
112 psiconv_buffer buf; 109 psiconv_buffer buf;
113 psiconv_file file; 110 psiconv_file file;
114 psiconv_fileformat ff; 111 psiconv_fileformat ff;
132 case 'v': if (psiconv_verbosity < PSICONV_VERB_PROGRESS) 129 case 'v': if (psiconv_verbosity < PSICONV_VERB_PROGRESS)
133 psiconv_verbosity = PSICONV_VERB_PROGRESS; 130 psiconv_verbosity = PSICONV_VERB_PROGRESS;
134 break; 131 break;
135 case 'd': psiconv_verbosity = PSICONV_VERB_DEBUG; break; 132 case 'd': psiconv_verbosity = PSICONV_VERB_DEBUG; break;
136 case 's': psiconv_verbosity = PSICONV_VERB_FATAL; break; 133 case 's': psiconv_verbosity = PSICONV_VERB_FATAL; break;
137 case 'e': exact = 1; break;
138 case 'o': outputfilename = strdup(optarg); break; 134 case 'o': outputfilename = strdup(optarg); break;
139 case 'T': type = strdup(optarg); break; 135 case 'T': type = strdup(optarg); break;
140 case '?': case ':': fputs("Try `-h' for more information\n",stderr); 136 case '?': case ':': fputs("Try `-h' for more information\n",stderr);
141 exit(1); 137 exit(1);
142 default: fprintf(stderr,"Internal error: getopt_long returned character " 138 default: fprintf(stderr,"Internal error: getopt_long returned character "
175 if (fclose(f)) { 171 if (fclose(f)) {
176 perror(inputfilename); 172 perror(inputfilename);
177 exit(1); 173 exit(1);
178 } 174 }
179 175
180 if (psiconv_parse(buf,&file)) 176 if (psiconv_parse(buf,&file) || (file->type == psiconv_unknown_file))
181 if(exact) 177 {
178 fprintf(stderr,"Parse error\n");
182 exit(1); 179 exit(1);
180 }
183 181
184 /* Set correct output file */ 182 /* Set correct output file */
185 if (strlen(outputfilename) == 0) 183 if (strlen(outputfilename) == 0)
186 outputfilename = "/dev/stdout"; 184 outputfilename = "/dev/stdout";
187 185

Legend:
Removed from v.65  
changed lines
  Added in v.66

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