@@ -36,6 +36,17 @@ PERFORMANCE OF THIS SOFTWARE.
3636#include <sys/types.h>
3737#include <pwd.h>
3838
39+ static char pwd__doc__ [] = "\
40+ This module provides access to the Unix password database.\n\
41+ It is available on all Unix versions.\n\
42+ \n\
43+ Password database entries are reported as 7-tuples containing the following\n\
44+ items from the password database (see `<pwd.h>'), in order:\n\
45+ pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell.\n\
46+ The uid and gid items are integers, all others are strings. An\n\
47+ exception is raised if the entry asked for cannot be found." ;
48+
49+
3950static PyObject *
4051mkpwent (p )
4152 struct passwd * p ;
@@ -58,6 +69,11 @@ mkpwent(p)
5869 p -> pw_shell );
5970}
6071
72+ static char pwd_getpwuid__doc__ [] = "\
73+ getpwuid(uid) -> entry\n\
74+ Return the password database entry for the given numeric user ID.\n\
75+ See pwd.__doc__ for more on password database entries." ;
76+
6177static PyObject *
6278pwd_getpwuid (self , args )
6379 PyObject * self ;
@@ -74,6 +90,11 @@ pwd_getpwuid(self, args)
7490 return mkpwent (p );
7591}
7692
93+ static char pwd_getpwnam__doc__ [] = "\
94+ getpwnam(name) -> entry\n\
95+ Return the password database entry for the given user name.\n\
96+ See pwd.__doc__ for more on password database entries." ;
97+
7798static PyObject *
7899pwd_getpwnam (self , args )
79100 PyObject * self ;
@@ -91,6 +112,12 @@ pwd_getpwnam(self, args)
91112}
92113
93114#ifdef HAVE_GETPWENT
115+ static char pwd_getpwall__doc__ [] = "\
116+ getpwall() -> list_of_entries\n\
117+ Return a list of all available password database entries, \
118+ in arbitrary order.\n\
119+ See pwd.__doc__ for more on password database entries." ;
120+
94121static PyObject *
95122pwd_getpwall (self , args )
96123 PyObject * self ;
@@ -117,16 +144,17 @@ pwd_getpwall(self, args)
117144#endif
118145
119146static PyMethodDef pwd_methods [] = {
120- {"getpwuid" , pwd_getpwuid },
121- {"getpwnam" , pwd_getpwnam },
147+ {"getpwuid" , pwd_getpwuid , 0 , pwd_getpwuid__doc__ },
148+ {"getpwnam" , pwd_getpwnam , 0 , pwd_getpwnam__doc__ },
122149#ifdef HAVE_GETPWENT
123- {"getpwall" , pwd_getpwall },
150+ {"getpwall" , pwd_getpwall , 0 , pwd_getpwall__doc__ },
124151#endif
125152 {NULL , NULL } /* sentinel */
126153};
127154
128155void
129156initpwd ()
130157{
131- Py_InitModule ("pwd" , pwd_methods );
158+ Py_InitModule4 ("pwd" , pwd_methods , pwd__doc__ ,
159+ (PyObject * )NULL , PYTHON_API_VERSION );
132160}
0 commit comments