summaryrefslogtreecommitdiff
path: root/src/unix/linux_like/linux/mod.rs
diff options
context:
space:
mode:
authorAlexander Batischev <eual.jp@gmail.com>2020-04-04 20:54:02 +0300
committerAlexander Batischev <eual.jp@gmail.com>2020-04-13 15:57:58 +0300
commitfda521b9d247098b89e48ca532bebc53462e7b3c (patch)
tree65b2c8ec15d4a1c3167580d3a520229227694dbc /src/unix/linux_like/linux/mod.rs
parent29b27da956002079bba0f9c6eb2d3ed29b8e49ab (diff)
downloadrust-libc-fda521b9d247098b89e48ca532bebc53462e7b3c.tar.gz
Add bindings for POSIX regexes
Headers I used: Oh, for reference, here are the headers I used while working on this: - musl: https://git.musl-libc.org/cgit/musl/tree/include/regex.h?id=8327ae0cb23b799bc55a45e0d4bd95f5a2b1cdf1 - glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/regex.h;h=87cce7f5cb8cc3b678467329b479bd511e250e61;hb=HEAD - macOS: https://opensource.apple.com/source/Libc/Libc-997.90.3/include/regex.h.auto.html - FreeBSD: https://github.com/freebsd/freebsd/blob/8103b0ddb041617b7cd161528f0ff93ff32970a2/include/regex.h - NetBSD: https://github.com/NetBSD/src/blob/61c8f6fbb7e38b20e862d5cb3ed2203312963283/include/regex.h
Diffstat (limited to 'src/unix/linux_like/linux/mod.rs')
-rw-r--r--src/unix/linux_like/linux/mod.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index 4f76812e8c..220b38ebd5 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -489,6 +489,11 @@ s! {
pub svm_cid: ::c_uint,
pub svm_zero: [u8; 4]
}
+
+ pub struct regmatch_t {
+ pub rm_so: regoff_t,
+ pub rm_eo: regoff_t,
+ }
}
s_no_extra_traits! {
@@ -2512,6 +2517,29 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
+pub const REG_EXTENDED: ::c_int = 1;
+pub const REG_ICASE: ::c_int = 2;
+pub const REG_NEWLINE: ::c_int = 4;
+pub const REG_NOSUB: ::c_int = 8;
+
+pub const REG_NOTBOL: ::c_int = 1;
+pub const REG_NOTEOL: ::c_int = 2;
+
+pub const REG_ENOSYS: ::c_int = -1;
+pub const REG_NOMATCH: ::c_int = 1;
+pub const REG_BADPAT: ::c_int = 2;
+pub const REG_ECOLLATE: ::c_int = 3;
+pub const REG_ECTYPE: ::c_int = 4;
+pub const REG_EESCAPE: ::c_int = 5;
+pub const REG_ESUBREG: ::c_int = 6;
+pub const REG_EBRACK: ::c_int = 7;
+pub const REG_EPAREN: ::c_int = 8;
+pub const REG_EBRACE: ::c_int = 9;
+pub const REG_BADBR: ::c_int = 10;
+pub const REG_ERANGE: ::c_int = 11;
+pub const REG_ESPACE: ::c_int = 12;
+pub const REG_BADRPT: ::c_int = 13;
+
f! {
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
@@ -3365,6 +3393,29 @@ extern "C" {
mask: u32,
) -> ::c_int;
pub fn fanotify_init(flags: ::c_uint, event_f_flags: ::c_uint) -> ::c_int;
+
+ pub fn regcomp(
+ preg: *mut ::regex_t,
+ pattern: *const ::c_char,
+ cflags: ::c_int,
+ ) -> ::c_int;
+
+ pub fn regexec(
+ preg: *const ::regex_t,
+ input: *const ::c_char,
+ nmatch: ::size_t,
+ pmatch: *mut regmatch_t,
+ eflags: ::c_int,
+ ) -> ::c_int;
+
+ pub fn regerror(
+ errcode: ::c_int,
+ preg: *const ::regex_t,
+ errbuf: *mut ::c_char,
+ errbuf_size: ::size_t,
+ ) -> ::size_t;
+
+ pub fn regfree(preg: *mut ::regex_t);
}
cfg_if! {