Skip to content

Commit 27cc898

Browse files
committed
adding getopt_long for unixes.
1 parent e4b8fd4 commit 27cc898

File tree

13 files changed

+89
-4
lines changed

13 files changed

+89
-4
lines changed

libc-test/build.rs

Lines changed: 8 additions & 0 deletions
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",
@@ -1511,6 +1516,7 @@ fn test_android(target: &str) {
15111516
"elf.h",
15121517
"errno.h",
15131518
"fcntl.h",
1519+
"getopt.h",
15141520
"grp.h",
15151521
"ifaddrs.h",
15161522
"libgen.h",
@@ -1884,6 +1890,7 @@ fn test_freebsd(target: &str) {
18841890
"errno.h",
18851891
"execinfo.h",
18861892
"fcntl.h",
1893+
"getopt.h",
18871894
"glob.h",
18881895
"grp.h",
18891896
"iconv.h",
@@ -2803,6 +2810,7 @@ fn test_linux(target: &str) {
28032810
"dlfcn.h",
28042811
"elf.h",
28052812
"fcntl.h",
2813+
"getopt.h",
28062814
"glob.h",
28072815
[gnu]: "gnu/libc-version.h",
28082816
"grp.h",

libc-test/semver/android.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,6 +3026,7 @@ getline
30263026
getlogin
30273027
getnameinfo
30283028
getopt
3029+
getopt_long
30293030
getpeername
30303031
getpgid
30313032
getpgrp
@@ -3594,4 +3595,4 @@ wmemchr
35943595
write
35953596
writev
35963597
dirname
3597-
basename
3598+
basename

libc-test/semver/apple.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,7 @@ getline
18951895
getloadavg
18961896
getmntinfo
18971897
getnameinfo
1898+
getopt_long
18981899
getpeereid
18991900
getpriority
19001901
getprogname
@@ -2228,4 +2229,4 @@ waitid
22282229
xsw_usage
22292230
xucred
22302231
dirname
2231-
basename
2232+
basename

libc-test/semver/dragonfly.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ getlastlogx
12941294
getline
12951295
getloadavg
12961296
getnameinfo
1297+
getopt_long
12971298
getpeereid
12981299
getpriority
12991300
getprogname

libc-test/semver/freebsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ getline
15991599
getloadavg
16001600
getlocalbase
16011601
getnameinfo
1602+
getopt_long
16021603
getpagesize
16031604
getpagesizes
16041605
getpeereid

libc-test/semver/linux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,6 +2967,7 @@ getifaddrs
29672967
getline
29682968
getmntent
29692969
getnameinfo
2970+
getopt_long
29702971
getpriority
29712972
getpwent
29722973
getresgid

libc-test/semver/netbsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ getlastlogx
12541254
getline
12551255
getloadavg
12561256
getnameinfo
1257+
getopt_long
12571258
getpeereid
12581259
getpriority
12591260
getprogname

libc-test/semver/openbsd.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ getline
10401040
getloadavg
10411041
getmntinfo
10421042
getnameinfo
1043+
getopt_long
10431044
getpeereid
10441045
getpriority
10451046
getprogname
@@ -1232,4 +1233,4 @@ utrace
12321233
wait4
12331234
xucred
12341235
dirname
1235-
basename
1236+
basename

src/unix/bsd/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ s! {
115115
pub rm_so: regoff_t,
116116
pub rm_eo: regoff_t,
117117
}
118+
119+
pub struct option {
120+
pub name: *const ::c_char,
121+
pub has_arg: ::c_int,
122+
pub flag: *mut ::c_int,
123+
pub val: ::c_int,
124+
}
118125
}
119126

120127
s_no_extra_traits! {
@@ -885,6 +892,13 @@ extern "C" {
885892
pub fn srand48(seed: ::c_long);
886893
pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
887894
pub fn lcong48(p: *mut ::c_ushort);
895+
pub fn getopt_long(
896+
argc: ::c_int,
897+
argv: *const *mut c_char,
898+
optstring: *const c_char,
899+
longopts: *const option,
900+
longindex: *mut ::c_int,
901+
) -> ::c_int;
888902
}
889903

890904
cfg_if! {

src/unix/haiku/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ s! {
430430
pub key: *mut ::c_char,
431431
pub data: *mut ::c_void,
432432
}
433+
434+
pub struct option {
435+
pub name: *const ::c_char,
436+
pub has_arg: ::c_int,
437+
pub flag: *mut ::c_int,
438+
pub val: ::c_int,
439+
}
433440
}
434441

435442
s_no_extra_traits! {
@@ -1971,7 +1978,13 @@ extern "C" {
19711978
attr: *mut posix_spawnattr_t,
19721979
sigmask: *const ::sigset_t,
19731980
) -> ::c_int;
1974-
1981+
pub fn getopt_long(
1982+
argc: ::c_int,
1983+
argv: *const *mut c_char,
1984+
optstring: *const c_char,
1985+
longopts: *const option,
1986+
longindex: *mut ::c_int,
1987+
) -> ::c_int;
19751988
}
19761989

19771990
#[link(name = "bsd")]

0 commit comments

Comments
 (0)