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(PyObject *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((MD5object *)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(PyObject *self, PyObject *Py_UNUSED(ignored))
47 {
48 return MD5Type_digest_impl((MD5object *)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(PyObject *self, PyObject *Py_UNUSED(ignored))
65 {
66 return MD5Type_hexdigest_impl((MD5object *)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 static PyObject *
79 MD5Type_update_impl(MD5object *self, PyObject *obj);
80
81 static PyObject *
82 MD5Type_update(PyObject *self, PyObject *obj)
83 {
84 PyObject *return_value = NULL;
85
86 return_value = MD5Type_update_impl((MD5object *)self, obj);
87
88 return return_value;
89 }
90
91 PyDoc_STRVAR(_md5_md5__doc__,
92 "md5($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n"
93 "--\n"
94 "\n"
95 "Return a new MD5 hash object; optionally initialized with a string.");
96
97 #define _MD5_MD5_METHODDEF \
98 {"md5", _PyCFunction_CAST(_md5_md5), METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__},
99
100 static PyObject *
101 _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
102 PyObject *string_obj);
103
104 static PyObject *
105 _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
106 {
107 PyObject *return_value = NULL;
108 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
109
110 #define NUM_KEYWORDS 3
111 static struct {
112 PyGC_Head _this_is_not_used;
113 PyObject_VAR_HEAD
114 Py_hash_t ob_hash;
115 PyObject *ob_item[NUM_KEYWORDS];
116 } _kwtuple = {
117 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
118 .ob_hash = -1,
119 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
120 };
121 #undef NUM_KEYWORDS
122 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
123
124 #else // !Py_BUILD_CORE
125 # define KWTUPLE NULL
126 #endif // !Py_BUILD_CORE
127
128 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
129 static _PyArg_Parser _parser = {
130 .keywords = _keywords,
131 .fname = "md5",
132 .kwtuple = KWTUPLE,
133 };
134 #undef KWTUPLE
135 PyObject *argsbuf[3];
136 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
137 PyObject *data = NULL;
138 int usedforsecurity = 1;
139 PyObject *string_obj = NULL;
140
141 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
142 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
143 if (!args) {
144 goto exit;
145 }
146 if (!noptargs) {
147 goto skip_optional_pos;
148 }
149 if (args[0]) {
150 data = args[0];
151 if (!--noptargs) {
152 goto skip_optional_pos;
153 }
154 }
155 skip_optional_pos:
156 if (!noptargs) {
157 goto skip_optional_kwonly;
158 }
159 if (args[1]) {
160 usedforsecurity = PyObject_IsTrue(args[1]);
161 if (usedforsecurity < 0) {
162 goto exit;
163 }
164 if (!--noptargs) {
165 goto skip_optional_kwonly;
166 }
167 }
168 string_obj = args[2];
169 skip_optional_kwonly:
170 return_value = _md5_md5_impl(module, data, usedforsecurity, string_obj);
171
172 exit:
173 return return_value;
174 }
175 /*[clinic end generated code: output=920fe54b9ed06f92 input=a9049054013a1b77]*/