diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-05-18 12:06:25 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-05-18 16:12:08 +0200 |
commit | fa3e2fc8bb3e935c65b7043382cad1d649cb68a6 (patch) | |
tree | 43962d7c9bac68b99c55881bf917ff3249fb2119 /source4/scripting/python/pyglue.c | |
parent | 06435acf3b9afa94019f7654cda4ad9386c6384b (diff) | |
download | samba-fa3e2fc8bb3e935c65b7043382cad1d649cb68a6.tar.gz samba-fa3e2fc8bb3e935c65b7043382cad1d649cb68a6.tar.bz2 samba-fa3e2fc8bb3e935c65b7043382cad1d649cb68a6.zip |
selftest: Re-enable strings.py from source3/stf as a python subunit test
Diffstat (limited to 'source4/scripting/python/pyglue.c')
-rw-r--r-- | source4/scripting/python/pyglue.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c index 03460db8ff..0f2048aa89 100644 --- a/source4/scripting/python/pyglue.c +++ b/source4/scripting/python/pyglue.c @@ -25,6 +25,10 @@ void init_glue(void); +#ifndef Py_RETURN_NONE +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None +#endif + static PyObject *py_generate_random_str(PyObject *self, PyObject *args) { int len; @@ -173,6 +177,30 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args) return pylist; } +static PyObject *py_strcasecmp_m(PyObject *self, PyObject *args) +{ + char *s1, *s2; + + if (!PyArg_ParseTuple(args, "ss", &s1, &s2)) + return NULL; + + return PyInt_FromLong(strcasecmp_m(s1, s2)); +} + +static PyObject *py_strstr_m(PyObject *self, PyObject *args) +{ + char *s1, *s2, *ret; + + if (!PyArg_ParseTuple(args, "ss", &s1, &s2)) + return NULL; + + ret = strstr_m(s1, s2); + if (!ret) { + Py_RETURN_NONE; + } + return PyString_FromString(ret); +} + static PyMethodDef py_misc_methods[] = { { "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS, "generate_random_str(len) -> string\n" @@ -192,6 +220,10 @@ static PyMethodDef py_misc_methods[] = { "get debug level" }, { "interface_ips", (PyCFunction)py_interface_ips, METH_VARARGS, "get interface IP address list"}, + { "strcasecmp_m", (PyCFunction)py_strcasecmp_m, METH_VARARGS, + "(for testing) compare two strings using Samba's strcasecmp_m()"}, + { "strstr_m", (PyCFunction)py_strstr_m, METH_VARARGS, + "(for testing) find one string in another with Samba's strstr_m()"}, { NULL } }; |