Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
15f3d1ea
...
15f3d1ea73e60026f8bbe7d9ce4b613a987bc17e
authored
2003-08-17 20:10:30 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mh_getopt): Implemented -version option.
1 parent
7ea39bc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
41 deletions
mh/mh_getopt.c
mh/mh_getopt.c
View file @
15f3d1e
...
...
@@ -53,51 +53,56 @@ mh_getopt (int argc, char **argv, struct mh_option *mh_opt, const char *doc)
return
0
;
}
optlen
=
strlen
(
mh_optptr
+
1
);
for
(
p
=
mh_opt
;
p
->
opt
;
p
++
)
{
if
((
p
->
match_len
<=
optlen
&&
memcmp
(
mh_optptr
+
1
,
p
->
opt
,
optlen
)
==
0
)
||
(
p
->
flags
==
MH_OPT_BOOL
&&
optlen
>
2
&&
memcmp
(
mh_optptr
+
1
,
"no"
,
2
)
==
0
&&
strlen
(
p
->
opt
)
>=
optlen
-
2
&&
memcmp
(
mh_optptr
+
3
,
p
->
opt
,
optlen
-
2
)
==
0
))
break
;
}
if
(
p
->
opt
)
if
(
strcmp
(
mh_optptr
,
"-version"
)
==
0
)
asprintf
(
&
argv
[
mh_optind
],
"--version"
);
else
{
char
*
longopt
=
p
->
opt
;
switch
(
p
->
flags
)
optlen
=
strlen
(
mh_optptr
+
1
)
;
for
(
p
=
mh_opt
;
p
->
opt
;
p
++
)
{
case
MH_OPT_BOOL
:
if
(
memcmp
(
mh_optptr
+
1
,
"no"
,
2
)
==
0
)
mh_optarg
=
"no"
;
else
mh_optarg
=
"yes"
;
asprintf
(
&
argv
[
mh_optind
],
"--%s=%s"
,
longopt
,
mh_optarg
);
break
;
case
MH_OPT_ARG
:
asprintf
(
&
argv
[
mh_optind
],
"--%s"
,
longopt
);
mh_optarg
=
argv
[
++
mh_optind
];
break
;
default:
asprintf
(
&
argv
[
mh_optind
],
"--%s"
,
longopt
);
mh_optarg
=
NULL
;
if
((
p
->
match_len
<=
optlen
&&
memcmp
(
mh_optptr
+
1
,
p
->
opt
,
optlen
)
==
0
)
||
(
p
->
flags
==
MH_OPT_BOOL
&&
optlen
>
2
&&
memcmp
(
mh_optptr
+
1
,
"no"
,
2
)
==
0
&&
strlen
(
p
->
opt
)
>=
optlen
-
2
&&
memcmp
(
mh_optptr
+
3
,
p
->
opt
,
optlen
-
2
)
==
0
))
break
;
}
mh_optind
++
;
return
1
;
}
else
if
(
!
strcmp
(
mh_optptr
+
1
,
"help"
))
{
mh_help
(
mh_opt
,
doc
);
exit
(
1
);
if
(
p
->
opt
)
{
char
*
longopt
=
p
->
opt
;
switch
(
p
->
flags
)
{
case
MH_OPT_BOOL
:
if
(
memcmp
(
mh_optptr
+
1
,
"no"
,
2
)
==
0
)
mh_optarg
=
"no"
;
else
mh_optarg
=
"yes"
;
asprintf
(
&
argv
[
mh_optind
],
"--%s=%s"
,
longopt
,
mh_optarg
);
break
;
case
MH_OPT_ARG
:
asprintf
(
&
argv
[
mh_optind
],
"--%s"
,
longopt
);
mh_optarg
=
argv
[
++
mh_optind
];
break
;
default:
asprintf
(
&
argv
[
mh_optind
],
"--%s"
,
longopt
);
mh_optarg
=
NULL
;
}
mh_optind
++
;
return
1
;
}
else
if
(
!
strcmp
(
mh_optptr
+
1
,
"help"
))
{
mh_help
(
mh_opt
,
doc
);
exit
(
1
);
}
else
mh_optind
++
;
}
else
mh_optind
++
;
return
'?'
;
}
...
...
@@ -137,6 +142,7 @@ mh_help (struct mh_option *mh_opt, const char *doc)
printf
(
"
\n
"
);
}
printf
(
" -help
\n
"
);
printf
(
" -version
\n
"
);
printf
(
_
(
"
\n
Please use GNU long options instead.
\n
"
"Run %s --help for more info on these.
\n
"
),
program_invocation_short_name
);
...
...
Please
register
or
sign in
to post a comment