(root)/
Python-3.12.0/
Modules/
clinic/
sha1module.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(SHA1Type_copy__doc__,
      12  "copy($self, /)\n"
      13  "--\n"
      14  "\n"
      15  "Return a copy of the hash object.");
      16  
      17  #define SHA1TYPE_COPY_METHODDEF    \
      18      {"copy", _PyCFunction_CAST(SHA1Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA1Type_copy__doc__},
      19  
      20  static PyObject *
      21  SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls);
      22  
      23  static PyObject *
      24  SHA1Type_copy(SHA1object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      25  {
      26      if (nargs) {
      27          PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
      28          return NULL;
      29      }
      30      return SHA1Type_copy_impl(self, cls);
      31  }
      32  
      33  PyDoc_STRVAR(SHA1Type_digest__doc__,
      34  "digest($self, /)\n"
      35  "--\n"
      36  "\n"
      37  "Return the digest value as a bytes object.");
      38  
      39  #define SHA1TYPE_DIGEST_METHODDEF    \
      40      {"digest", (PyCFunction)SHA1Type_digest, METH_NOARGS, SHA1Type_digest__doc__},
      41  
      42  static PyObject *
      43  SHA1Type_digest_impl(SHA1object *self);
      44  
      45  static PyObject *
      46  SHA1Type_digest(SHA1object *self, PyObject *Py_UNUSED(ignored))
      47  {
      48      return SHA1Type_digest_impl(self);
      49  }
      50  
      51  PyDoc_STRVAR(SHA1Type_hexdigest__doc__,
      52  "hexdigest($self, /)\n"
      53  "--\n"
      54  "\n"
      55  "Return the digest value as a string of hexadecimal digits.");
      56  
      57  #define SHA1TYPE_HEXDIGEST_METHODDEF    \
      58      {"hexdigest", (PyCFunction)SHA1Type_hexdigest, METH_NOARGS, SHA1Type_hexdigest__doc__},
      59  
      60  static PyObject *
      61  SHA1Type_hexdigest_impl(SHA1object *self);
      62  
      63  static PyObject *
      64  SHA1Type_hexdigest(SHA1object *self, PyObject *Py_UNUSED(ignored))
      65  {
      66      return SHA1Type_hexdigest_impl(self);
      67  }
      68  
      69  PyDoc_STRVAR(SHA1Type_update__doc__,
      70  "update($self, obj, /)\n"
      71  "--\n"
      72  "\n"
      73  "Update this hash object\'s state with the provided string.");
      74  
      75  #define SHA1TYPE_UPDATE_METHODDEF    \
      76      {"update", (PyCFunction)SHA1Type_update, METH_O, SHA1Type_update__doc__},
      77  
      78  PyDoc_STRVAR(_sha1_sha1__doc__,
      79  "sha1($module, /, string=b\'\', *, usedforsecurity=True)\n"
      80  "--\n"
      81  "\n"
      82  "Return a new SHA1 hash object; optionally initialized with a string.");
      83  
      84  #define _SHA1_SHA1_METHODDEF    \
      85      {"sha1", _PyCFunction_CAST(_sha1_sha1), METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__},
      86  
      87  static PyObject *
      88  _sha1_sha1_impl(PyObject *module, PyObject *string, int usedforsecurity);
      89  
      90  static PyObject *
      91  _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      92  {
      93      PyObject *return_value = NULL;
      94      #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      95  
      96      #define NUM_KEYWORDS 2
      97      static struct {
      98          PyGC_Head _this_is_not_used;
      99          PyObject_VAR_HEAD
     100          PyObject *ob_item[NUM_KEYWORDS];
     101      } _kwtuple = {
     102          .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     103          .ob_item = { &_Py_ID(string), &_Py_ID(usedforsecurity), },
     104      };
     105      #undef NUM_KEYWORDS
     106      #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     107  
     108      #else  // !Py_BUILD_CORE
     109      #  define KWTUPLE NULL
     110      #endif  // !Py_BUILD_CORE
     111  
     112      static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     113      static _PyArg_Parser _parser = {
     114          .keywords = _keywords,
     115          .fname = "sha1",
     116          .kwtuple = KWTUPLE,
     117      };
     118      #undef KWTUPLE
     119      PyObject *argsbuf[2];
     120      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     121      PyObject *string = NULL;
     122      int usedforsecurity = 1;
     123  
     124      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     125      if (!args) {
     126          goto exit;
     127      }
     128      if (!noptargs) {
     129          goto skip_optional_pos;
     130      }
     131      if (args[0]) {
     132          string = args[0];
     133          if (!--noptargs) {
     134              goto skip_optional_pos;
     135          }
     136      }
     137  skip_optional_pos:
     138      if (!noptargs) {
     139          goto skip_optional_kwonly;
     140      }
     141      usedforsecurity = PyObject_IsTrue(args[1]);
     142      if (usedforsecurity < 0) {
     143          goto exit;
     144      }
     145  skip_optional_kwonly:
     146      return_value = _sha1_sha1_impl(module, string, usedforsecurity);
     147  
     148  exit:
     149      return return_value;
     150  }
     151  /*[clinic end generated code: output=4d1293ca3472acdb input=a9049054013a1b77]*/