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(_wmi_exec_query__doc__,
12 "exec_query($module, /, query)\n"
13 "--\n"
14 "\n"
15 "Runs a WMI query against the local machine.\n"
16 "\n"
17 "This returns a single string with \'name=value\' pairs in a flat array separated\n"
18 "by null characters.");
19
20 #define _WMI_EXEC_QUERY_METHODDEF \
21 {"exec_query", _PyCFunction_CAST(_wmi_exec_query), METH_FASTCALL|METH_KEYWORDS, _wmi_exec_query__doc__},
22
23 static PyObject *
24 _wmi_exec_query_impl(PyObject *module, PyObject *query);
25
26 static PyObject *
27 _wmi_exec_query(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
28 {
29 PyObject *return_value = NULL;
30 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
31
32 #define NUM_KEYWORDS 1
33 static struct {
34 PyGC_Head _this_is_not_used;
35 PyObject_VAR_HEAD
36 PyObject *ob_item[NUM_KEYWORDS];
37 } _kwtuple = {
38 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
39 .ob_item = { &_Py_ID(query), },
40 };
41 #undef NUM_KEYWORDS
42 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
43
44 #else // !Py_BUILD_CORE
45 # define KWTUPLE NULL
46 #endif // !Py_BUILD_CORE
47
48 static const char * const _keywords[] = {"query", NULL};
49 static _PyArg_Parser _parser = {
50 .keywords = _keywords,
51 .fname = "exec_query",
52 .kwtuple = KWTUPLE,
53 };
54 #undef KWTUPLE
55 PyObject *argsbuf[1];
56 PyObject *query;
57
58 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
59 if (!args) {
60 goto exit;
61 }
62 if (!PyUnicode_Check(args[0])) {
63 _PyArg_BadArgument("exec_query", "argument 'query'", "str", args[0]);
64 goto exit;
65 }
66 if (PyUnicode_READY(args[0]) == -1) {
67 goto exit;
68 }
69 query = args[0];
70 return_value = _wmi_exec_query_impl(module, query);
71
72 exit:
73 return return_value;
74 }
75 /*[clinic end generated code: output=7fdf0c0579ddb566 input=a9049054013a1b77]*/