diff -r 30013dbb5bc2 Modules/spwdmodule.c --- a/Modules/spwdmodule.c Fri Jan 17 12:06:28 2014 -0500 +++ b/Modules/spwdmodule.c Fri Jan 17 14:12:45 2014 -0500 @@ -10,6 +10,10 @@ #include #endif +/*[clinic input] +module spwd +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ PyDoc_STRVAR(spwd__doc__, "This module provides access to the Unix shadow password database.\n\ @@ -107,20 +111,53 @@ #ifdef HAVE_GETSPNAM +/*[clinic input] +spwd.getspnam + + arg: unicode + / + +Return the shadow password database entry for the given user name. + +See spwd.__doc__ for more on shadow password database entries. +[clinic start generated code]*/ + PyDoc_STRVAR(spwd_getspnam__doc__, -"getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n\ - sp_warn, sp_inact, sp_expire, sp_flag)\n\ -Return the shadow password database entry for the given user name.\n\ -See spwd.__doc__ for more on shadow password database entries."); +"getspnam(arg)\n" +"Return the shadow password database entry for the given user name.\n" +"\n" +"See spwd.__doc__ for more on shadow password database entries."); -static PyObject* spwd_getspnam(PyObject *self, PyObject *args) +#define SPWD_GETSPNAM_METHODDEF \ + {"getspnam", (PyCFunction)spwd_getspnam, METH_VARARGS, spwd_getspnam__doc__}, + +static PyObject * +spwd_getspnam_impl(PyModuleDef *module, PyObject *arg); + +static PyObject * +spwd_getspnam(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *arg; + + if (!PyArg_ParseTuple(args, + "U:getspnam", + &arg)) + goto exit; + return_value = spwd_getspnam_impl(module, arg); + +exit: + return return_value; +} + +static PyObject * +spwd_getspnam_impl(PyModuleDef *module, PyObject *arg) +/*[clinic end generated code: checksum=27dea695607d1afd3caf7979ec673a3ed73d652c]*/ { char *name; struct spwd *p; - PyObject *arg, *bytes, *retval = NULL; + PyObject *bytes, *retval = NULL; - if (!PyArg_ParseTuple(args, "U:getspnam", &arg)) - return NULL; if ((bytes = PyUnicode_EncodeFSDefault(arg)) == NULL) return NULL; if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1) @@ -139,14 +176,39 @@ #ifdef HAVE_GETSPENT +/*[clinic input] +spwd.getspall + +Return a list of all available shadow password database entries, in arbitrary order. + +See spwd.__doc__ for more on shadow password database entries. +[clinic start generated code]*/ + PyDoc_STRVAR(spwd_getspall__doc__, -"getspall() -> list_of_entries\n\ -Return a list of all available shadow password database entries, \ -in arbitrary order.\n\ -See spwd.__doc__ for more on shadow password database entries."); +"getspall()\n" +"Return a list of all available shadow password database entries, in arbitrary order.\n" +"\n" +"See spwd.__doc__ for more on shadow password database entries."); + +#define SPWD_GETSPALL_METHODDEF \ + {"getspall", (PyCFunction)spwd_getspall, METH_NOARGS, spwd_getspall__doc__}, static PyObject * -spwd_getspall(PyObject *self, PyObject *args) +spwd_getspall_impl(PyModuleDef *module); + +static PyObject * +spwd_getspall(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + return_value = spwd_getspall_impl(module); + + return return_value; +} + +static PyObject * +spwd_getspall_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=7f633b75eeaa2f15311042fec7a553c95f5cf5d5]*/ { PyObject *d; struct spwd *p; @@ -171,10 +233,10 @@ static PyMethodDef spwd_methods[] = { #ifdef HAVE_GETSPNAM - {"getspnam", spwd_getspnam, METH_VARARGS, spwd_getspnam__doc__}, + SPWD_GETSPNAM_METHODDEF #endif #ifdef HAVE_GETSPENT - {"getspall", spwd_getspall, METH_NOARGS, spwd_getspall__doc__}, + SPWD_GETSPALL_METHODDEF #endif {NULL, NULL} /* sentinel */ };