Skip to content

Commit bbbeea4

Browse files
committed
Add fnmatch.h
Add fnmatch() function and FNM_* constants. Signed-off-by: Manos Pitsidianakis <[email protected]>
1 parent a6386af commit bbbeea4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

libc-test/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn test_apple(target: &str) {
191191
"errno.h",
192192
"execinfo.h",
193193
"fcntl.h",
194+
"fnmatch.h",
194195
"getopt.h",
195196
"glob.h",
196197
"grp.h",
@@ -454,6 +455,7 @@ fn test_openbsd(target: &str) {
454455
"errno.h",
455456
"execinfo.h",
456457
"fcntl.h",
458+
"fnmatch.h",
457459
"getopt.h",
458460
"libgen.h",
459461
"limits.h",
@@ -731,6 +733,7 @@ fn test_redox(target: &str) {
731733
"dlfcn.h",
732734
"errno.h",
733735
"fcntl.h",
736+
"fnmatch.h",
734737
"grp.h",
735738
"limits.h",
736739
"locale.h",
@@ -790,6 +793,7 @@ fn test_solarish(target: &str) {
790793
"errno.h",
791794
"execinfo.h",
792795
"fcntl.h",
796+
"fnmatch.h",
793797
"getopt.h",
794798
"glob.h",
795799
"grp.h",
@@ -1030,6 +1034,7 @@ fn test_netbsd(target: &str) {
10301034
"elf.h",
10311035
"errno.h",
10321036
"fcntl.h",
1037+
"fnmatch.h",
10331038
"getopt.h",
10341039
"libgen.h",
10351040
"limits.h",
@@ -1244,6 +1249,7 @@ fn test_dragonflybsd(target: &str) {
12441249
"errno.h",
12451250
"execinfo.h",
12461251
"fcntl.h",
1252+
"fnmatch.h",
12471253
"getopt.h",
12481254
"glob.h",
12491255
"grp.h",
@@ -1464,6 +1470,7 @@ fn test_wasi(target: &str) {
14641470
"dirent.h",
14651471
"errno.h",
14661472
"fcntl.h",
1473+
"fnmatch.h",
14671474
"langinfo.h",
14681475
"limits.h",
14691476
"locale.h",
@@ -1579,6 +1586,7 @@ fn test_android(target: &str) {
15791586
"elf.h",
15801587
"errno.h",
15811588
"fcntl.h",
1589+
"fnmatch.h",
15821590
"getopt.h",
15831591
"grp.h",
15841592
"ifaddrs.h",
@@ -2087,6 +2095,7 @@ fn test_freebsd(target: &str) {
20872095
"errno.h",
20882096
"execinfo.h",
20892097
"fcntl.h",
2098+
"fnmatch.h",
20902099
"getopt.h",
20912100
"glob.h",
20922101
"grp.h",
@@ -2706,6 +2715,7 @@ fn test_emscripten(target: &str) {
27062715
"dlfcn.h",
27072716
"errno.h",
27082717
"fcntl.h",
2718+
"fnmatch.h",
27092719
"glob.h",
27102720
"grp.h",
27112721
"ifaddrs.h",
@@ -2974,6 +2984,7 @@ fn test_neutrino(target: &str) {
29742984
"dlfcn.h",
29752985
"sys/elf.h",
29762986
"fcntl.h",
2987+
"fnmatch.h",
29772988
"glob.h",
29782989
"grp.h",
29792990
"iconv.h",
@@ -3368,6 +3379,7 @@ fn test_linux(target: &str) {
33683379
"dlfcn.h",
33693380
"elf.h",
33703381
"fcntl.h",
3382+
"fnmatch.h",
33713383
"getopt.h",
33723384
"glob.h",
33733385
[gnu]: "gnu/libc-version.h",

src/unix/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,21 @@ pub const ATF_PERM: ::c_int = 0x04;
320320
pub const ATF_PUBL: ::c_int = 0x08;
321321
pub const ATF_USETRAILERS: ::c_int = 0x10;
322322

323+
pub const FNM_PERIOD: c_int = 1 << 2;
324+
pub const FNM_CASEFOLD: c_int = 1 << 4;
325+
pub const FNM_NOMATCH: c_int = 1;
326+
327+
cfg_if! {
328+
if #[cfg(any(target_os = "macos"))] {
329+
pub const FNM_PATHNAME: c_int = 1 << 1;
330+
pub const FNM_NOESCAPE: c_int = 1 << 0;
331+
332+
} else {
333+
pub const FNM_PATHNAME: c_int = 1 << 0;
334+
pub const FNM_NOESCAPE: c_int = 1 << 1;
335+
}
336+
}
337+
323338
extern "C" {
324339
pub static in6addr_loopback: in6_addr;
325340
pub static in6addr_any: in6_addr;
@@ -1570,6 +1585,10 @@ cfg_if! {
15701585
}
15711586
}
15721587

1588+
extern "C" {
1589+
pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int;
1590+
}
1591+
15731592
cfg_if! {
15741593
if #[cfg(target_env = "newlib")] {
15751594
mod newlib;

0 commit comments

Comments
 (0)