59 static int valid_option(
const EST_Option &option,
const char *arg,
61 static void standard_options(
int argc,
char **argv,
const EST_String &usage);
65 static void output_man_options(
const EST_String &usage);
66 static void output_sgml_options(
const EST_String &usage);
67 static void output_sgml_synopsis(
char **argv,
const EST_String &usage);
74 if ((al.
val(
"-N", 0) !=
"true") &&
75 ((envname =
getenv(
"IA_OP_FILE")) != 0))
80 if (al.
val(
"-c", 0) !=
"")
87 if (al.
val(
"-ops", 0) ==
"true")
115 standard_options(argc,argv,usage);
119 est_progname = argv[0];
120 parse_usage(argv[0],usage,options,al);
122 for (i=1; i < argc; i++)
126 else if (
streq(argv[i],
"-"))
128 else if (!valid_option(options,argv[i],arg))
131 EST_String(
": Unknown option \"")+argv[i]+
"\"\n");
135 if (options.
val(arg) ==
"true")
137 else if (options.
val(arg) ==
"<int>")
147 arg+
"\" not an int\n");
150 else if ((options.
val(arg) ==
"<float>") ||
151 (options.
val(arg) ==
"<double>"))
155 EST_String(
": missing float argument for \"")+
161 arg+
"\" not a float\n");
164 else if (options.
val(arg) ==
"<string>")
168 EST_String(
": missing string argument for \"")+
173 else if (options.
val(arg) ==
"<ofile>")
177 EST_String(
": missing ifile argument for \"")+
184 EST_String(
": output file not accessible \"")+
187 else if (options.
val(arg) ==
"<ifile>")
191 EST_String(
": missing ifile argument for \"")+
202 else if (options.
val(arg) ==
"<star>")
211 options.
val(argv[i])+
"\" (misparsed usage string)\n");
222 static int valid_option(
const EST_Option &options,
const char *arg,
232 if (options.
key(p) == arg)
237 else if ((options.
val(p) ==
"<star>") &&
240 sarg = options.
key(p);
281 EST_String(
": malformed default value for \"")+
282 t.
string()+
"\" (missing closing brace)\n");
297 cerr << progname << message;
298 cerr <<
"Type -h for help on options.\n";
302 static void standard_options(
int argc,
char **argv,
const EST_String &usage)
307 for (i=1; i < argc; i++)
309 if (
streq(argv[i],
"-man_options"))
311 output_man_options(usage);
314 if (
streq(argv[i],
"-sgml_options"))
316 output_sgml_options(usage);
319 if (
streq(argv[i],
"-sgml_synopsis"))
321 output_sgml_synopsis(argv, usage);
324 if ((
streq(argv[i],
"-h")) ||
325 (
streq(argv[i],
"-help")) ||
326 (
streq(argv[i],
"-?")) ||
327 (
streq(argv[i],
"--help")))
330 cout <<
"Usage: " << full.
filename() <<
" " << usage << endl;
333 if (((
streq(argv[i],
"-version")) ||
334 (
streq(argv[i],
"--version")))&&
345 static void output_man_options(
const EST_String &usage)
349 int in_options =
FALSE;
362 fprintf(stdout,
"\n.TP 8\n.BI \"%s \" ",(
const char *)t.
string());
367 fprintf(stdout,
"%s",(
const char *)ts.
get().string());
371 fprintf(stdout,
" \" {%s}\"",(
const char *)ts.
get().string());
375 fprintf(stdout,
"\n");
381 fprintf(stdout,
"\n");
382 fprintf(stdout,
"%s ",(
const char *)t.
string());
386 fprintf(stdout,
"\n");
391 static void output_sgml_options(
const EST_String &usage)
396 int in_options =
FALSE;
403 fprintf(stdout,
"<variablelist>\n");
412 fprintf(stdout,
"\n</PARA></LISTITEM>\n</varlistentry>\n\n");
413 fprintf(stdout,
"<varlistentry><term>%s</term>\n<LISTITEM><PARA>\n", (
const char *)t.
string());
421 atype = ts.
get().string();
424 fprintf(stdout,
"<replaceable>%s</replaceable>\n",
425 (
const char *) atype);
430 fprintf(stdout,
" \" {%s}\"",(
const char *)ts.
get().string());
434 fprintf(stdout,
"\n");
440 fprintf(stdout,
"\n");
441 fprintf(stdout,
"%s ",(
const char *)t.
string());
445 fprintf(stdout,
"</PARA></LISTITEM>\n</varlistentry>\n</variablelist>\n");
449 static void output_sgml_synopsis(
char **argv,
const EST_String &usage)
454 int in_options =
FALSE;
463 fprintf(stdout,
"<cmdsynopsis><command>%s</command>",
475 fprintf(stdout,
"</arg>\n");
476 fprintf(stdout,
"<arg>%s ", (
const char *)t.
string());
484 atype = ts.
get().string();
487 fprintf(stdout,
"<replaceable>%s</replaceable>",
488 (
const char *) atype);
493 fprintf(stdout,
" \" {%s}\"",(
const char *)ts.
get().string());
499 fprintf(stdout,
"</arg>\n</cmdsynopsis>\n");
507 "-o <ofile> output file" +
508 "-otype <string> output file type\n";
515 op.
set(option, al.
val(arg));
int readable_file(char *filename)
return true if this file is readable
EST_TokenStream & get(EST_Token &t)
get next token in stream
const K & key(EST_Litem *ptr, int m=1) const
find key, reference by ptr
int writable_file(char *filename)
return true if this file is writeable
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
Utility IO Function header file.
EST_String options_general(void)
The file was read in successfully.
void set_SingleCharSymbols(const EST_String &sc)
set which characters are to be treated as single character symbols
EST_Regex RXdouble("-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?")
Floating point number.
const EST_String & whitespace()
void set(const EST_String &name, int ival)
void set_PrePunctuationSymbols(const EST_String &ps)
set which characters are to be treated as (post) punctuation
int contains(EST_TList< int > &l, int n)
void option_override(EST_Features &op, EST_Option al, const EST_String &option, const EST_String &arg)
int open_string(const EST_String &newbuffer)
open a EST_TokenStream for string rather than a file
EST_Regex RXint("-?[0-9]+")
Integer.
void set_PunctuationSymbols(const EST_String &ps)
set which characters are to be treated as (post) punctuation
int gsub(const char *os, const EST_String &s)
Substitute one string for another.
EST_read_status load(const EST_String &filename, const EST_String &comment=";")
EST_TList< EST_TKVI< K, V > > list
Linked list of key-val pairs. Don't use this as it will be made private in the future.
void override_lib_ops(EST_Option &a_list, EST_Option &al)
int parse_command_line(int argc, char *argv[], const EST_String &usage, EST_StrList &files, EST_Option &al, int make_stdio)
EST_Token & peek(void)
peek at next token
const char *const est_tools_version
int init_lib_ops(EST_Option &al, EST_Option &op)
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
EST_Pathname filename(void) const
void append(const T &item)
add item onto end of list
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
const EST_String & string() const
const char *const est_name
int present(const K &rkey) const
Returns true if key is present.
EST_Token get_upto_eoln(void)
get up to s in end of line as a single token.
EST_String before(int pos, int len=0) const
Part before position.
Utility EST_String Functions header file.