Skip to content

Commit 2eea873

Browse files
committed
Auto merge of #3021 - devnexen:getopt_long, r=JohnTitor
adding getopt_long for unixes.
2 parents 15d2795 + 27cc898 commit 2eea873

File tree

13 files changed

+89
-4
lines changed

13 files changed

+89
-4
lines changed

libc-test/build.rs

+8
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",
@@ -2804,6 +2811,7 @@ fn test_linux(target: &str) {
28042811
"dlfcn.h",
28052812
"elf.h",
28062813
"fcntl.h",
2814+
"getopt.h",
28072815
"glob.h",
28082816
[gnu]: "gnu/libc-version.h",
28092817
"grp.h",

libc-test/semver/android.txt

+2-1
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

+2-1
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

+1
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

+1
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,7 @@ getline
16171617
getloadavg
16181618
getlocalbase
16191619
getnameinfo
1620+
getopt_long
16201621
getpagesize
16211622
getpagesizes
16221623
getpeereid

libc-test/semver/linux.txt

+1
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

+1
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

+2-1
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

+14
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

+14-1
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")]

src/unix/linux_like/android/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,13 @@ s! {
482482
pub code: ::__u16,
483483
pub absinfo: input_absinfo,
484484
}
485+
486+
pub struct option {
487+
pub name: *const ::c_char,
488+
pub has_arg: ::c_int,
489+
pub flag: *mut ::c_int,
490+
pub val: ::c_int,
491+
}
485492
}
486493

487494
s_no_extra_traits! {
@@ -3471,6 +3478,13 @@ extern "C" {
34713478

34723479
pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
34733480
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
3481+
pub fn getopt_long(
3482+
argc: ::c_int,
3483+
argv: *const *mut c_char,
3484+
optstring: *const c_char,
3485+
longopts: *const option,
3486+
longindex: *mut ::c_int,
3487+
) -> ::c_int;
34743488
}
34753489

34763490
cfg_if! {

src/unix/linux_like/linux/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,13 @@ s! {
618618
pub ifr6_prefixlen: u32,
619619
pub ifr6_ifindex: ::c_int,
620620
}
621+
622+
pub struct option {
623+
pub name: *const ::c_char,
624+
pub has_arg: ::c_int,
625+
pub flag: *mut ::c_int,
626+
pub val: ::c_int,
627+
}
621628
}
622629

623630
s_no_extra_traits! {
@@ -4441,6 +4448,13 @@ extern "C" {
44414448

44424449
pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int;
44434450
pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int;
4451+
pub fn getopt_long(
4452+
argc: ::c_int,
4453+
argv: *const *mut c_char,
4454+
optstring: *const c_char,
4455+
longopts: *const option,
4456+
longindex: *mut ::c_int,
4457+
) -> ::c_int;
44444458
}
44454459

44464460
cfg_if! {

src/unix/solarish/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,13 @@ s! {
466466
pub pi_fputypes: [::c_char; PI_FPUTYPE as usize],
467467
pub pi_clock: ::c_int,
468468
}
469+
470+
pub struct option {
471+
pub name: *const ::c_char,
472+
pub has_arg: ::c_int,
473+
pub flag: *mut ::c_int,
474+
pub val: ::c_int,
475+
}
469476
}
470477

471478
s_no_extra_traits! {
@@ -3182,6 +3189,14 @@ extern "C" {
31823189
pub fn backtrace(buffer: *mut *mut ::c_void, size: ::c_int) -> ::c_int;
31833190
pub fn backtrace_symbols(buffer: *const *mut ::c_void, size: ::c_int) -> *mut *mut ::c_char;
31843191
pub fn backtrace_symbols_fd(buffer: *const *mut ::c_void, size: ::c_int, fd: ::c_int);
3192+
3193+
pub fn getopt_long(
3194+
argc: ::c_int,
3195+
argv: *const *mut c_char,
3196+
optstring: *const c_char,
3197+
longopts: *const option,
3198+
longindex: *mut ::c_int,
3199+
) -> ::c_int;
31853200
}
31863201

31873202
#[link(name = "sendfile")]

0 commit comments

Comments
 (0)