Remove a few more warnings.
[suif.git] / html / suif1_105.html
blobbd244cfcca323079d4aefc988b6d7761fce55670
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.54
4 from suif1.texi on 28 April 1999 -->
6 <TITLE>The SUIF Version 1 Library - Command-Line Parser</TITLE>
7 <link href="suif1_106.html" rel=Next>
8 <link href="suif1_104.html" rel=Previous>
9 <link href="suif1_toc.html" rel=ToC>
11 </HEAD>
12 <BODY>
13 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_104.html">previous</A>, <A HREF="suif1_106.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
14 <P><HR><P>
17 <H2><A NAME="SEC105" HREF="suif1_toc.html#TOC105">Command-Line Parser</A></H2>
18 <P>
19 <A NAME="IDX743"></A>
20 <A NAME="IDX744"></A>
21 <A NAME="IDX745"></A>
22 <A NAME="IDX746"></A>
23 <A NAME="IDX747"></A>
25 </P>
26 <P>
27 The SUIF library provides a generic interface for a command line parser.
28 The parser is defined and implemented in the files <TT>`cmdparse.h'</TT> and
29 <TT>`cmdparse.cc'</TT>. The SUIF program can provide a structure that
30 contains a list of command line options, the type of arguments these
31 options can handle, and pointers to data where the argument values will
32 be stored. The data locations will be initialized to default values
33 specified in the options table before parsing begins. The
34 <CODE>parse_cmd_line</CODE> function is called with <CODE>argc</CODE>, <CODE>argv</CODE>,
35 the options table, and the number of options in the table. If the
36 parser finds one of the options on the command line, the option (and its
37 argument, if any) are removed from <CODE>argv</CODE> and <CODE>argc</CODE> is
38 appropriately adjusted. Thus when parsing is finished, <CODE>argv</CODE>
39 contains only unrecognized options (such as file names).
41 </P>
42 <P>
43 The following types of arguments are supported:
45 </P>
46 <DL COMPACT>
48 <DT><CODE>CLO_NOARG</CODE>
49 <DD>
50 No argument is expected. The default value is 0. If the argument is
51 present, the value becomes 1.
53 <DT><CODE>CLO_INT</CODE>
54 <DD>
55 A single integer is expected.
57 <DT><CODE>CLO_STRING</CODE>
58 <DD>
59 A single string is expected.
61 <DT><CODE>CLO_MULTI_STRING</CODE>
62 <DD>
63 A single string is expected for each occurrence of this option, but
64 the option can be repeated with different arguments.
65 </DL>
67 <P>
68 For example:
70 </P>
72 <PRE>
73 static boolean quiet;
74 static int size;
75 static cmd_line_option my_options[] = {
76 { CLO_NOARG, "-quiet", "", &#38;quiet },
77 { CLO_INT, "-size", "8", &#38;size }
80 parse_cmd_line(argc, argv, my_options,
81 sizeof(my_options)/sizeof(cmd_line_option));
82 </PRE>
84 <P><HR><P>
85 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_104.html">previous</A>, <A HREF="suif1_106.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
86 </BODY>
87 </HTML>