_wmimodule.cpp.h 2.1 KB

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