Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
20cf6ddf
Commit
20cf6ddf
authored
Aug 22, 2014
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20152: Port the spwd module to Argument Clinic.
parent
04bb443e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
17 deletions
+100
-17
Modules/clinic/spwdmodule.c.h
Modules/clinic/spwdmodule.c.h
+70
-0
Modules/spwdmodule.c
Modules/spwdmodule.c
+30
-17
No files found.
Modules/clinic/spwdmodule.c.h
0 → 100644
View file @
20cf6ddf
/*[clinic input]
preserve
[clinic start generated code]*/
#if defined(HAVE_GETSPNAM)
PyDoc_STRVAR
(
spwd_getspnam__doc__
,
"getspnam($module, arg, /)
\n
"
"--
\n
"
"
\n
"
"Return the shadow password database entry for the given user name.
\n
"
"
\n
"
"See `help(spwd)` for more on shadow password database entries."
);
#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
;
}
#endif
/* defined(HAVE_GETSPNAM) */
#ifndef SPWD_GETSPNAM_METHODDEF
#define SPWD_GETSPNAM_METHODDEF
#endif
/* !defined(SPWD_GETSPNAM_METHODDEF) */
#if defined(HAVE_GETSPENT)
PyDoc_STRVAR
(
spwd_getspall__doc__
,
"getspall($module, /)
\n
"
"--
\n
"
"
\n
"
"Return a list of all available shadow password database entries, in arbitrary order.
\n
"
"
\n
"
"See `help(spwd)` for more on shadow password database entries."
);
#define SPWD_GETSPALL_METHODDEF \
{"getspall", (PyCFunction)spwd_getspall, METH_NOARGS, spwd_getspall__doc__},
static
PyObject
*
spwd_getspall_impl
(
PyModuleDef
*
module
);
static
PyObject
*
spwd_getspall
(
PyModuleDef
*
module
,
PyObject
*
Py_UNUSED
(
ignored
))
{
return
spwd_getspall_impl
(
module
);
}
#endif
/* defined(HAVE_GETSPENT) */
#ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF
#endif
/* !defined(SPWD_GETSPALL_METHODDEF) */
/*[clinic end generated code: output=41fec4a15b0cd2a0 input=a9049054013a1b77]*/
Modules/spwdmodule.c
View file @
20cf6ddf
...
...
@@ -10,6 +10,11 @@
#include <shadow.h>
#endif
/*[clinic input]
output preset file
module spwd
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b3464a3667278fae]*/
PyDoc_STRVAR
(
spwd__doc__
,
"This module provides access to the Unix shadow password database.
\n
\
...
...
@@ -107,20 +112,25 @@ static PyObject *mkspent(struct spwd *p)
#ifdef HAVE_GETSPNAM
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."
);
/*[clinic input]
spwd.getspnam
static
PyObject
*
spwd_getspnam
(
PyObject
*
self
,
PyObject
*
args
)
arg: unicode
/
Return the shadow password database entry for the given user name.
See `help(spwd)` for more on shadow password database entries.
[clinic start generated code]*/
static
PyObject
*
spwd_getspnam_impl
(
PyModuleDef
*
module
,
PyObject
*
arg
)
/*[clinic end generated code: output=9f6bbe51a4eb3b21 input=dd89429e6167a00f]*/
{
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 +149,17 @@ out:
#ifdef HAVE_GETSPENT
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."
);
/*[clinic input]
spwd.getspall
Return a list of all available shadow password database entries, in arbitrary order.
See `help(spwd)` for more on shadow password database entries.
[clinic start generated code]*/
static
PyObject
*
spwd_getspall
(
PyObject
*
self
,
PyObject
*
args
)
spwd_getspall_impl
(
PyModuleDef
*
module
)
/*[clinic end generated code: output=b12d8ec7bdb29612 input=b2c84b7857d622bd]*/
{
PyObject
*
d
;
struct
spwd
*
p
;
...
...
@@ -171,10 +184,10 @@ spwd_getspall(PyObject *self, PyObject *args)
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 */
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment