Debian Codegraph @

Modules/clinic/md5module.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(MD5Type_copy__doc__,
12 "copy($self, /)\n"
13 "--\n"
14 "\n"
15 "Return a copy of the hash object.");
16
17 #define MD5TYPE_COPY_METHODDEF \
18 {"copy", _PyCFunction_CAST(MD5Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__},
19
20 static PyObject *
21 MD5Type_copy_impl(MD5object *self, PyTypeObject *cls);
22
23 static PyObject *
24 MD5Type_copy(MD5object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
25 {
26 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
27 PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
28 return NULL;
29 }
30 return MD5Type_copy_impl(self, cls);
31 }
32
33 PyDoc_STRVAR(MD5Type_digest__doc__,
34 "digest($self, /)\n"
35 "--\n"
36 "\n"
37 "Return the digest value as a bytes object.");
38
39 #define MD5TYPE_DIGEST_METHODDEF \
40 {"digest", (PyCFunction)MD5Type_digest, METH_NOARGS, MD5Type_digest__doc__},
41
42 static PyObject *
43 MD5Type_digest_impl(MD5object *self);
44
45 static PyObject *
46 MD5Type_digest(MD5object *self, PyObject *Py_UNUSED(ignored))
47 {
48 return MD5Type_digest_impl(self);
49 }
50
51 PyDoc_STRVAR(MD5Type_hexdigest__doc__,
52 "hexdigest($self, /)\n"
53 "--\n"
54 "\n"
55 "Return the digest value as a string of hexadecimal digits.");
56
57 #define MD5TYPE_HEXDIGEST_METHODDEF \
58 {"hexdigest", (PyCFunction)MD5Type_hexdigest, METH_NOARGS, MD5Type_hexdigest__doc__},
59
60 static PyObject *
61 MD5Type_hexdigest_impl(MD5object *self);
62
63 static PyObject *
64 MD5Type_hexdigest(MD5object *self, PyObject *Py_UNUSED(ignored))
65 {
66 return MD5Type_hexdigest_impl(self);
67 }
68
69 PyDoc_STRVAR(MD5Type_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 MD5TYPE_UPDATE_METHODDEF \
76 {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__},
77
78 PyDoc_STRVAR(_md5_md5__doc__,
79 "md5($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n"
80 "--\n"
81 "\n"
82 "Return a new MD5 hash object; optionally initialized with a string.");
83
84 #define _MD5_MD5_METHODDEF \
85 {"md5", _PyCFunction_CAST(_md5_md5), METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__},
86
87 static PyObject *
88 _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
89 PyObject *string_obj);
90
91 static PyObject *
92 _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
93 {
94 PyObject *return_value = NULL;
95 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
96
97 #define NUM_KEYWORDS 3
98 static struct {
99 PyGC_Head _this_is_not_used;
100 PyObject_VAR_HEAD
101 PyObject *ob_item[NUM_KEYWORDS];
102 } _kwtuple = {
103 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
104 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
105 };
106 #undef NUM_KEYWORDS
107 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
108
109 #else // !Py_BUILD_CORE
110 # define KWTUPLE NULL
111 #endif // !Py_BUILD_CORE
112
113 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
114 static _PyArg_Parser _parser = {
115 .keywords = _keywords,
116 .fname = "md5",
117 .kwtuple = KWTUPLE,
118 };
119 #undef KWTUPLE
120 PyObject *argsbuf[3];
121 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
122 PyObject *data = NULL;
123 int usedforsecurity = 1;
124 PyObject *string_obj = NULL;
125
126 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
127 if (!args) {
128 goto exit;
129 }
130 if (!noptargs) {
131 goto skip_optional_pos;
132 }
133 if (args[0]) {
134 data = args[0];
135 if (!--noptargs) {
136 goto skip_optional_pos;
137 }
138 }
139 skip_optional_pos:
140 if (!noptargs) {
141 goto skip_optional_kwonly;
142 }
143 if (args[1]) {
144 usedforsecurity = PyObject_IsTrue(args[1]);
145 if (usedforsecurity < 0) {
146 goto exit;
147 }
148 if (!--noptargs) {
149 goto skip_optional_kwonly;
150 }
151 }
152 string_obj = args[2];
153 skip_optional_kwonly:
154 return_value = _md5_md5_impl(module, data, usedforsecurity, string_obj);
155
156 exit:
157 return return_value;
158 }
159 /*[clinic end generated code: output=3a2880d9fb5801cd input=a9049054013a1b77]*/