/src/cpython/Modules/clinic/pwdmodule.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #include "pycore_modsupport.h" // _PyArg_BadArgument() |
6 | | |
7 | | PyDoc_STRVAR(pwd_getpwuid__doc__, |
8 | | "getpwuid($module, uidobj, /)\n" |
9 | | "--\n" |
10 | | "\n" |
11 | | "Return the password database entry for the given numeric user ID.\n" |
12 | | "\n" |
13 | | "See `help(pwd)` for more on password database entries."); |
14 | | |
15 | | #define PWD_GETPWUID_METHODDEF \ |
16 | | {"getpwuid", (PyCFunction)pwd_getpwuid, METH_O, pwd_getpwuid__doc__}, |
17 | | |
18 | | static PyObject * |
19 | | pwd_getpwuid_impl(PyObject *module, uid_t uid); |
20 | | |
21 | | static PyObject * |
22 | | pwd_getpwuid(PyObject *module, PyObject *arg) |
23 | 0 | { |
24 | 0 | PyObject *return_value = NULL; |
25 | 0 | uid_t uid; |
26 | |
|
27 | 0 | if (!_Py_Uid_Converter(arg, &uid)) { |
28 | 0 | goto exit; |
29 | 0 | } |
30 | 0 | return_value = pwd_getpwuid_impl(module, uid); |
31 | |
|
32 | 0 | exit: |
33 | 0 | return return_value; |
34 | 0 | } |
35 | | |
36 | | PyDoc_STRVAR(pwd_getpwnam__doc__, |
37 | | "getpwnam($module, name, /)\n" |
38 | | "--\n" |
39 | | "\n" |
40 | | "Return the password database entry for the given user name.\n" |
41 | | "\n" |
42 | | "See `help(pwd)` for more on password database entries."); |
43 | | |
44 | | #define PWD_GETPWNAM_METHODDEF \ |
45 | | {"getpwnam", (PyCFunction)pwd_getpwnam, METH_O, pwd_getpwnam__doc__}, |
46 | | |
47 | | static PyObject * |
48 | | pwd_getpwnam_impl(PyObject *module, PyObject *name); |
49 | | |
50 | | static PyObject * |
51 | | pwd_getpwnam(PyObject *module, PyObject *arg) |
52 | 0 | { |
53 | 0 | PyObject *return_value = NULL; |
54 | 0 | PyObject *name; |
55 | |
|
56 | 0 | if (!PyUnicode_Check(arg)) { |
57 | 0 | _PyArg_BadArgument("getpwnam", "argument", "str", arg); |
58 | 0 | goto exit; |
59 | 0 | } |
60 | 0 | name = arg; |
61 | 0 | return_value = pwd_getpwnam_impl(module, name); |
62 | |
|
63 | 0 | exit: |
64 | 0 | return return_value; |
65 | 0 | } |
66 | | |
67 | | #if defined(HAVE_GETPWENT) |
68 | | |
69 | | PyDoc_STRVAR(pwd_getpwall__doc__, |
70 | | "getpwall($module, /)\n" |
71 | | "--\n" |
72 | | "\n" |
73 | | "Return a list of all available password database entries, in arbitrary order.\n" |
74 | | "\n" |
75 | | "See help(pwd) for more on password database entries."); |
76 | | |
77 | | #define PWD_GETPWALL_METHODDEF \ |
78 | | {"getpwall", (PyCFunction)pwd_getpwall, METH_NOARGS, pwd_getpwall__doc__}, |
79 | | |
80 | | static PyObject * |
81 | | pwd_getpwall_impl(PyObject *module); |
82 | | |
83 | | static PyObject * |
84 | | pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored)) |
85 | 0 | { |
86 | 0 | return pwd_getpwall_impl(module); |
87 | 0 | } |
88 | | |
89 | | #endif /* defined(HAVE_GETPWENT) */ |
90 | | |
91 | | #ifndef PWD_GETPWALL_METHODDEF |
92 | | #define PWD_GETPWALL_METHODDEF |
93 | | #endif /* !defined(PWD_GETPWALL_METHODDEF) */ |
94 | | /*[clinic end generated code: output=5bca0b2c2f4c5e89 input=a9049054013a1b77]*/ |