Debian Codegraph @

Modules/clinic/grpmodule.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(grp_getgrgid__doc__,
12 "getgrgid($module, /, id)\n"
13 "--\n"
14 "\n"
15 "Return the group database entry for the given numeric group ID.\n"
16 "\n"
17 "If id is not valid, raise KeyError.");
18
19 #define GRP_GETGRGID_METHODDEF \
20 {"getgrgid", _PyCFunction_CAST(grp_getgrgid), METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__},
21
22 static PyObject *
23 grp_getgrgid_impl(PyObject *module, PyObject *id);
24
25 static PyObject *
26 grp_getgrgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
27 {
28 PyObject *return_value = NULL;
29 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
30
31 #define NUM_KEYWORDS 1
32 static struct {
33 PyGC_Head _this_is_not_used;
34 PyObject_VAR_HEAD
35 Py_hash_t ob_hash;
36 PyObject *ob_item[NUM_KEYWORDS];
37 } _kwtuple = {
38 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
39 .ob_hash = -1,
40 .ob_item = { &_Py_ID(id), },
41 };
42 #undef NUM_KEYWORDS
43 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
44
45 #else // !Py_BUILD_CORE
46 # define KWTUPLE NULL
47 #endif // !Py_BUILD_CORE
48
49 static const char * const _keywords[] = {"id", NULL};
50 static _PyArg_Parser _parser = {
51 .keywords = _keywords,
52 .fname = "getgrgid",
53 .kwtuple = KWTUPLE,
54 };
55 #undef KWTUPLE
56 PyObject *argsbuf[1];
57 PyObject *id;
58
59 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
60 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
61 if (!args) {
62 goto exit;
63 }
64 id = args[0];
65 return_value = grp_getgrgid_impl(module, id);
66
67 exit:
68 return return_value;
69 }
70
71 PyDoc_STRVAR(grp_getgrnam__doc__,
72 "getgrnam($module, /, name)\n"
73 "--\n"
74 "\n"
75 "Return the group database entry for the given group name.\n"
76 "\n"
77 "If name is not valid, raise KeyError.");
78
79 #define GRP_GETGRNAM_METHODDEF \
80 {"getgrnam", _PyCFunction_CAST(grp_getgrnam), METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__},
81
82 static PyObject *
83 grp_getgrnam_impl(PyObject *module, PyObject *name);
84
85 static PyObject *
86 grp_getgrnam(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
87 {
88 PyObject *return_value = NULL;
89 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
90
91 #define NUM_KEYWORDS 1
92 static struct {
93 PyGC_Head _this_is_not_used;
94 PyObject_VAR_HEAD
95 Py_hash_t ob_hash;
96 PyObject *ob_item[NUM_KEYWORDS];
97 } _kwtuple = {
98 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
99 .ob_hash = -1,
100 .ob_item = { &_Py_ID(name), },
101 };
102 #undef NUM_KEYWORDS
103 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
104
105 #else // !Py_BUILD_CORE
106 # define KWTUPLE NULL
107 #endif // !Py_BUILD_CORE
108
109 static const char * const _keywords[] = {"name", NULL};
110 static _PyArg_Parser _parser = {
111 .keywords = _keywords,
112 .fname = "getgrnam",
113 .kwtuple = KWTUPLE,
114 };
115 #undef KWTUPLE
116 PyObject *argsbuf[1];
117 PyObject *name;
118
119 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
120 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
121 if (!args) {
122 goto exit;
123 }
124 if (!PyUnicode_Check(args[0])) {
125 _PyArg_BadArgument("getgrnam", "argument 'name'", "str", args[0]);
126 goto exit;
127 }
128 name = args[0];
129 return_value = grp_getgrnam_impl(module, name);
130
131 exit:
132 return return_value;
133 }
134
135 PyDoc_STRVAR(grp_getgrall__doc__,
136 "getgrall($module, /)\n"
137 "--\n"
138 "\n"
139 "Return a list of all available group entries, in arbitrary order.\n"
140 "\n"
141 "An entry whose name starts with \'+\' or \'-\' represents an instruction\n"
142 "to use YP/NIS and may not be accessible via getgrnam or getgrgid.");
143
144 #define GRP_GETGRALL_METHODDEF \
145 {"getgrall", (PyCFunction)grp_getgrall, METH_NOARGS, grp_getgrall__doc__},
146
147 static PyObject *
148 grp_getgrall_impl(PyObject *module);
149
150 static PyObject *
151 grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored))
152 {
153 return grp_getgrall_impl(module);
154 }
155 /*[clinic end generated code: output=35aa81c00dbd3229 input=a9049054013a1b77]*/