Skip to content

Commit 8b77cda

Browse files
committed
adding getopt_long for unixes.
1 parent e4b8fd4 commit 8b77cda

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

libc-test/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ fn test_apple(target: &str) {
199199
"errno.h",
200200
"execinfo.h",
201201
"fcntl.h",
202+
"getopt.h",
202203
"glob.h",
203204
"grp.h",
204205
"iconv.h",
@@ -421,6 +422,7 @@ fn test_openbsd(target: &str) {
421422
"errno.h",
422423
"execinfo.h",
423424
"fcntl.h",
425+
"getopt.h",
424426
"libgen.h",
425427
"limits.h",
426428
"link.h",
@@ -769,6 +771,7 @@ fn test_solarish(target: &str) {
769771
"errno.h",
770772
"execinfo.h",
771773
"fcntl.h",
774+
"getopt.h",
772775
"glob.h",
773776
"grp.h",
774777
"ifaddrs.h",
@@ -997,6 +1000,7 @@ fn test_netbsd(target: &str) {
9971000
"elf.h",
9981001
"errno.h",
9991002
"fcntl.h",
1003+
"getopt.h",
10001004
"libgen.h",
10011005
"limits.h",
10021006
"link.h",
@@ -1208,6 +1212,7 @@ fn test_dragonflybsd(target: &str) {
12081212
"errno.h",
12091213
"execinfo.h",
12101214
"fcntl.h",
1215+
"getopt.h",
12111216
"glob.h",
12121217
"grp.h",
12131218
"ifaddrs.h",
@@ -1884,6 +1889,7 @@ fn test_freebsd(target: &str) {
18841889
"errno.h",
18851890
"execinfo.h",
18861891
"fcntl.h",
1892+
"getopt.h",
18871893
"glob.h",
18881894
"grp.h",
18891895
"iconv.h",
@@ -2803,6 +2809,7 @@ fn test_linux(target: &str) {
28032809
"dlfcn.h",
28042810
"elf.h",
28052811
"fcntl.h",
2812+
"getopt.h",
28062813
"glob.h",
28072814
[gnu]: "gnu/libc-version.h",
28082815
"grp.h",

libc-test/semver/unix.txt

+1
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ getgroups
559559
gethostname
560560
getlogin
561561
getopt
562+
getopt_long
562563
getpeername
563564
getpgid
564565
getpgrp

src/unix/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ s! {
201201
pub p_aliases: *mut *mut ::c_char,
202202
pub p_proto: ::c_int,
203203
}
204+
205+
pub struct option {
206+
pub name: *const ::c_char,
207+
pub has_arg: ::c_int,
208+
pub flag: *mut ::c_int,
209+
pub val: ::c_int,
210+
}
204211
}
205212

206213
pub const INT_MIN: c_int = -2147483648;
@@ -881,6 +888,13 @@ extern "C" {
881888
link_name = "getopt$UNIX2003"
882889
)]
883890
pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
891+
pub fn getopt_long(
892+
argc: ::c_int,
893+
argv: *const *mut c_char,
894+
optstring: *const c_char,
895+
longopts: *const option,
896+
longindex: *mut ::c_int,
897+
) -> ::c_int;
884898
pub fn getpgid(pid: pid_t) -> pid_t;
885899
pub fn getpgrp() -> pid_t;
886900
pub fn getpid() -> pid_t;

0 commit comments

Comments
 (0)