diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-21 04:10:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:29:51 -0500 |
commit | 4163622a0b30cd4f8ab2467e3bf8f8ba87ec2c5a (patch) | |
tree | 0f6b5ae188be8917abeef80c7adf7c5218103107 /source4 | |
parent | 6173fad23171add5b1d143f6c15fb36842811135 (diff) | |
download | samba-4163622a0b30cd4f8ab2467e3bf8f8ba87ec2c5a.tar.gz samba-4163622a0b30cd4f8ab2467e3bf8f8ba87ec2c5a.tar.bz2 samba-4163622a0b30cd4f8ab2467e3bf8f8ba87ec2c5a.zip |
r8661: added strstr() ejs function in string lib
(This used to be commit a569fc8924e8c8edbdfa7efc89ad99659af8c379)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/ejs/smbcalls_string.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c index 3d386abe2e..cd5db1f574 100644 --- a/source4/scripting/ejs/smbcalls_string.c +++ b/source4/scripting/ejs/smbcalls_string.c @@ -75,6 +75,22 @@ static int ejs_strupper(MprVarHandle eid, int argc, char **argv) /* usage: + var s = strstr(string, substring); +*/ +static int ejs_strstr(MprVarHandle eid, int argc, char **argv) +{ + char *s; + if (argc != 2) { + ejsSetErrorMsg(eid, "strstr invalid arguments"); + return -1; + } + s = strstr(argv[0], argv[1]); + mpr_Return(eid, mprString(s)); + return 0; +} + +/* + usage: list = split(".", "a.foo.bar"); NOTE: does not take a regular expression, unlink perl split() @@ -330,6 +346,7 @@ static int ejs_string_init(MprVarHandle eid, int argc, struct MprVar **argv) mprSetStringCFunction(obj, "strlen", ejs_strlen); mprSetStringCFunction(obj, "strlower", ejs_strlower); mprSetStringCFunction(obj, "strupper", ejs_strupper); + mprSetStringCFunction(obj, "strstr", ejs_strstr); mprSetStringCFunction(obj, "split", ejs_split); mprSetCFunction(obj, "join", ejs_join); mprSetCFunction(obj, "sprintf", ejs_sprintf); |