(root)/
Python-3.12.0/
Modules/
clinic/
grpmodule.c.h
       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  
      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          PyObject *ob_item[NUM_KEYWORDS];
      36      } _kwtuple = {
      37          .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      38          .ob_item = { &_Py_ID(id), },
      39      };
      40      #undef NUM_KEYWORDS
      41      #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      42  
      43      #else  // !Py_BUILD_CORE
      44      #  define KWTUPLE NULL
      45      #endif  // !Py_BUILD_CORE
      46  
      47      static const char * const _keywords[] = {"id", NULL};
      48      static _PyArg_Parser _parser = {
      49          .keywords = _keywords,
      50          .fname = "getgrgid",
      51          .kwtuple = KWTUPLE,
      52      };
      53      #undef KWTUPLE
      54      PyObject *argsbuf[1];
      55      PyObject *id;
      56  
      57      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
      58      if (!args) {
      59          goto exit;
      60      }
      61      id = args[0];
      62      return_value = grp_getgrgid_impl(module, id);
      63  
      64  exit:
      65      return return_value;
      66  }
      67  
      68  PyDoc_STRVAR(grp_getgrnam__doc__,
      69  "getgrnam($module, /, name)\n"
      70  "--\n"
      71  "\n"
      72  "Return the group database entry for the given group name.\n"
      73  "\n"
      74  "If name is not valid, raise KeyError.");
      75  
      76  #define GRP_GETGRNAM_METHODDEF    \
      77      {"getgrnam", _PyCFunction_CAST(grp_getgrnam), METH_FASTCALL|METH_KEYWORDS, grp_getgrnam__doc__},
      78  
      79  static PyObject *
      80  grp_getgrnam_impl(PyObject *module, PyObject *name);
      81  
      82  static PyObject *
      83  grp_getgrnam(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      84  {
      85      PyObject *return_value = NULL;
      86      #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      87  
      88      #define NUM_KEYWORDS 1
      89      static struct {
      90          PyGC_Head _this_is_not_used;
      91          PyObject_VAR_HEAD
      92          PyObject *ob_item[NUM_KEYWORDS];
      93      } _kwtuple = {
      94          .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      95          .ob_item = { &_Py_ID(name), },
      96      };
      97      #undef NUM_KEYWORDS
      98      #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      99  
     100      #else  // !Py_BUILD_CORE
     101      #  define KWTUPLE NULL
     102      #endif  // !Py_BUILD_CORE
     103  
     104      static const char * const _keywords[] = {"name", NULL};
     105      static _PyArg_Parser _parser = {
     106          .keywords = _keywords,
     107          .fname = "getgrnam",
     108          .kwtuple = KWTUPLE,
     109      };
     110      #undef KWTUPLE
     111      PyObject *argsbuf[1];
     112      PyObject *name;
     113  
     114      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     115      if (!args) {
     116          goto exit;
     117      }
     118      if (!PyUnicode_Check(args[0])) {
     119          _PyArg_BadArgument("getgrnam", "argument 'name'", "str", args[0]);
     120          goto exit;
     121      }
     122      if (PyUnicode_READY(args[0]) == -1) {
     123          goto exit;
     124      }
     125      name = args[0];
     126      return_value = grp_getgrnam_impl(module, name);
     127  
     128  exit:
     129      return return_value;
     130  }
     131  
     132  PyDoc_STRVAR(grp_getgrall__doc__,
     133  "getgrall($module, /)\n"
     134  "--\n"
     135  "\n"
     136  "Return a list of all available group entries, in arbitrary order.\n"
     137  "\n"
     138  "An entry whose name starts with \'+\' or \'-\' represents an instruction\n"
     139  "to use YP/NIS and may not be accessible via getgrnam or getgrgid.");
     140  
     141  #define GRP_GETGRALL_METHODDEF    \
     142      {"getgrall", (PyCFunction)grp_getgrall, METH_NOARGS, grp_getgrall__doc__},
     143  
     144  static PyObject *
     145  grp_getgrall_impl(PyObject *module);
     146  
     147  static PyObject *
     148  grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored))
     149  {
     150      return grp_getgrall_impl(module);
     151  }
     152  /*[clinic end generated code: output=0916fdbcdeaf5d7d input=a9049054013a1b77]*/