mirror of
https://github.com/envmodules/modules.git
synced 2026-06-14 00:42:43 +08:00
202 lines
11 KiB
HTML
202 lines
11 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<!-- This HTML file generated by cxref (version 1.6a). -->
|
|
<!-- cxref program (c) Andrew M. Bishop 1995,96,97,98,99,2000,01,02,03,04,05. -->
|
|
|
|
<!--
|
|
Cxref: cxref -block-comments -verbatim-comments -xref-all -index-all -html-src -Oxref getopt.h
|
|
CPP : cxref-cpp -lang-c -C -dD -dI
|
|
-->
|
|
|
|
<HTML>
|
|
|
|
<HEAD>
|
|
<TITLE>Source File getopt.h</TITLE>
|
|
<LINK rel="stylesheet" href="cxref.css" type="text/css">
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
<pre>
|
|
<a name="line1">1 |</a> /*****
|
|
<a name="line2">2 |</a> ** ** Module Header ******************************************************* **
|
|
<a name="line3">3 |</a> ** **
|
|
<a name="line4">4 |</a> ** Modules Revision 3.0 **
|
|
<a name="line5">5 |</a> ** Providing a flexible user environment **
|
|
<a name="line6">6 |</a> ** **
|
|
<a name="line7">7 |</a> ** File: getopt.h **
|
|
<a name="line8">8 |</a> ** Revision: 1.1 **
|
|
<a name="line9">9 |</a> ** First Edition: 95/12/20 **
|
|
<a name="line10">10 |</a> ** **
|
|
<a name="line11">11 |</a> ** Authors: Jens Hamisch, Jens.Hamisch@Strawberry.COM **
|
|
<a name="line12">12 |</a> ** **
|
|
<a name="line13">13 |</a> ** Description: getopt procedure for the Modules package **
|
|
<a name="line14">14 |</a> ** **
|
|
<a name="line15">15 |</a> ** Exports: getopt Recognition of commadn line options **
|
|
<a name="line16">16 |</a> ** **
|
|
<a name="line17">17 |</a> ** Notes: This is based on the 'Getopt for GNU' from the gcc-2.7.2 **
|
|
<a name="line18">18 |</a> ** compiler. It is preferred to the libc version, because it **
|
|
<a name="line19">19 |</a> ** provides 'long-options'. **
|
|
<a name="line20">20 |</a> ** **
|
|
<a name="line21">21 |</a> ** ************************************************************************ **
|
|
<a name="line22">22 |</a> ****/
|
|
<a name="line23">23 |</a> /** **/
|
|
<a name="line24">24 |</a> /** Getopt for GNU. **/
|
|
<a name="line25">25 |</a> /** NOTE: getopt is now part of the C library, so if you don't know what **/
|
|
<a name="line26">26 |</a> /** "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu **/
|
|
<a name="line27">27 |</a> /** before changing it! **/
|
|
<a name="line28">28 |</a> /** **/
|
|
<a name="line29">29 |</a> /** Copyright( C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 **/
|
|
<a name="line30">30 |</a> /** Free Software Foundation, Inc. **/
|
|
<a name="line31">31 |</a> /** **/
|
|
<a name="line32">32 |</a> /** This program is free software; you can redistribute it and/or modify **/
|
|
<a name="line33">33 |</a> /** it under the terms of the GNU General Public License as published by **/
|
|
<a name="line34">34 |</a> /** the Free Software Foundation; either version 2, or( at your option) **/
|
|
<a name="line35">35 |</a> /** any later version. **/
|
|
<a name="line36">36 |</a> /** **/
|
|
<a name="line37">37 |</a> /** This program is distributed in the hope that it will be useful, **/
|
|
<a name="line38">38 |</a> /** but WITHOUT ANY WARRANTY; without even the implied warranty of **/
|
|
<a name="line39">39 |</a> /** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **/
|
|
<a name="line40">40 |</a> /** GNU General Public License for more details. **/
|
|
<a name="line41">41 |</a> /** **/
|
|
<a name="line42">42 |</a> /** You should have received a copy of the GNU General Public License **/
|
|
<a name="line43">43 |</a> /** along with this program; if not, write to the Free Software **/
|
|
<a name="line44">44 |</a> /** Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. **/
|
|
<a name="line45">45 |</a> /** **/
|
|
<a name="line46">46 |</a> /** ************************************************************************ **/
|
|
<a name="line47">47 |</a>
|
|
<a name="line48">48 |</a> /** ** Copyright *********************************************************** **
|
|
<a name="line49">49 |</a> ** **
|
|
<a name="line50">50 |</a> ** Copyright 1991-1994 by John L. Furlan. **
|
|
<a name="line51">51 |</a> ** see LICENSE.GPL, which must be provided, for details **
|
|
<a name="line52">52 |</a> ** **
|
|
<a name="line53">53 |</a> ** ************************************************************************ **/
|
|
<a name="line54">54 |</a>
|
|
<a name="line55">55 |</a> #ifndef _GETOPT_H
|
|
<a name="line56">56 |</a> #define _GETOPT_H 1
|
|
<a name="line57">57 |</a>
|
|
<a name="line58">58 |</a> #ifdef __cplusplus
|
|
<a name="line59">59 |</a> extern "C" {
|
|
<a name="line60">60 |</a> #endif
|
|
<a name="line61">61 |</a>
|
|
<a name="line62">62 |</a> /**
|
|
<a name="line63">63 |</a> ** For communication from `getopt' to the caller. When `getopt' finds an
|
|
<a name="line64">64 |</a> ** option that takes an argument, the argument value is returned here.
|
|
<a name="line65">65 |</a> ** Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element
|
|
<a name="line66">66 |</a> ** is returned here.
|
|
<a name="line67">67 |</a> **/
|
|
<a name="line68">68 |</a>
|
|
<a name="line69">69 |</a> extern char *optarg;
|
|
<a name="line70">70 |</a>
|
|
<a name="line71">71 |</a> /**
|
|
<a name="line72">72 |</a> ** Index in ARGV of the next element to be scanned.
|
|
<a name="line73">73 |</a> ** This is used for communication to and from the caller
|
|
<a name="line74">74 |</a> ** and for communication between successive calls to `getopt'.
|
|
<a name="line75">75 |</a> **
|
|
<a name="line76">76 |</a> ** On entry to `getopt', zero means this is the first call; initialize.
|
|
<a name="line77">77 |</a> **
|
|
<a name="line78">78 |</a> ** When `getopt' returns EOF, this is the index of the first of the
|
|
<a name="line79">79 |</a> ** non-option elements that the caller should itself scan.
|
|
<a name="line80">80 |</a> **
|
|
<a name="line81">81 |</a> ** Otherwise, `optind' communicates from one call to the next
|
|
<a name="line82">82 |</a> ** how much of ARGV has been scanned so far.
|
|
<a name="line83">83 |</a> **/
|
|
<a name="line84">84 |</a>
|
|
<a name="line85">85 |</a> extern int optind;
|
|
<a name="line86">86 |</a>
|
|
<a name="line87">87 |</a> /**
|
|
<a name="line88">88 |</a> ** Callers store zero here to inhibit the error message `getopt' prints
|
|
<a name="line89">89 |</a> ** for unrecognized options.
|
|
<a name="line90">90 |</a> **/
|
|
<a name="line91">91 |</a>
|
|
<a name="line92">92 |</a> extern int opterr;
|
|
<a name="line93">93 |</a>
|
|
<a name="line94">94 |</a> /**
|
|
<a name="line95">95 |</a> ** Set to an option character which was unrecognized.
|
|
<a name="line96">96 |</a> **/
|
|
<a name="line97">97 |</a>
|
|
<a name="line98">98 |</a> extern int optopt;
|
|
<a name="line99">99 |</a>
|
|
<a name="line100">100 |</a> /**
|
|
<a name="line101">101 |</a> ** Describe the long-named options requested by the application.
|
|
<a name="line102">102 |</a> ** The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
|
<a name="line103">103 |</a> ** of `struct option' terminated by an element containing a name which is
|
|
<a name="line104">104 |</a> ** zero.
|
|
<a name="line105">105 |</a> **
|
|
<a name="line106">106 |</a> ** The field `has_arg' is:
|
|
<a name="line107">107 |</a> ** no_argument (or 0) if the option does not take an argument,
|
|
<a name="line108">108 |</a> ** required_argument (or 1) if the option requires an argument,
|
|
<a name="line109">109 |</a> ** optional_argument (or 2) if the option takes an optional argument.
|
|
<a name="line110">110 |</a> **
|
|
<a name="line111">111 |</a> ** If the field `flag' is not NULL, it points to a variable that is set
|
|
<a name="line112">112 |</a> ** to the value given in the field `val' when the option is found, but
|
|
<a name="line113">113 |</a> ** left unchanged if the option is not found.
|
|
<a name="line114">114 |</a> **
|
|
<a name="line115">115 |</a> ** To have a long-named option do something other than set an `int' to
|
|
<a name="line116">116 |</a> ** a compiled-in constant, such as set a value from `optarg', set the
|
|
<a name="line117">117 |</a> ** option's `flag' field to zero and its `val' field to a nonzero
|
|
<a name="line118">118 |</a> ** value( the equivalent single-letter option character, if there is
|
|
<a name="line119">119 |</a> ** one). For long options that have a zero `flag' field, `getopt'
|
|
<a name="line120">120 |</a> ** returns the contents of the `val' field.
|
|
<a name="line121">121 |</a> **/
|
|
<a name="line122">122 |</a>
|
|
<a name="line123">123 |</a> struct option {
|
|
<a name="line124">124 |</a>
|
|
<a name="line125">125 |</a> #if defined( __STDC__) && __STDC__
|
|
<a name="line126">126 |</a> const char *name;
|
|
<a name="line127">127 |</a> #else
|
|
<a name="line128">128 |</a> char *name;
|
|
<a name="line129">129 |</a> #endif
|
|
<a name="line130">130 |</a>
|
|
<a name="line131">131 |</a> /**
|
|
<a name="line132">132 |</a> ** has_arg can't be an enum because some compilers complain about
|
|
<a name="line133">133 |</a> ** type mismatches in all the code that assumes it is an int.
|
|
<a name="line134">134 |</a> **/
|
|
<a name="line135">135 |</a>
|
|
<a name="line136">136 |</a> int has_arg;
|
|
<a name="line137">137 |</a> int *flag;
|
|
<a name="line138">138 |</a> int val;
|
|
<a name="line139">139 |</a> };
|
|
<a name="line140">140 |</a>
|
|
<a name="line141">141 |</a> /**
|
|
<a name="line142">142 |</a> ** Names for the values of the `has_arg' field of `struct option'.
|
|
<a name="line143">143 |</a> **/
|
|
<a name="line144">144 |</a>
|
|
<a name="line145">145 |</a> #define no_argument 0
|
|
<a name="line146">146 |</a> #define required_argument 1
|
|
<a name="line147">147 |</a> #define optional_argument 2
|
|
<a name="line148">148 |</a>
|
|
<a name="line149">149 |</a> /**
|
|
<a name="line150">150 |</a> ** Many other libraries have conflicting prototypes for getopt, with
|
|
<a name="line151">151 |</a> ** differences in the consts, in stdlib.h. To avoid compilation
|
|
<a name="line152">152 |</a> ** errors, only prototype getopt for the GNU C library.
|
|
<a name="line153">153 |</a> **/
|
|
<a name="line154">154 |</a>
|
|
<a name="line155">155 |</a> #if defined( __STDC__) && __STDC__
|
|
<a name="line156">156 |</a>
|
|
<a name="line157">157 |</a> extern int getopt( int argc, char *const *argv, const char *shortopts);
|
|
<a name="line158">158 |</a>
|
|
<a name="line159">159 |</a> extern int getopt_long( int argc, char *const *argv, const char *shortopts,
|
|
<a name="line160">160 |</a> const struct option *longopts, int *longind);
|
|
<a name="line161">161 |</a> extern int getopt_long_only( int argc, char *const *argv,
|
|
<a name="line162">162 |</a> const char *shortopts,
|
|
<a name="line163">163 |</a> const struct option *longopts, int *longind);
|
|
<a name="line164">164 |</a>
|
|
<a name="line165">165 |</a> #else /* not __STDC__ */
|
|
<a name="line166">166 |</a>
|
|
<a name="line167">167 |</a> extern int getopt();
|
|
<a name="line168">168 |</a> extern int getopt_long();
|
|
<a name="line169">169 |</a> extern int getopt_long_only();
|
|
<a name="line170">170 |</a>
|
|
<a name="line171">171 |</a> #endif /* __STDC__ */
|
|
<a name="line172">172 |</a>
|
|
<a name="line173">173 |</a> #ifdef __cplusplus
|
|
<a name="line174">174 |</a> }
|
|
<a name="line175">175 |</a> #endif
|
|
<a name="line176">176 |</a>
|
|
<a name="line177">177 |</a> #endif /* _GETOPT_H */
|
|
</pre>
|
|
|
|
</BODY>
|
|
</HTML>
|