ReactOS
0.4.16-dev-1007-g2e85425
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
getopt.c
Go to the documentation of this file.
1
/* getopt.c
2
*
3
* Copyright (c) 1992-2001 by Mike Gleason.
4
* All rights reserved.
5
*
6
*/
7
8
#include <stdio.h>
9
#include <string.h>
10
11
#include "
getopt.h
"
12
13
int
gOptErr
= 1;
/* if error message should be printed */
14
int
gOptInd
= 1;
/* index into parent argv vector */
15
int
gOptOpt
;
/* character checked for validity */
16
const
char
*
gOptArg
;
/* argument associated with option */
17
const
char
*
gOptPlace
=
kGetoptErrMsg
;
/* saved position in an arg */
18
19
/* This must be called before each Getopt. */
20
void
21
GetoptReset
(
void
)
22
{
23
gOptInd
= 1;
24
gOptPlace
=
kGetoptErrMsg
;
25
}
/* GetoptReset */
26
27
28
29
30
static
char
*
31
NextOption
(
const
char
*
const
ostr)
32
{
33
if
((
gOptOpt
= (
int
) *
gOptPlace
++) == (
int
)
':'
)
34
return
0;
35
return
strchr
(ostr,
gOptOpt
);
36
}
/* NextOption */
37
38
39
40
41
int
42
Getopt
(
int
nargc,
const
char
**
const
nargv,
const
char
*
const
ostr)
43
{
44
const
char
*oli;
/* Option letter list index */
45
46
if
(!*
gOptPlace
) {
/* update scanning pointer */
47
if
(
gOptInd
>= nargc || *(
gOptPlace
= nargv[
gOptInd
]) !=
'-'
)
48
return
(
EOF
);
49
if
(
gOptPlace
[1] && *++
gOptPlace
==
'-'
) {
/* found "--" */
50
++
gOptInd
;
51
return
(
EOF
);
52
}
53
}
/* Option letter okay? */
54
oli =
NextOption
(ostr);
55
if
(oli ==
NULL
) {
56
if
(!*
gOptPlace
)
57
++
gOptInd
;
58
if
(
gOptErr
)
59
(
void
)
fprintf
(
stderr
,
"%s%s%c\n"
, *nargv,
": illegal option -- "
,
gOptOpt
);
60
return
(
kGetoptBadChar
);
61
}
62
if
(*++oli !=
':'
) {
/* don't need argument */
63
gOptArg
=
NULL
;
64
if
(!*
gOptPlace
)
65
++
gOptInd
;
66
}
else
{
/* need an argument */
67
if
(*
gOptPlace
)
/* no white space */
68
gOptArg
=
gOptPlace
;
69
else
if
(nargc <= ++
gOptInd
) {
/* no arg */
70
gOptPlace
=
kGetoptErrMsg
;
71
if
(
gOptErr
)
72
(
void
)
fprintf
(
stderr
,
"%s%s%c\n"
, *nargv,
": option requires an argument -- "
,
gOptOpt
);
73
return
(
kGetoptBadChar
);
74
}
else
/* white space */
75
gOptArg
= nargv[
gOptInd
];
76
gOptPlace
=
kGetoptErrMsg
;
77
++
gOptInd
;
78
}
79
return
(
gOptOpt
);
/* dump back Option letter */
80
}
/* Getopt */
81
82
/* eof */
strchr
char * strchr(const char *String, int ch)
Definition:
utclib.c:501
NULL
#define NULL
Definition:
types.h:112
EOF
#define EOF
Definition:
stdio.h:24
stderr
#define stderr
Definition:
stdio.h:100
fprintf
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void
Definition:
nsiface.idl:2307
gOptErr
int gOptErr
Definition:
getopt.c:13
gOptArg
const char * gOptArg
Definition:
getopt.c:16
GetoptReset
void GetoptReset(void)
Definition:
getopt.c:21
gOptInd
int gOptInd
Definition:
getopt.c:14
gOptOpt
int gOptOpt
Definition:
getopt.c:15
NextOption
static char * NextOption(const char *const ostr)
Definition:
getopt.c:31
gOptPlace
const char * gOptPlace
Definition:
getopt.c:17
Getopt
int Getopt(int nargc, const char **const nargv, const char *const ostr)
Definition:
getopt.c:42
kGetoptErrMsg
#define kGetoptErrMsg
Definition:
getopt.h:9
kGetoptBadChar
#define kGetoptBadChar
Definition:
getopt.h:8
getopt.h
modules
rosapps
applications
net
ncftp
ncftp
getopt.c
Generated on Fri Apr 18 2025 06:17:19 for ReactOS by
1.9.6