Skip to content

File tree

9 files changed

+163
-0
lines changed

9 files changed

+163
-0
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ fn test_apple(target: &str) {
124124
"poll.h",
125125
"pthread.h",
126126
"pwd.h",
127+
"regex.h",
127128
"resolv.h",
128129
"sched.h",
129130
"semaphore.h",
@@ -303,6 +304,7 @@ fn test_openbsd(target: &str) {
303304
"netinet/tcp.h",
304305
"netinet/udp.h",
305306
"net/bpf.h",
307+
"regex.h",
306308
"resolv.h",
307309
"pthread.h",
308310
"dlfcn.h",
@@ -903,6 +905,7 @@ fn test_netbsd(target: &str) {
903905
"poll.h",
904906
"pthread.h",
905907
"pwd.h",
908+
"regex.h",
906909
"resolv.h",
907910
"sched.h",
908911
"semaphore.h",
@@ -1098,6 +1101,7 @@ fn test_dragonflybsd(target: &str) {
10981101
"pthread.h",
10991102
"pthread_np.h",
11001103
"pwd.h",
1104+
"regex.h",
11011105
"resolv.h",
11021106
"sched.h",
11031107
"semaphore.h",
@@ -1643,6 +1647,7 @@ fn test_freebsd(target: &str) {
16431647
"pthread.h",
16441648
"pthread_np.h",
16451649
"pwd.h",
1650+
"regex.h",
16461651
"resolv.h",
16471652
"sched.h",
16481653
"semaphore.h",
@@ -2248,6 +2253,7 @@ fn test_linux(target: &str) {
22482253
"pthread.h",
22492254
"pty.h",
22502255
"pwd.h",
2256+
"regex.h",
22512257
"resolv.h",
22522258
"sched.h",
22532259
"semaphore.h",

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,9 @@ pub const TIME_OOP: ::c_int = 3;
11811181
pub const TIME_WAIT: ::c_int = 4;
11821182
pub const TIME_ERROR: ::c_int = 5;
11831183

1184+
pub const REG_ENOSYS: ::c_int = -1;
1185+
pub const REG_ILLSEQ: ::c_int = 17;
1186+
11841187
f! {
11851188
pub fn WIFCONTINUED(status: ::c_int) -> bool {
11861189
status == 0x13

src/unix/bsd/mod.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub type socklen_t = u32;
66
pub type sa_family_t = u8;
77
pub type pthread_t = ::uintptr_t;
88
pub type nfds_t = ::c_uint;
9+
pub type regoff_t = off_t;
910

1011
s! {
1112
pub struct sockaddr {
@@ -101,6 +102,18 @@ s! {
101102
pub if_index: ::c_uint,
102103
pub if_name: *mut ::c_char,
103104
}
105+
106+
pub struct regex_t {
107+
__re_magic: ::c_int,
108+
__re_nsub: ::size_t,
109+
__re_endp: *const ::c_char,
110+
__re_g: *mut ::c_void,
111+
}
112+
113+
pub struct regmatch_t {
114+
pub rm_so: regoff_t,
115+
pub rm_eo: regoff_t,
116+
}
104117
}
105118

106119
s_no_extra_traits! {
@@ -450,6 +463,41 @@ pub const BIOCGHDRCMPLT: ::c_ulong = 0x40044274;
450463
pub const BIOCSHDRCMPLT: ::c_ulong = 0x80044275;
451464
pub const SIOCGIFADDR: ::c_ulong = 0xc0206921;
452465

466+
pub const REG_BASIC: ::c_int = 0o0000;
467+
pub const REG_EXTENDED: ::c_int = 0o0001;
468+
pub const REG_ICASE: ::c_int = 0o0002;
469+
pub const REG_NOSUB: ::c_int = 0o0004;
470+
pub const REG_NEWLINE: ::c_int = 0o0010;
471+
pub const REG_NOSPEC: ::c_int = 0o0020;
472+
pub const REG_PEND: ::c_int = 0o0040;
473+
pub const REG_DUMP: ::c_int = 0o0200;
474+
475+
pub const REG_NOMATCH: ::c_int = 1;
476+
pub const REG_BADPAT: ::c_int = 2;
477+
pub const REG_ECOLLATE: ::c_int = 3;
478+
pub const REG_ECTYPE: ::c_int = 4;
479+
pub const REG_EESCAPE: ::c_int = 5;
480+
pub const REG_ESUBREG: ::c_int = 6;
481+
pub const REG_EBRACK: ::c_int = 7;
482+
pub const REG_EPAREN: ::c_int = 8;
483+
pub const REG_EBRACE: ::c_int = 9;
484+
pub const REG_BADBR: ::c_int = 10;
485+
pub const REG_ERANGE: ::c_int = 11;
486+
pub const REG_ESPACE: ::c_int = 12;
487+
pub const REG_BADRPT: ::c_int = 13;
488+
pub const REG_EMPTY: ::c_int = 14;
489+
pub const REG_ASSERT: ::c_int = 15;
490+
pub const REG_INVARG: ::c_int = 16;
491+
pub const REG_ATOI: ::c_int = 255;
492+
pub const REG_ITOA: ::c_int = 0o0400;
493+
494+
pub const REG_NOTBOL: ::c_int = 0o00001;
495+
pub const REG_NOTEOL: ::c_int = 0o00002;
496+
pub const REG_STARTEND: ::c_int = 0o00004;
497+
pub const REG_TRACE: ::c_int = 0o00400;
498+
pub const REG_LARGE: ::c_int = 0o01000;
499+
pub const REG_BACKR: ::c_int = 0o02000;
500+
453501
f! {
454502
pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
455503
if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() {
@@ -785,6 +833,29 @@ extern "C" {
785833
options: ::c_int,
786834
rusage: *mut ::rusage,
787835
) -> ::pid_t;
836+
837+
pub fn regcomp(
838+
preg: *mut regex_t,
839+
pattern: *const ::c_char,
840+
cflags: ::c_int,
841+
) -> ::c_int;
842+
843+
pub fn regexec(
844+
preg: *const regex_t,
845+
input: *const ::c_char,
846+
nmatch: ::size_t,
847+
pmatch: *mut regmatch_t,
848+
eflags: ::c_int,
849+
) -> ::c_int;
850+
851+
pub fn regerror(
852+
errcode: ::c_int,
853+
preg: *const regex_t,
854+
errbuf: *mut ::c_char,
855+
errbuf_size: ::size_t,
856+
) -> ::size_t;
857+
858+
pub fn regfree(preg: *mut regex_t);
788859
}
789860

790861
cfg_if! {

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ pub const SF_APPEND: ::c_ulong = 0x00040000;
621621

622622
pub const TIMER_ABSTIME: ::c_int = 1;
623623

624+
pub const REG_ENOSYS: ::c_int = 17;
625+
624626
#[link(name = "util")]
625627
extern "C" {
626628
pub fn setgrent();

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub type pthread_t = c_ulong;
22
pub type __priority_which_t = ::c_uint;
33
pub type __rlimit_resource_t = ::c_uint;
44
pub type Lmid_t = ::c_long;
5+
pub type regoff_t = ::c_int;
56

67
s! {
78
pub struct statx {
@@ -273,6 +274,17 @@ s! {
273274
pub __glibc_reserved3: ::c_long,
274275
pub __glibc_reserved4: ::c_long,
275276
}
277+
278+
pub struct regex_t {
279+
__buffer: *mut ::c_void,
280+
__allocated: ::size_t,
281+
__used: ::size_t,
282+
__syntax: ::c_ulong,
283+
__fastmap: *mut ::c_char,
284+
__translate: *mut ::c_char,
285+
__re_nsub: ::size_t,
286+
__bitfield: u8,
287+
}
276288
}
277289

278290
impl siginfo_t {
@@ -1127,6 +1139,12 @@ cfg_if! {
11271139
}
11281140
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
11291141

1142+
pub const REG_STARTEND: ::c_int = 4;
1143+
1144+
pub const REG_EEND: ::c_int = 14;
1145+
pub const REG_ESIZE: ::c_int = 15;
1146+
pub const REG_ERPAREN: ::c_int = 16;
1147+
11301148
extern "C" {
11311149
pub fn fgetspent_r(
11321150
fp: *mut ::FILE,

src/unix/linux_like/linux/mod.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ s! {
489489
pub svm_cid: ::c_uint,
490490
pub svm_zero: [u8; 4]
491491
}
492+
493+
pub struct regmatch_t {
494+
pub rm_so: regoff_t,
495+
pub rm_eo: regoff_t,
496+
}
492497
}
493498

494499
s_no_extra_traits! {
@@ -2512,6 +2517,29 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
25122517
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
25132518
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
25142519

2520+
pub const REG_EXTENDED: ::c_int = 1;
2521+
pub const REG_ICASE: ::c_int = 2;
2522+
pub const REG_NEWLINE: ::c_int = 4;
2523+
pub const REG_NOSUB: ::c_int = 8;
2524+
2525+
pub const REG_NOTBOL: ::c_int = 1;
2526+
pub const REG_NOTEOL: ::c_int = 2;
2527+
2528+
pub const REG_ENOSYS: ::c_int = -1;
2529+
pub const REG_NOMATCH: ::c_int = 1;
2530+
pub const REG_BADPAT: ::c_int = 2;
2531+
pub const REG_ECOLLATE: ::c_int = 3;
2532+
pub const REG_ECTYPE: ::c_int = 4;
2533+
pub const REG_EESCAPE: ::c_int = 5;
2534+
pub const REG_ESUBREG: ::c_int = 6;
2535+
pub const REG_EBRACK: ::c_int = 7;
2536+
pub const REG_EPAREN: ::c_int = 8;
2537+
pub const REG_EBRACE: ::c_int = 9;
2538+
pub const REG_BADBR: ::c_int = 10;
2539+
pub const REG_ERANGE: ::c_int = 11;
2540+
pub const REG_ESPACE: ::c_int = 12;
2541+
pub const REG_BADRPT: ::c_int = 13;
2542+
25152543
f! {
25162544
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
25172545
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
@@ -3365,6 +3393,29 @@ extern "C" {
33653393
mask: u32,
33663394
) -> ::c_int;
33673395
pub fn fanotify_init(flags: ::c_uint, event_f_flags: ::c_uint) -> ::c_int;
3396+
3397+
pub fn regcomp(
3398+
preg: *mut ::regex_t,
3399+
pattern: *const ::c_char,
3400+
cflags: ::c_int,
3401+
) -> ::c_int;
3402+
3403+
pub fn regexec(
3404+
preg: *const ::regex_t,
3405+
input: *const ::c_char,
3406+
nmatch: ::size_t,
3407+
pmatch: *mut regmatch_t,
3408+
eflags: ::c_int,
3409+
) -> ::c_int;
3410+
3411+
pub fn regerror(
3412+
errcode: ::c_int,
3413+
preg: *const ::regex_t,
3414+
errbuf: *mut ::c_char,
3415+
errbuf_size: ::size_t,
3416+
) -> ::size_t;
3417+
3418+
pub fn regfree(preg: *mut ::regex_t);
33683419
}
33693420

33703421
cfg_if! {

src/unix/linux_like/linux/musl/b32/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub type c_ulong = u32;
33
pub type nlink_t = u32;
44
pub type blksize_t = ::c_long;
55
pub type __u64 = ::c_ulonglong;
6+
pub type regoff_t = ::c_int;
67

78
s! {
89
pub struct pthread_attr_t {

src/unix/linux_like/linux/musl/b64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub type c_long = i64;
22
pub type c_ulong = u64;
3+
pub type regoff_t = ::c_long;
34

45
s! {
56
pub struct statfs64 {

src/unix/linux_like/linux/musl/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ s! {
109109
pub l_len: ::off_t,
110110
pub l_pid: ::pid_t,
111111
}
112+
113+
pub struct regex_t {
114+
__re_nsub: ::size_t,
115+
__opaque: *mut ::c_void,
116+
__padding: [*mut ::c_void; 4usize],
117+
__nsub2: ::size_t,
118+
__padding2: ::c_char,
119+
}
112120
}
113121

114122
s_no_extra_traits! {
@@ -391,6 +399,8 @@ pub const RLIMIT_MSGQUEUE: ::c_int = 12;
391399
pub const RLIMIT_NICE: ::c_int = 13;
392400
pub const RLIMIT_RTPRIO: ::c_int = 14;
393401

402+
pub const REG_OK: ::c_int = 0;
403+
394404
extern "C" {
395405
pub fn sendmmsg(
396406
sockfd: ::c_int,

0 commit comments

Comments
 (0)