Skip to content

Commit

Permalink
adding getopt_long for unixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Nov 30, 2022
1 parent e4b8fd4 commit 8b77cda
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libc-test/build.rs
Expand Up @@ -199,6 +199,7 @@ fn test_apple(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"iconv.h",
Expand Down Expand Up @@ -421,6 +422,7 @@ fn test_openbsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"libgen.h",
"limits.h",
"link.h",
Expand Down Expand Up @@ -769,6 +771,7 @@ fn test_solarish(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"ifaddrs.h",
Expand Down Expand Up @@ -997,6 +1000,7 @@ fn test_netbsd(target: &str) {
"elf.h",
"errno.h",
"fcntl.h",
"getopt.h",
"libgen.h",
"limits.h",
"link.h",
Expand Down Expand Up @@ -1208,6 +1212,7 @@ fn test_dragonflybsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"ifaddrs.h",
Expand Down Expand Up @@ -1884,6 +1889,7 @@ fn test_freebsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"iconv.h",
Expand Down Expand Up @@ -2803,6 +2809,7 @@ fn test_linux(target: &str) {
"dlfcn.h",
"elf.h",
"fcntl.h",
"getopt.h",
"glob.h",
[gnu]: "gnu/libc-version.h",
"grp.h",
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/unix.txt
Expand Up @@ -559,6 +559,7 @@ getgroups
gethostname
getlogin
getopt
getopt_long
getpeername
getpgid
getpgrp
Expand Down
14 changes: 14 additions & 0 deletions src/unix/mod.rs
Expand Up @@ -201,6 +201,13 @@ s! {
pub p_aliases: *mut *mut ::c_char,
pub p_proto: ::c_int,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

pub const INT_MIN: c_int = -2147483648;
Expand Down Expand Up @@ -881,6 +888,13 @@ extern "C" {
link_name = "getopt$UNIX2003"
)]
pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
pub fn getopt_long(
argc: ::c_int,
argv: *const *mut c_char,
optstring: *const c_char,
longopts: *const option,
longindex: *mut ::c_int,
) -> ::c_int;
pub fn getpgid(pid: pid_t) -> pid_t;
pub fn getpgrp() -> pid_t;
pub fn getpid() -> pid_t;
Expand Down

0 comments on commit 8b77cda

Please sign in to comment.