250 lines
6.3 KiB
Groff
250 lines
6.3 KiB
Groff
|
.\" Copyright (c) 1988, 1991, 1993
|
|||
|
.\" The Regents of the University of California. All rights reserved.
|
|||
|
.\"
|
|||
|
.\" Redistribution and use in source and binary forms, with or without
|
|||
|
.\" modification, are permitted provided that the following conditions
|
|||
|
.\" are met:
|
|||
|
.\" 1. Redistributions of source code must retain the above copyright
|
|||
|
.\" notice, this list of conditions and the following disclaimer.
|
|||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|||
|
.\" notice, this list of conditions and the following disclaimer in the
|
|||
|
.\" documentation and/or other materials provided with the distribution.
|
|||
|
.\" 3. All advertising materials mentioning features or use of this software
|
|||
|
.\" must display the following acknowledgement:
|
|||
|
.\" This product includes software developed by the University of
|
|||
|
.\" California, Berkeley and its contributors.
|
|||
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|||
|
.\" may be used to endorse or promote products derived from this software
|
|||
|
.\" without specific prior written permission.
|
|||
|
.\"
|
|||
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|||
|
.\" SUCH DAMAGE.
|
|||
|
.\"
|
|||
|
.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
|
|||
|
.\"
|
|||
|
.Dd April 27, 1995
|
|||
|
.Dt GETOPT 3
|
|||
|
.Os BSD 4.3
|
|||
|
.Sh ̾<EFBFBD><EFBFBD>
|
|||
|
.Nm getopt
|
|||
|
.Nd <EFBFBD><EFBFBD><EFBFBD>ޥ<EFBFBD><EFBFBD>ɥ饤<EFBFBD><EFBFBD><EFBFBD>ΰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꥹ<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD>ץ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Sh <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Fd #include <unistd.h>
|
|||
|
.Vt extern char *optarg;
|
|||
|
.Vt extern int optind;
|
|||
|
.Vt extern int optopt;
|
|||
|
.Vt extern int opterr;
|
|||
|
.Vt extern int optreset;
|
|||
|
.Ft int
|
|||
|
.Fn getopt "int argc" "char * const *argv" "const char *optstring"
|
|||
|
.Sh <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Fn getopt
|
|||
|
<EFBFBD>ؿ<EFBFBD><EFBFBD>ϥ<EFBFBD><EFBFBD>ޥ<EFBFBD><EFBFBD>ɥ饤<EFBFBD><EFBFBD><EFBFBD>ΰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꥹ<EFBFBD><EFBFBD>
|
|||
|
.Fa argv
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>༡Ū<EFBFBD>˲<EFBFBD><EFBFBD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<EFBFBD>ʥ<EFBFBD><EFBFBD>顼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>餹<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Sh <EFBFBD><EFBFBD>ĥ
|
|||
|
.Fn getopt
|
|||
|
<EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƤӽФ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ˤ<EFBFBD><EFBFBD>뤿<EFBFBD>ᡢ
|
|||
|
.Va optreset
|
|||
|
<EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɲä<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.St -p1003.2
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ʤؤγ<EFBFBD>ĥ<EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Sh <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Bd -literal -compact
|
|||
|
extern char *optarg;
|
|||
|
extern int optind;
|
|||
|
int bflag, ch, fd;
|
|||
|
|
|||
|
bflag = 0;
|
|||
|
while ((ch = getopt(argc, argv, "bf:")) != -1)
|
|||
|
switch (ch) {
|
|||
|
case 'b':
|
|||
|
bflag = 1;
|
|||
|
break;
|
|||
|
case 'f':
|
|||
|
if ((fd = open(optarg, O_RDONLY, 0)) < 0) {
|
|||
|
(void)fprintf(stderr,
|
|||
|
"myname: %s: %s\en", optarg, strerror(errno));
|
|||
|
exit(1);
|
|||
|
}
|
|||
|
break;
|
|||
|
case '?':
|
|||
|
default:
|
|||
|
usage();
|
|||
|
}
|
|||
|
argc -= optind;
|
|||
|
argv += optind;
|
|||
|
.Ed
|
|||
|
.Sh <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Fn getopt
|
|||
|
<EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Bx 4.3
|
|||
|
<EFBFBD>Ǻǽ<EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Sh <EFBFBD>Х<EFBFBD>
|
|||
|
.Fn getopt
|
|||
|
<EFBFBD>ؿ<EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>ä<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\-1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Dv EOF
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>褦<EFBFBD>˻<EFBFBD><EFBFBD>ꤵ<EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD>
|
|||
|
.Fn getopt
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
.Aq Pa stdio.h
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڤ<EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥǡ<EFBFBD>
|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<EFBFBD><EFBFBD>٤<EFBFBD><EFBFBD>ǤϤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD≯ߴ<EFBFBD><EFBFBD>Τ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Em <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD>¸<EFBFBD>ߤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥե饰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۤȤ<EFBFBD><EFBFBD>ɤξ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.Bd -literal -offset indent
|
|||
|
int length;
|
|||
|
char *p;
|
|||
|
|
|||
|
while ((ch = getopt(argc, argv, "0123456789")) != -1)
|
|||
|
switch (ch) {
|
|||
|
case '0': case '1': case '2': case '3': case '4':
|
|||
|
case '5': case '6': case '7': case '8': case '9':
|
|||
|
p = argv[optind - 1];
|
|||
|
if (p[0] == '-' && p[1] == ch && !p[2])
|
|||
|
length = atoi(++p);
|
|||
|
else
|
|||
|
length = atoi(argv[optind] + 1);
|
|||
|
break;
|
|||
|
}
|
|||
|
.Ed
|