s/qmail
3.3.23
Next generation secure email transport
sqmail-3.3.23
src
sgetopt.c
Go to the documentation of this file.
1
/* sgetopt.c, sgetopt.h: (yet another) improved getopt clone, outer layer
2
D. J. Bernstein, djb@pobox.com.
3
Depends on subgetopt.h, substdio.h, subfd.h.
4
No system requirements.
5
19970208: Cleanups.
6
931201: Baseline.
7
No known patent problems.
8
9
Documentation in sgetopt.3.
10
*/
11
12
#include "
substdio.h
"
13
#include "
subfd.h
"
14
#define SGETOPTNOSHORT
15
#include "
sgetopt.h
"
16
#define SUBGETOPTNOSHORT
17
#include "
subgetopt.h
"
18
19
#define getopt sgetoptmine
20
#define optind subgetoptind
21
#define opterr sgetopterr
22
#define optproblem subgetoptproblem
23
#define optprogname sgetoptprogname
24
25
int
opterr
= 1;
26
char
*
optprogname
= 0;
27
28
int
getopt
(argc,argv,opts)
29
int
argc;
30
char
**argv;
31
char
*opts;
32
{
33
int
c
;
34
char
*s;
35
36
if
(!
optprogname
) {
37
optprogname
= *argv;
38
if
(!
optprogname
)
optprogname
=
""
;
39
for
(s =
optprogname
;*s;++s)
if
(*s ==
'/'
)
optprogname
= s + 1;
40
}
41
c =
subgetopt
(argc,argv,opts);
42
if
(
opterr
)
43
if
(c ==
'?'
) {
44
char
chp[2]; chp[0] =
optproblem
; chp[1] =
'\n'
;
45
substdio_puts
(
subfderr
,
optprogname
);
46
if
(argv[
optind
] && (
optind
< argc))
47
substdio_puts
(
subfderr
,
": illegal option -- "
);
48
else
49
substdio_puts
(
subfderr
,
": option requires an argument -- "
);
50
substdio_put
(
subfderr
,chp,2);
51
substdio_flush
(
subfderr
);
52
}
53
return
c;
54
}
subfd.h
c
void c(char *home, char *subdir, char *file, int uid, int gid, int mode)
Definition:
install.c:57
optind
#define optind
Definition:
sgetopt.c:20
subgetopt
int subgetopt()
substdio_puts
int substdio_puts()
substdio.h
opterr
#define opterr
Definition:
sgetopt.c:21
subgetopt.h
subfderr
substdio * subfderr
Definition:
subfderr.c:7
substdio_put
int substdio_put()
sgetopt.h
optproblem
#define optproblem
Definition:
sgetopt.c:22
substdio_flush
int substdio_flush()
getopt
#define getopt
Definition:
sgetopt.c:19
optprogname
#define optprogname
Definition:
sgetopt.c:23
Generated on Sat Jan 12 2019 23:42:28 for s/qmail by
1.8.13