Skip to content

Commit c6c865e

Browse files
authored
Merge pull request #1862 from fornwall/android-regex
2 parents 83b3730 + a848efd commit c6c865e

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ fn test_android(target: &str) {
14011401
"pthread.h",
14021402
"pty.h",
14031403
"pwd.h",
1404+
"regex.h",
14041405
"resolv.h",
14051406
"sched.h",
14061407
"semaphore.h",

src/unix/linux_like/android/mod.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ s! {
224224
pub ee_info: u32,
225225
pub ee_data: u32,
226226
}
227+
228+
pub struct regex_t {
229+
re_magic: ::c_int,
230+
re_nsub: ::size_t,
231+
re_endp: *const ::c_char,
232+
re_guts: *mut ::c_void,
233+
}
234+
235+
pub struct regmatch_t {
236+
pub rm_so: ::ssize_t,
237+
pub rm_eo: ::ssize_t,
238+
}
227239
}
228240

229241
s_no_extra_traits! {
@@ -1241,6 +1253,41 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
12411253
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
12421254
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
12431255

1256+
pub const REG_BASIC: ::c_int = 0;
1257+
pub const REG_EXTENDED: ::c_int = 1;
1258+
pub const REG_ICASE: ::c_int = 2;
1259+
pub const REG_NOSUB: ::c_int = 4;
1260+
pub const REG_NEWLINE: ::c_int = 8;
1261+
pub const REG_NOSPEC: ::c_int = 16;
1262+
pub const REG_PEND: ::c_int = 32;
1263+
pub const REG_DUMP: ::c_int = 128;
1264+
1265+
pub const REG_NOMATCH: ::c_int = 1;
1266+
pub const REG_BADPAT: ::c_int = 2;
1267+
pub const REG_ECOLLATE: ::c_int = 3;
1268+
pub const REG_ECTYPE: ::c_int = 4;
1269+
pub const REG_EESCAPE: ::c_int = 5;
1270+
pub const REG_ESUBREG: ::c_int = 6;
1271+
pub const REG_EBRACK: ::c_int = 7;
1272+
pub const REG_EPAREN: ::c_int = 8;
1273+
pub const REG_EBRACE: ::c_int = 9;
1274+
pub const REG_BADBR: ::c_int = 10;
1275+
pub const REG_ERANGE: ::c_int = 11;
1276+
pub const REG_ESPACE: ::c_int = 12;
1277+
pub const REG_BADRPT: ::c_int = 13;
1278+
pub const REG_EMPTY: ::c_int = 14;
1279+
pub const REG_ASSERT: ::c_int = 15;
1280+
pub const REG_INVARG: ::c_int = 16;
1281+
pub const REG_ATOI: ::c_int = 255;
1282+
pub const REG_ITOA: ::c_int = 256;
1283+
1284+
pub const REG_NOTBOL: ::c_int = 1;
1285+
pub const REG_NOTEOL: ::c_int = 2;
1286+
pub const REG_STARTEND: ::c_int = 4;
1287+
pub const REG_TRACE: ::c_int = 256;
1288+
pub const REG_LARGE: ::c_int = 512;
1289+
pub const REG_BACKR: ::c_int = 1024;
1290+
12441291
pub const MCL_CURRENT: ::c_int = 0x0001;
12451292
pub const MCL_FUTURE: ::c_int = 0x0002;
12461293

@@ -2661,6 +2708,29 @@ extern "C" {
26612708
path: *const ::c_char,
26622709
mask: u32,
26632710
) -> ::c_int;
2711+
2712+
pub fn regcomp(
2713+
preg: *mut ::regex_t,
2714+
pattern: *const ::c_char,
2715+
cflags: ::c_int,
2716+
) -> ::c_int;
2717+
2718+
pub fn regexec(
2719+
preg: *const ::regex_t,
2720+
input: *const ::c_char,
2721+
nmatch: ::size_t,
2722+
pmatch: *mut regmatch_t,
2723+
eflags: ::c_int,
2724+
) -> ::c_int;
2725+
2726+
pub fn regerror(
2727+
errcode: ::c_int,
2728+
preg: *const ::regex_t,
2729+
errbuf: *mut ::c_char,
2730+
errbuf_size: ::size_t,
2731+
) -> ::size_t;
2732+
2733+
pub fn regfree(preg: *mut ::regex_t);
26642734
}
26652735

26662736
cfg_if! {

0 commit comments

Comments
 (0)