fnmatch_sys/
lib.rs

1#[cfg(test)]
2mod tests {
3    use super::*;
4    #[test]
5    fn all_symbols_defined() {
6        unsafe { assert!(FNM_NOMATCH > 0 || FNM_NOMATCH <= 0) };
7        unsafe { assert!(FNM_NOESCAPE > 0 || FNM_NOESCAPE <= 0) };
8        unsafe { assert!(FNM_PATHNAME > 0 || FNM_PATHNAME <= 0) };
9        unsafe { assert!(FNM_PERIOD > 0 || FNM_PERIOD <= 0) };
10        let _ = |pattern: *const c_char, string: *const c_char, flags: c_int| unsafe {
11            fnmatch(pattern, string, flags)
12        };
13    }
14}
15
16use std::os::raw::{c_char, c_int};
17
18extern "C" {
19    /// Match failed.
20    #[link_name = "fnm_nomatch"]
21    pub static FNM_NOMATCH: c_int;
22    /// Disable backslash escpaing.
23    #[link_name = "fnm_noescape"]
24    pub static FNM_NOESCAPE: c_int;
25    /// Slash must be matched by slash.
26    #[link_name = "fnm_pathname"]
27    pub static FNM_PATHNAME: c_int;
28    /// Period must be matched by period.
29    #[link_name = "fnm_period"]
30    pub static FNM_PERIOD: c_int;
31    /// The `fnmatch()` function checks whether the string argument matches the
32    /// pattern argument, which is a shell wildcard pattern (see glob(7)).
33    ///
34    /// The flags argument modifies the behavior; it is the bitwise OR of zero
35    /// or more of the following flags:
36    ///
37    ///     `FNM_NOMATCH`
38    ///     `FNM_NOESCAPE`
39    ///     `FNM_PATHNAME`
40    ///     `FNM_PERIOD`
41    ///
42    /// RETURN VALUE
43    /// Zero if string matches pattern, FNM_NOMATCH if there is no match or
44    /// another nonzero value if there is an error.
45    pub fn fnmatch(pattern: *const c_char, string: *const c_char, flags: c_int) -> c_int;
46}