overlapped.c.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  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(_overlapped_CreateIoCompletionPort__doc__,
  9. "CreateIoCompletionPort($module, handle, port, key, concurrency, /)\n"
  10. "--\n"
  11. "\n"
  12. "Create a completion port or register a handle with a port.");
  13. #define _OVERLAPPED_CREATEIOCOMPLETIONPORT_METHODDEF \
  14. {"CreateIoCompletionPort", _PyCFunction_CAST(_overlapped_CreateIoCompletionPort), METH_FASTCALL, _overlapped_CreateIoCompletionPort__doc__},
  15. static PyObject *
  16. _overlapped_CreateIoCompletionPort_impl(PyObject *module, HANDLE FileHandle,
  17. HANDLE ExistingCompletionPort,
  18. ULONG_PTR CompletionKey,
  19. DWORD NumberOfConcurrentThreads);
  20. static PyObject *
  21. _overlapped_CreateIoCompletionPort(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  22. {
  23. PyObject *return_value = NULL;
  24. HANDLE FileHandle;
  25. HANDLE ExistingCompletionPort;
  26. ULONG_PTR CompletionKey;
  27. DWORD NumberOfConcurrentThreads;
  28. if (!_PyArg_CheckPositional("CreateIoCompletionPort", nargs, 4, 4)) {
  29. goto exit;
  30. }
  31. FileHandle = PyLong_AsVoidPtr(args[0]);
  32. if (!FileHandle && PyErr_Occurred()) {
  33. goto exit;
  34. }
  35. ExistingCompletionPort = PyLong_AsVoidPtr(args[1]);
  36. if (!ExistingCompletionPort && PyErr_Occurred()) {
  37. goto exit;
  38. }
  39. CompletionKey = (uintptr_t)PyLong_AsVoidPtr(args[2]);
  40. if (!CompletionKey && PyErr_Occurred()) {
  41. goto exit;
  42. }
  43. if (!_PyLong_UnsignedLong_Converter(args[3], &NumberOfConcurrentThreads)) {
  44. goto exit;
  45. }
  46. return_value = _overlapped_CreateIoCompletionPort_impl(module, FileHandle, ExistingCompletionPort, CompletionKey, NumberOfConcurrentThreads);
  47. exit:
  48. return return_value;
  49. }
  50. PyDoc_STRVAR(_overlapped_GetQueuedCompletionStatus__doc__,
  51. "GetQueuedCompletionStatus($module, port, msecs, /)\n"
  52. "--\n"
  53. "\n"
  54. "Get a message from completion port.\n"
  55. "\n"
  56. "Wait for up to msecs milliseconds.");
  57. #define _OVERLAPPED_GETQUEUEDCOMPLETIONSTATUS_METHODDEF \
  58. {"GetQueuedCompletionStatus", _PyCFunction_CAST(_overlapped_GetQueuedCompletionStatus), METH_FASTCALL, _overlapped_GetQueuedCompletionStatus__doc__},
  59. static PyObject *
  60. _overlapped_GetQueuedCompletionStatus_impl(PyObject *module,
  61. HANDLE CompletionPort,
  62. DWORD Milliseconds);
  63. static PyObject *
  64. _overlapped_GetQueuedCompletionStatus(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  65. {
  66. PyObject *return_value = NULL;
  67. HANDLE CompletionPort;
  68. DWORD Milliseconds;
  69. if (!_PyArg_CheckPositional("GetQueuedCompletionStatus", nargs, 2, 2)) {
  70. goto exit;
  71. }
  72. CompletionPort = PyLong_AsVoidPtr(args[0]);
  73. if (!CompletionPort && PyErr_Occurred()) {
  74. goto exit;
  75. }
  76. if (!_PyLong_UnsignedLong_Converter(args[1], &Milliseconds)) {
  77. goto exit;
  78. }
  79. return_value = _overlapped_GetQueuedCompletionStatus_impl(module, CompletionPort, Milliseconds);
  80. exit:
  81. return return_value;
  82. }
  83. PyDoc_STRVAR(_overlapped_PostQueuedCompletionStatus__doc__,
  84. "PostQueuedCompletionStatus($module, port, bytes, key, address, /)\n"
  85. "--\n"
  86. "\n"
  87. "Post a message to completion port.");
  88. #define _OVERLAPPED_POSTQUEUEDCOMPLETIONSTATUS_METHODDEF \
  89. {"PostQueuedCompletionStatus", _PyCFunction_CAST(_overlapped_PostQueuedCompletionStatus), METH_FASTCALL, _overlapped_PostQueuedCompletionStatus__doc__},
  90. static PyObject *
  91. _overlapped_PostQueuedCompletionStatus_impl(PyObject *module,
  92. HANDLE CompletionPort,
  93. DWORD NumberOfBytes,
  94. ULONG_PTR CompletionKey,
  95. OVERLAPPED *Overlapped);
  96. static PyObject *
  97. _overlapped_PostQueuedCompletionStatus(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  98. {
  99. PyObject *return_value = NULL;
  100. HANDLE CompletionPort;
  101. DWORD NumberOfBytes;
  102. ULONG_PTR CompletionKey;
  103. OVERLAPPED *Overlapped;
  104. if (!_PyArg_CheckPositional("PostQueuedCompletionStatus", nargs, 4, 4)) {
  105. goto exit;
  106. }
  107. CompletionPort = PyLong_AsVoidPtr(args[0]);
  108. if (!CompletionPort && PyErr_Occurred()) {
  109. goto exit;
  110. }
  111. if (!_PyLong_UnsignedLong_Converter(args[1], &NumberOfBytes)) {
  112. goto exit;
  113. }
  114. CompletionKey = (uintptr_t)PyLong_AsVoidPtr(args[2]);
  115. if (!CompletionKey && PyErr_Occurred()) {
  116. goto exit;
  117. }
  118. Overlapped = PyLong_AsVoidPtr(args[3]);
  119. if (!Overlapped && PyErr_Occurred()) {
  120. goto exit;
  121. }
  122. return_value = _overlapped_PostQueuedCompletionStatus_impl(module, CompletionPort, NumberOfBytes, CompletionKey, Overlapped);
  123. exit:
  124. return return_value;
  125. }
  126. PyDoc_STRVAR(_overlapped_RegisterWaitWithQueue__doc__,
  127. "RegisterWaitWithQueue($module, Object, CompletionPort, Overlapped,\n"
  128. " Timeout, /)\n"
  129. "--\n"
  130. "\n"
  131. "Register wait for Object; when complete CompletionPort is notified.");
  132. #define _OVERLAPPED_REGISTERWAITWITHQUEUE_METHODDEF \
  133. {"RegisterWaitWithQueue", _PyCFunction_CAST(_overlapped_RegisterWaitWithQueue), METH_FASTCALL, _overlapped_RegisterWaitWithQueue__doc__},
  134. static PyObject *
  135. _overlapped_RegisterWaitWithQueue_impl(PyObject *module, HANDLE Object,
  136. HANDLE CompletionPort,
  137. OVERLAPPED *Overlapped,
  138. DWORD Milliseconds);
  139. static PyObject *
  140. _overlapped_RegisterWaitWithQueue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  141. {
  142. PyObject *return_value = NULL;
  143. HANDLE Object;
  144. HANDLE CompletionPort;
  145. OVERLAPPED *Overlapped;
  146. DWORD Milliseconds;
  147. if (!_PyArg_CheckPositional("RegisterWaitWithQueue", nargs, 4, 4)) {
  148. goto exit;
  149. }
  150. Object = PyLong_AsVoidPtr(args[0]);
  151. if (!Object && PyErr_Occurred()) {
  152. goto exit;
  153. }
  154. CompletionPort = PyLong_AsVoidPtr(args[1]);
  155. if (!CompletionPort && PyErr_Occurred()) {
  156. goto exit;
  157. }
  158. Overlapped = PyLong_AsVoidPtr(args[2]);
  159. if (!Overlapped && PyErr_Occurred()) {
  160. goto exit;
  161. }
  162. if (!_PyLong_UnsignedLong_Converter(args[3], &Milliseconds)) {
  163. goto exit;
  164. }
  165. return_value = _overlapped_RegisterWaitWithQueue_impl(module, Object, CompletionPort, Overlapped, Milliseconds);
  166. exit:
  167. return return_value;
  168. }
  169. PyDoc_STRVAR(_overlapped_UnregisterWait__doc__,
  170. "UnregisterWait($module, WaitHandle, /)\n"
  171. "--\n"
  172. "\n"
  173. "Unregister wait handle.");
  174. #define _OVERLAPPED_UNREGISTERWAIT_METHODDEF \
  175. {"UnregisterWait", (PyCFunction)_overlapped_UnregisterWait, METH_O, _overlapped_UnregisterWait__doc__},
  176. static PyObject *
  177. _overlapped_UnregisterWait_impl(PyObject *module, HANDLE WaitHandle);
  178. static PyObject *
  179. _overlapped_UnregisterWait(PyObject *module, PyObject *arg)
  180. {
  181. PyObject *return_value = NULL;
  182. HANDLE WaitHandle;
  183. WaitHandle = PyLong_AsVoidPtr(arg);
  184. if (!WaitHandle && PyErr_Occurred()) {
  185. goto exit;
  186. }
  187. return_value = _overlapped_UnregisterWait_impl(module, WaitHandle);
  188. exit:
  189. return return_value;
  190. }
  191. PyDoc_STRVAR(_overlapped_UnregisterWaitEx__doc__,
  192. "UnregisterWaitEx($module, WaitHandle, Event, /)\n"
  193. "--\n"
  194. "\n"
  195. "Unregister wait handle.");
  196. #define _OVERLAPPED_UNREGISTERWAITEX_METHODDEF \
  197. {"UnregisterWaitEx", _PyCFunction_CAST(_overlapped_UnregisterWaitEx), METH_FASTCALL, _overlapped_UnregisterWaitEx__doc__},
  198. static PyObject *
  199. _overlapped_UnregisterWaitEx_impl(PyObject *module, HANDLE WaitHandle,
  200. HANDLE Event);
  201. static PyObject *
  202. _overlapped_UnregisterWaitEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  203. {
  204. PyObject *return_value = NULL;
  205. HANDLE WaitHandle;
  206. HANDLE Event;
  207. if (!_PyArg_CheckPositional("UnregisterWaitEx", nargs, 2, 2)) {
  208. goto exit;
  209. }
  210. WaitHandle = PyLong_AsVoidPtr(args[0]);
  211. if (!WaitHandle && PyErr_Occurred()) {
  212. goto exit;
  213. }
  214. Event = PyLong_AsVoidPtr(args[1]);
  215. if (!Event && PyErr_Occurred()) {
  216. goto exit;
  217. }
  218. return_value = _overlapped_UnregisterWaitEx_impl(module, WaitHandle, Event);
  219. exit:
  220. return return_value;
  221. }
  222. PyDoc_STRVAR(_overlapped_CreateEvent__doc__,
  223. "CreateEvent($module, EventAttributes, ManualReset, InitialState, Name,\n"
  224. " /)\n"
  225. "--\n"
  226. "\n"
  227. "Create an event.\n"
  228. "\n"
  229. "EventAttributes must be None.");
  230. #define _OVERLAPPED_CREATEEVENT_METHODDEF \
  231. {"CreateEvent", _PyCFunction_CAST(_overlapped_CreateEvent), METH_FASTCALL, _overlapped_CreateEvent__doc__},
  232. static PyObject *
  233. _overlapped_CreateEvent_impl(PyObject *module, PyObject *EventAttributes,
  234. BOOL ManualReset, BOOL InitialState,
  235. const Py_UNICODE *Name);
  236. static PyObject *
  237. _overlapped_CreateEvent(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  238. {
  239. PyObject *return_value = NULL;
  240. PyObject *EventAttributes;
  241. BOOL ManualReset;
  242. BOOL InitialState;
  243. const Py_UNICODE *Name = NULL;
  244. if (!_PyArg_CheckPositional("CreateEvent", nargs, 4, 4)) {
  245. goto exit;
  246. }
  247. EventAttributes = args[0];
  248. ManualReset = _PyLong_AsInt(args[1]);
  249. if (ManualReset == -1 && PyErr_Occurred()) {
  250. goto exit;
  251. }
  252. InitialState = _PyLong_AsInt(args[2]);
  253. if (InitialState == -1 && PyErr_Occurred()) {
  254. goto exit;
  255. }
  256. if (args[3] == Py_None) {
  257. Name = NULL;
  258. }
  259. else if (PyUnicode_Check(args[3])) {
  260. Name = PyUnicode_AsWideCharString(args[3], NULL);
  261. if (Name == NULL) {
  262. goto exit;
  263. }
  264. }
  265. else {
  266. _PyArg_BadArgument("CreateEvent", "argument 4", "str or None", args[3]);
  267. goto exit;
  268. }
  269. return_value = _overlapped_CreateEvent_impl(module, EventAttributes, ManualReset, InitialState, Name);
  270. exit:
  271. /* Cleanup for Name */
  272. PyMem_Free((void *)Name);
  273. return return_value;
  274. }
  275. PyDoc_STRVAR(_overlapped_SetEvent__doc__,
  276. "SetEvent($module, Handle, /)\n"
  277. "--\n"
  278. "\n"
  279. "Set event.");
  280. #define _OVERLAPPED_SETEVENT_METHODDEF \
  281. {"SetEvent", (PyCFunction)_overlapped_SetEvent, METH_O, _overlapped_SetEvent__doc__},
  282. static PyObject *
  283. _overlapped_SetEvent_impl(PyObject *module, HANDLE Handle);
  284. static PyObject *
  285. _overlapped_SetEvent(PyObject *module, PyObject *arg)
  286. {
  287. PyObject *return_value = NULL;
  288. HANDLE Handle;
  289. Handle = PyLong_AsVoidPtr(arg);
  290. if (!Handle && PyErr_Occurred()) {
  291. goto exit;
  292. }
  293. return_value = _overlapped_SetEvent_impl(module, Handle);
  294. exit:
  295. return return_value;
  296. }
  297. PyDoc_STRVAR(_overlapped_ResetEvent__doc__,
  298. "ResetEvent($module, Handle, /)\n"
  299. "--\n"
  300. "\n"
  301. "Reset event.");
  302. #define _OVERLAPPED_RESETEVENT_METHODDEF \
  303. {"ResetEvent", (PyCFunction)_overlapped_ResetEvent, METH_O, _overlapped_ResetEvent__doc__},
  304. static PyObject *
  305. _overlapped_ResetEvent_impl(PyObject *module, HANDLE Handle);
  306. static PyObject *
  307. _overlapped_ResetEvent(PyObject *module, PyObject *arg)
  308. {
  309. PyObject *return_value = NULL;
  310. HANDLE Handle;
  311. Handle = PyLong_AsVoidPtr(arg);
  312. if (!Handle && PyErr_Occurred()) {
  313. goto exit;
  314. }
  315. return_value = _overlapped_ResetEvent_impl(module, Handle);
  316. exit:
  317. return return_value;
  318. }
  319. PyDoc_STRVAR(_overlapped_BindLocal__doc__,
  320. "BindLocal($module, handle, family, /)\n"
  321. "--\n"
  322. "\n"
  323. "Bind a socket handle to an arbitrary local port.\n"
  324. "\n"
  325. "family should be AF_INET or AF_INET6.");
  326. #define _OVERLAPPED_BINDLOCAL_METHODDEF \
  327. {"BindLocal", _PyCFunction_CAST(_overlapped_BindLocal), METH_FASTCALL, _overlapped_BindLocal__doc__},
  328. static PyObject *
  329. _overlapped_BindLocal_impl(PyObject *module, HANDLE Socket, int Family);
  330. static PyObject *
  331. _overlapped_BindLocal(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  332. {
  333. PyObject *return_value = NULL;
  334. HANDLE Socket;
  335. int Family;
  336. if (!_PyArg_CheckPositional("BindLocal", nargs, 2, 2)) {
  337. goto exit;
  338. }
  339. Socket = PyLong_AsVoidPtr(args[0]);
  340. if (!Socket && PyErr_Occurred()) {
  341. goto exit;
  342. }
  343. Family = _PyLong_AsInt(args[1]);
  344. if (Family == -1 && PyErr_Occurred()) {
  345. goto exit;
  346. }
  347. return_value = _overlapped_BindLocal_impl(module, Socket, Family);
  348. exit:
  349. return return_value;
  350. }
  351. PyDoc_STRVAR(_overlapped_FormatMessage__doc__,
  352. "FormatMessage($module, error_code, /)\n"
  353. "--\n"
  354. "\n"
  355. "Return error message for an error code.");
  356. #define _OVERLAPPED_FORMATMESSAGE_METHODDEF \
  357. {"FormatMessage", (PyCFunction)_overlapped_FormatMessage, METH_O, _overlapped_FormatMessage__doc__},
  358. static PyObject *
  359. _overlapped_FormatMessage_impl(PyObject *module, DWORD code);
  360. static PyObject *
  361. _overlapped_FormatMessage(PyObject *module, PyObject *arg)
  362. {
  363. PyObject *return_value = NULL;
  364. DWORD code;
  365. if (!_PyLong_UnsignedLong_Converter(arg, &code)) {
  366. goto exit;
  367. }
  368. return_value = _overlapped_FormatMessage_impl(module, code);
  369. exit:
  370. return return_value;
  371. }
  372. PyDoc_STRVAR(_overlapped_Overlapped__doc__,
  373. "Overlapped(event=_overlapped.INVALID_HANDLE_VALUE)\n"
  374. "--\n"
  375. "\n"
  376. "OVERLAPPED structure wrapper.");
  377. static PyObject *
  378. _overlapped_Overlapped_impl(PyTypeObject *type, HANDLE event);
  379. static PyObject *
  380. _overlapped_Overlapped(PyTypeObject *type, PyObject *args, PyObject *kwargs)
  381. {
  382. PyObject *return_value = NULL;
  383. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  384. #define NUM_KEYWORDS 1
  385. static struct {
  386. PyGC_Head _this_is_not_used;
  387. PyObject_VAR_HEAD
  388. PyObject *ob_item[NUM_KEYWORDS];
  389. } _kwtuple = {
  390. .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
  391. .ob_item = { &_Py_ID(event), },
  392. };
  393. #undef NUM_KEYWORDS
  394. #define KWTUPLE (&_kwtuple.ob_base.ob_base)
  395. #else // !Py_BUILD_CORE
  396. # define KWTUPLE NULL
  397. #endif // !Py_BUILD_CORE
  398. static const char * const _keywords[] = {"event", NULL};
  399. static _PyArg_Parser _parser = {
  400. .keywords = _keywords,
  401. .fname = "Overlapped",
  402. .kwtuple = KWTUPLE,
  403. };
  404. #undef KWTUPLE
  405. PyObject *argsbuf[1];
  406. PyObject * const *fastargs;
  407. Py_ssize_t nargs = PyTuple_GET_SIZE(args);
  408. Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
  409. HANDLE event = INVALID_HANDLE_VALUE;
  410. fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
  411. if (!fastargs) {
  412. goto exit;
  413. }
  414. if (!noptargs) {
  415. goto skip_optional_pos;
  416. }
  417. event = PyLong_AsVoidPtr(fastargs[0]);
  418. if (!event && PyErr_Occurred()) {
  419. goto exit;
  420. }
  421. skip_optional_pos:
  422. return_value = _overlapped_Overlapped_impl(type, event);
  423. exit:
  424. return return_value;
  425. }
  426. PyDoc_STRVAR(_overlapped_Overlapped_cancel__doc__,
  427. "cancel($self, /)\n"
  428. "--\n"
  429. "\n"
  430. "Cancel overlapped operation.");
  431. #define _OVERLAPPED_OVERLAPPED_CANCEL_METHODDEF \
  432. {"cancel", (PyCFunction)_overlapped_Overlapped_cancel, METH_NOARGS, _overlapped_Overlapped_cancel__doc__},
  433. static PyObject *
  434. _overlapped_Overlapped_cancel_impl(OverlappedObject *self);
  435. static PyObject *
  436. _overlapped_Overlapped_cancel(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
  437. {
  438. return _overlapped_Overlapped_cancel_impl(self);
  439. }
  440. PyDoc_STRVAR(_overlapped_Overlapped_getresult__doc__,
  441. "getresult($self, wait=False, /)\n"
  442. "--\n"
  443. "\n"
  444. "Retrieve result of operation.\n"
  445. "\n"
  446. "If wait is true then it blocks until the operation is finished. If wait\n"
  447. "is false and the operation is still pending then an error is raised.");
  448. #define _OVERLAPPED_OVERLAPPED_GETRESULT_METHODDEF \
  449. {"getresult", _PyCFunction_CAST(_overlapped_Overlapped_getresult), METH_FASTCALL, _overlapped_Overlapped_getresult__doc__},
  450. static PyObject *
  451. _overlapped_Overlapped_getresult_impl(OverlappedObject *self, BOOL wait);
  452. static PyObject *
  453. _overlapped_Overlapped_getresult(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  454. {
  455. PyObject *return_value = NULL;
  456. BOOL wait = FALSE;
  457. if (!_PyArg_CheckPositional("getresult", nargs, 0, 1)) {
  458. goto exit;
  459. }
  460. if (nargs < 1) {
  461. goto skip_optional;
  462. }
  463. wait = _PyLong_AsInt(args[0]);
  464. if (wait == -1 && PyErr_Occurred()) {
  465. goto exit;
  466. }
  467. skip_optional:
  468. return_value = _overlapped_Overlapped_getresult_impl(self, wait);
  469. exit:
  470. return return_value;
  471. }
  472. PyDoc_STRVAR(_overlapped_Overlapped_ReadFile__doc__,
  473. "ReadFile($self, handle, size, /)\n"
  474. "--\n"
  475. "\n"
  476. "Start overlapped read.");
  477. #define _OVERLAPPED_OVERLAPPED_READFILE_METHODDEF \
  478. {"ReadFile", _PyCFunction_CAST(_overlapped_Overlapped_ReadFile), METH_FASTCALL, _overlapped_Overlapped_ReadFile__doc__},
  479. static PyObject *
  480. _overlapped_Overlapped_ReadFile_impl(OverlappedObject *self, HANDLE handle,
  481. DWORD size);
  482. static PyObject *
  483. _overlapped_Overlapped_ReadFile(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  484. {
  485. PyObject *return_value = NULL;
  486. HANDLE handle;
  487. DWORD size;
  488. if (!_PyArg_CheckPositional("ReadFile", nargs, 2, 2)) {
  489. goto exit;
  490. }
  491. handle = PyLong_AsVoidPtr(args[0]);
  492. if (!handle && PyErr_Occurred()) {
  493. goto exit;
  494. }
  495. if (!_PyLong_UnsignedLong_Converter(args[1], &size)) {
  496. goto exit;
  497. }
  498. return_value = _overlapped_Overlapped_ReadFile_impl(self, handle, size);
  499. exit:
  500. return return_value;
  501. }
  502. PyDoc_STRVAR(_overlapped_Overlapped_ReadFileInto__doc__,
  503. "ReadFileInto($self, handle, buf, /)\n"
  504. "--\n"
  505. "\n"
  506. "Start overlapped receive.");
  507. #define _OVERLAPPED_OVERLAPPED_READFILEINTO_METHODDEF \
  508. {"ReadFileInto", _PyCFunction_CAST(_overlapped_Overlapped_ReadFileInto), METH_FASTCALL, _overlapped_Overlapped_ReadFileInto__doc__},
  509. static PyObject *
  510. _overlapped_Overlapped_ReadFileInto_impl(OverlappedObject *self,
  511. HANDLE handle, Py_buffer *bufobj);
  512. static PyObject *
  513. _overlapped_Overlapped_ReadFileInto(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  514. {
  515. PyObject *return_value = NULL;
  516. HANDLE handle;
  517. Py_buffer bufobj = {NULL, NULL};
  518. if (!_PyArg_CheckPositional("ReadFileInto", nargs, 2, 2)) {
  519. goto exit;
  520. }
  521. handle = PyLong_AsVoidPtr(args[0]);
  522. if (!handle && PyErr_Occurred()) {
  523. goto exit;
  524. }
  525. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  526. goto exit;
  527. }
  528. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  529. _PyArg_BadArgument("ReadFileInto", "argument 2", "contiguous buffer", args[1]);
  530. goto exit;
  531. }
  532. return_value = _overlapped_Overlapped_ReadFileInto_impl(self, handle, &bufobj);
  533. exit:
  534. /* Cleanup for bufobj */
  535. if (bufobj.obj) {
  536. PyBuffer_Release(&bufobj);
  537. }
  538. return return_value;
  539. }
  540. PyDoc_STRVAR(_overlapped_Overlapped_WSARecv__doc__,
  541. "WSARecv($self, handle, size, flags=0, /)\n"
  542. "--\n"
  543. "\n"
  544. "Start overlapped receive.");
  545. #define _OVERLAPPED_OVERLAPPED_WSARECV_METHODDEF \
  546. {"WSARecv", _PyCFunction_CAST(_overlapped_Overlapped_WSARecv), METH_FASTCALL, _overlapped_Overlapped_WSARecv__doc__},
  547. static PyObject *
  548. _overlapped_Overlapped_WSARecv_impl(OverlappedObject *self, HANDLE handle,
  549. DWORD size, DWORD flags);
  550. static PyObject *
  551. _overlapped_Overlapped_WSARecv(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  552. {
  553. PyObject *return_value = NULL;
  554. HANDLE handle;
  555. DWORD size;
  556. DWORD flags = 0;
  557. if (!_PyArg_CheckPositional("WSARecv", nargs, 2, 3)) {
  558. goto exit;
  559. }
  560. handle = PyLong_AsVoidPtr(args[0]);
  561. if (!handle && PyErr_Occurred()) {
  562. goto exit;
  563. }
  564. if (!_PyLong_UnsignedLong_Converter(args[1], &size)) {
  565. goto exit;
  566. }
  567. if (nargs < 3) {
  568. goto skip_optional;
  569. }
  570. if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
  571. goto exit;
  572. }
  573. skip_optional:
  574. return_value = _overlapped_Overlapped_WSARecv_impl(self, handle, size, flags);
  575. exit:
  576. return return_value;
  577. }
  578. PyDoc_STRVAR(_overlapped_Overlapped_WSARecvInto__doc__,
  579. "WSARecvInto($self, handle, buf, flags, /)\n"
  580. "--\n"
  581. "\n"
  582. "Start overlapped receive.");
  583. #define _OVERLAPPED_OVERLAPPED_WSARECVINTO_METHODDEF \
  584. {"WSARecvInto", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvInto), METH_FASTCALL, _overlapped_Overlapped_WSARecvInto__doc__},
  585. static PyObject *
  586. _overlapped_Overlapped_WSARecvInto_impl(OverlappedObject *self,
  587. HANDLE handle, Py_buffer *bufobj,
  588. DWORD flags);
  589. static PyObject *
  590. _overlapped_Overlapped_WSARecvInto(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  591. {
  592. PyObject *return_value = NULL;
  593. HANDLE handle;
  594. Py_buffer bufobj = {NULL, NULL};
  595. DWORD flags;
  596. if (!_PyArg_CheckPositional("WSARecvInto", nargs, 3, 3)) {
  597. goto exit;
  598. }
  599. handle = PyLong_AsVoidPtr(args[0]);
  600. if (!handle && PyErr_Occurred()) {
  601. goto exit;
  602. }
  603. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  604. goto exit;
  605. }
  606. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  607. _PyArg_BadArgument("WSARecvInto", "argument 2", "contiguous buffer", args[1]);
  608. goto exit;
  609. }
  610. if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
  611. goto exit;
  612. }
  613. return_value = _overlapped_Overlapped_WSARecvInto_impl(self, handle, &bufobj, flags);
  614. exit:
  615. /* Cleanup for bufobj */
  616. if (bufobj.obj) {
  617. PyBuffer_Release(&bufobj);
  618. }
  619. return return_value;
  620. }
  621. PyDoc_STRVAR(_overlapped_Overlapped_WriteFile__doc__,
  622. "WriteFile($self, handle, buf, /)\n"
  623. "--\n"
  624. "\n"
  625. "Start overlapped write.");
  626. #define _OVERLAPPED_OVERLAPPED_WRITEFILE_METHODDEF \
  627. {"WriteFile", _PyCFunction_CAST(_overlapped_Overlapped_WriteFile), METH_FASTCALL, _overlapped_Overlapped_WriteFile__doc__},
  628. static PyObject *
  629. _overlapped_Overlapped_WriteFile_impl(OverlappedObject *self, HANDLE handle,
  630. Py_buffer *bufobj);
  631. static PyObject *
  632. _overlapped_Overlapped_WriteFile(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  633. {
  634. PyObject *return_value = NULL;
  635. HANDLE handle;
  636. Py_buffer bufobj = {NULL, NULL};
  637. if (!_PyArg_CheckPositional("WriteFile", nargs, 2, 2)) {
  638. goto exit;
  639. }
  640. handle = PyLong_AsVoidPtr(args[0]);
  641. if (!handle && PyErr_Occurred()) {
  642. goto exit;
  643. }
  644. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  645. goto exit;
  646. }
  647. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  648. _PyArg_BadArgument("WriteFile", "argument 2", "contiguous buffer", args[1]);
  649. goto exit;
  650. }
  651. return_value = _overlapped_Overlapped_WriteFile_impl(self, handle, &bufobj);
  652. exit:
  653. /* Cleanup for bufobj */
  654. if (bufobj.obj) {
  655. PyBuffer_Release(&bufobj);
  656. }
  657. return return_value;
  658. }
  659. PyDoc_STRVAR(_overlapped_Overlapped_WSASend__doc__,
  660. "WSASend($self, handle, buf, flags, /)\n"
  661. "--\n"
  662. "\n"
  663. "Start overlapped send.");
  664. #define _OVERLAPPED_OVERLAPPED_WSASEND_METHODDEF \
  665. {"WSASend", _PyCFunction_CAST(_overlapped_Overlapped_WSASend), METH_FASTCALL, _overlapped_Overlapped_WSASend__doc__},
  666. static PyObject *
  667. _overlapped_Overlapped_WSASend_impl(OverlappedObject *self, HANDLE handle,
  668. Py_buffer *bufobj, DWORD flags);
  669. static PyObject *
  670. _overlapped_Overlapped_WSASend(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  671. {
  672. PyObject *return_value = NULL;
  673. HANDLE handle;
  674. Py_buffer bufobj = {NULL, NULL};
  675. DWORD flags;
  676. if (!_PyArg_CheckPositional("WSASend", nargs, 3, 3)) {
  677. goto exit;
  678. }
  679. handle = PyLong_AsVoidPtr(args[0]);
  680. if (!handle && PyErr_Occurred()) {
  681. goto exit;
  682. }
  683. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  684. goto exit;
  685. }
  686. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  687. _PyArg_BadArgument("WSASend", "argument 2", "contiguous buffer", args[1]);
  688. goto exit;
  689. }
  690. if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
  691. goto exit;
  692. }
  693. return_value = _overlapped_Overlapped_WSASend_impl(self, handle, &bufobj, flags);
  694. exit:
  695. /* Cleanup for bufobj */
  696. if (bufobj.obj) {
  697. PyBuffer_Release(&bufobj);
  698. }
  699. return return_value;
  700. }
  701. PyDoc_STRVAR(_overlapped_Overlapped_AcceptEx__doc__,
  702. "AcceptEx($self, listen_handle, accept_handle, /)\n"
  703. "--\n"
  704. "\n"
  705. "Start overlapped wait for client to connect.");
  706. #define _OVERLAPPED_OVERLAPPED_ACCEPTEX_METHODDEF \
  707. {"AcceptEx", _PyCFunction_CAST(_overlapped_Overlapped_AcceptEx), METH_FASTCALL, _overlapped_Overlapped_AcceptEx__doc__},
  708. static PyObject *
  709. _overlapped_Overlapped_AcceptEx_impl(OverlappedObject *self,
  710. HANDLE ListenSocket,
  711. HANDLE AcceptSocket);
  712. static PyObject *
  713. _overlapped_Overlapped_AcceptEx(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  714. {
  715. PyObject *return_value = NULL;
  716. HANDLE ListenSocket;
  717. HANDLE AcceptSocket;
  718. if (!_PyArg_CheckPositional("AcceptEx", nargs, 2, 2)) {
  719. goto exit;
  720. }
  721. ListenSocket = PyLong_AsVoidPtr(args[0]);
  722. if (!ListenSocket && PyErr_Occurred()) {
  723. goto exit;
  724. }
  725. AcceptSocket = PyLong_AsVoidPtr(args[1]);
  726. if (!AcceptSocket && PyErr_Occurred()) {
  727. goto exit;
  728. }
  729. return_value = _overlapped_Overlapped_AcceptEx_impl(self, ListenSocket, AcceptSocket);
  730. exit:
  731. return return_value;
  732. }
  733. PyDoc_STRVAR(_overlapped_Overlapped_ConnectEx__doc__,
  734. "ConnectEx($self, client_handle, address_as_bytes, /)\n"
  735. "--\n"
  736. "\n"
  737. "Start overlapped connect.\n"
  738. "\n"
  739. "client_handle should be unbound.");
  740. #define _OVERLAPPED_OVERLAPPED_CONNECTEX_METHODDEF \
  741. {"ConnectEx", _PyCFunction_CAST(_overlapped_Overlapped_ConnectEx), METH_FASTCALL, _overlapped_Overlapped_ConnectEx__doc__},
  742. static PyObject *
  743. _overlapped_Overlapped_ConnectEx_impl(OverlappedObject *self,
  744. HANDLE ConnectSocket,
  745. PyObject *AddressObj);
  746. static PyObject *
  747. _overlapped_Overlapped_ConnectEx(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  748. {
  749. PyObject *return_value = NULL;
  750. HANDLE ConnectSocket;
  751. PyObject *AddressObj;
  752. if (!_PyArg_CheckPositional("ConnectEx", nargs, 2, 2)) {
  753. goto exit;
  754. }
  755. ConnectSocket = PyLong_AsVoidPtr(args[0]);
  756. if (!ConnectSocket && PyErr_Occurred()) {
  757. goto exit;
  758. }
  759. if (!PyTuple_Check(args[1])) {
  760. _PyArg_BadArgument("ConnectEx", "argument 2", "tuple", args[1]);
  761. goto exit;
  762. }
  763. AddressObj = args[1];
  764. return_value = _overlapped_Overlapped_ConnectEx_impl(self, ConnectSocket, AddressObj);
  765. exit:
  766. return return_value;
  767. }
  768. PyDoc_STRVAR(_overlapped_Overlapped_DisconnectEx__doc__,
  769. "DisconnectEx($self, handle, flags, /)\n"
  770. "--\n"
  771. "\n");
  772. #define _OVERLAPPED_OVERLAPPED_DISCONNECTEX_METHODDEF \
  773. {"DisconnectEx", _PyCFunction_CAST(_overlapped_Overlapped_DisconnectEx), METH_FASTCALL, _overlapped_Overlapped_DisconnectEx__doc__},
  774. static PyObject *
  775. _overlapped_Overlapped_DisconnectEx_impl(OverlappedObject *self,
  776. HANDLE Socket, DWORD flags);
  777. static PyObject *
  778. _overlapped_Overlapped_DisconnectEx(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  779. {
  780. PyObject *return_value = NULL;
  781. HANDLE Socket;
  782. DWORD flags;
  783. if (!_PyArg_CheckPositional("DisconnectEx", nargs, 2, 2)) {
  784. goto exit;
  785. }
  786. Socket = PyLong_AsVoidPtr(args[0]);
  787. if (!Socket && PyErr_Occurred()) {
  788. goto exit;
  789. }
  790. if (!_PyLong_UnsignedLong_Converter(args[1], &flags)) {
  791. goto exit;
  792. }
  793. return_value = _overlapped_Overlapped_DisconnectEx_impl(self, Socket, flags);
  794. exit:
  795. return return_value;
  796. }
  797. PyDoc_STRVAR(_overlapped_Overlapped_TransmitFile__doc__,
  798. "TransmitFile($self, socket, file, offset, offset_high, count_to_write,\n"
  799. " count_per_send, flags, /)\n"
  800. "--\n"
  801. "\n"
  802. "Transmit file data over a connected socket.");
  803. #define _OVERLAPPED_OVERLAPPED_TRANSMITFILE_METHODDEF \
  804. {"TransmitFile", _PyCFunction_CAST(_overlapped_Overlapped_TransmitFile), METH_FASTCALL, _overlapped_Overlapped_TransmitFile__doc__},
  805. static PyObject *
  806. _overlapped_Overlapped_TransmitFile_impl(OverlappedObject *self,
  807. HANDLE Socket, HANDLE File,
  808. DWORD offset, DWORD offset_high,
  809. DWORD count_to_write,
  810. DWORD count_per_send, DWORD flags);
  811. static PyObject *
  812. _overlapped_Overlapped_TransmitFile(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  813. {
  814. PyObject *return_value = NULL;
  815. HANDLE Socket;
  816. HANDLE File;
  817. DWORD offset;
  818. DWORD offset_high;
  819. DWORD count_to_write;
  820. DWORD count_per_send;
  821. DWORD flags;
  822. if (!_PyArg_CheckPositional("TransmitFile", nargs, 7, 7)) {
  823. goto exit;
  824. }
  825. Socket = PyLong_AsVoidPtr(args[0]);
  826. if (!Socket && PyErr_Occurred()) {
  827. goto exit;
  828. }
  829. File = PyLong_AsVoidPtr(args[1]);
  830. if (!File && PyErr_Occurred()) {
  831. goto exit;
  832. }
  833. if (!_PyLong_UnsignedLong_Converter(args[2], &offset)) {
  834. goto exit;
  835. }
  836. if (!_PyLong_UnsignedLong_Converter(args[3], &offset_high)) {
  837. goto exit;
  838. }
  839. if (!_PyLong_UnsignedLong_Converter(args[4], &count_to_write)) {
  840. goto exit;
  841. }
  842. if (!_PyLong_UnsignedLong_Converter(args[5], &count_per_send)) {
  843. goto exit;
  844. }
  845. if (!_PyLong_UnsignedLong_Converter(args[6], &flags)) {
  846. goto exit;
  847. }
  848. return_value = _overlapped_Overlapped_TransmitFile_impl(self, Socket, File, offset, offset_high, count_to_write, count_per_send, flags);
  849. exit:
  850. return return_value;
  851. }
  852. PyDoc_STRVAR(_overlapped_Overlapped_ConnectNamedPipe__doc__,
  853. "ConnectNamedPipe($self, handle, /)\n"
  854. "--\n"
  855. "\n"
  856. "Start overlapped wait for a client to connect.");
  857. #define _OVERLAPPED_OVERLAPPED_CONNECTNAMEDPIPE_METHODDEF \
  858. {"ConnectNamedPipe", (PyCFunction)_overlapped_Overlapped_ConnectNamedPipe, METH_O, _overlapped_Overlapped_ConnectNamedPipe__doc__},
  859. static PyObject *
  860. _overlapped_Overlapped_ConnectNamedPipe_impl(OverlappedObject *self,
  861. HANDLE Pipe);
  862. static PyObject *
  863. _overlapped_Overlapped_ConnectNamedPipe(OverlappedObject *self, PyObject *arg)
  864. {
  865. PyObject *return_value = NULL;
  866. HANDLE Pipe;
  867. Pipe = PyLong_AsVoidPtr(arg);
  868. if (!Pipe && PyErr_Occurred()) {
  869. goto exit;
  870. }
  871. return_value = _overlapped_Overlapped_ConnectNamedPipe_impl(self, Pipe);
  872. exit:
  873. return return_value;
  874. }
  875. PyDoc_STRVAR(_overlapped_Overlapped_ConnectPipe__doc__,
  876. "ConnectPipe($self, addr, /)\n"
  877. "--\n"
  878. "\n"
  879. "Connect to the pipe for asynchronous I/O (overlapped).");
  880. #define _OVERLAPPED_OVERLAPPED_CONNECTPIPE_METHODDEF \
  881. {"ConnectPipe", (PyCFunction)_overlapped_Overlapped_ConnectPipe, METH_O, _overlapped_Overlapped_ConnectPipe__doc__},
  882. static PyObject *
  883. _overlapped_Overlapped_ConnectPipe_impl(OverlappedObject *self,
  884. const Py_UNICODE *Address);
  885. static PyObject *
  886. _overlapped_Overlapped_ConnectPipe(OverlappedObject *self, PyObject *arg)
  887. {
  888. PyObject *return_value = NULL;
  889. const Py_UNICODE *Address = NULL;
  890. if (!PyUnicode_Check(arg)) {
  891. _PyArg_BadArgument("ConnectPipe", "argument", "str", arg);
  892. goto exit;
  893. }
  894. Address = PyUnicode_AsWideCharString(arg, NULL);
  895. if (Address == NULL) {
  896. goto exit;
  897. }
  898. return_value = _overlapped_Overlapped_ConnectPipe_impl(self, Address);
  899. exit:
  900. /* Cleanup for Address */
  901. PyMem_Free((void *)Address);
  902. return return_value;
  903. }
  904. PyDoc_STRVAR(_overlapped_WSAConnect__doc__,
  905. "WSAConnect($module, client_handle, address_as_bytes, /)\n"
  906. "--\n"
  907. "\n"
  908. "Bind a remote address to a connectionless (UDP) socket.");
  909. #define _OVERLAPPED_WSACONNECT_METHODDEF \
  910. {"WSAConnect", _PyCFunction_CAST(_overlapped_WSAConnect), METH_FASTCALL, _overlapped_WSAConnect__doc__},
  911. static PyObject *
  912. _overlapped_WSAConnect_impl(PyObject *module, HANDLE ConnectSocket,
  913. PyObject *AddressObj);
  914. static PyObject *
  915. _overlapped_WSAConnect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  916. {
  917. PyObject *return_value = NULL;
  918. HANDLE ConnectSocket;
  919. PyObject *AddressObj;
  920. if (!_PyArg_CheckPositional("WSAConnect", nargs, 2, 2)) {
  921. goto exit;
  922. }
  923. ConnectSocket = PyLong_AsVoidPtr(args[0]);
  924. if (!ConnectSocket && PyErr_Occurred()) {
  925. goto exit;
  926. }
  927. if (!PyTuple_Check(args[1])) {
  928. _PyArg_BadArgument("WSAConnect", "argument 2", "tuple", args[1]);
  929. goto exit;
  930. }
  931. AddressObj = args[1];
  932. return_value = _overlapped_WSAConnect_impl(module, ConnectSocket, AddressObj);
  933. exit:
  934. return return_value;
  935. }
  936. PyDoc_STRVAR(_overlapped_Overlapped_WSASendTo__doc__,
  937. "WSASendTo($self, handle, buf, flags, address_as_bytes, /)\n"
  938. "--\n"
  939. "\n"
  940. "Start overlapped sendto over a connectionless (UDP) socket.");
  941. #define _OVERLAPPED_OVERLAPPED_WSASENDTO_METHODDEF \
  942. {"WSASendTo", _PyCFunction_CAST(_overlapped_Overlapped_WSASendTo), METH_FASTCALL, _overlapped_Overlapped_WSASendTo__doc__},
  943. static PyObject *
  944. _overlapped_Overlapped_WSASendTo_impl(OverlappedObject *self, HANDLE handle,
  945. Py_buffer *bufobj, DWORD flags,
  946. PyObject *AddressObj);
  947. static PyObject *
  948. _overlapped_Overlapped_WSASendTo(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  949. {
  950. PyObject *return_value = NULL;
  951. HANDLE handle;
  952. Py_buffer bufobj = {NULL, NULL};
  953. DWORD flags;
  954. PyObject *AddressObj;
  955. if (!_PyArg_CheckPositional("WSASendTo", nargs, 4, 4)) {
  956. goto exit;
  957. }
  958. handle = PyLong_AsVoidPtr(args[0]);
  959. if (!handle && PyErr_Occurred()) {
  960. goto exit;
  961. }
  962. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  963. goto exit;
  964. }
  965. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  966. _PyArg_BadArgument("WSASendTo", "argument 2", "contiguous buffer", args[1]);
  967. goto exit;
  968. }
  969. if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
  970. goto exit;
  971. }
  972. if (!PyTuple_Check(args[3])) {
  973. _PyArg_BadArgument("WSASendTo", "argument 4", "tuple", args[3]);
  974. goto exit;
  975. }
  976. AddressObj = args[3];
  977. return_value = _overlapped_Overlapped_WSASendTo_impl(self, handle, &bufobj, flags, AddressObj);
  978. exit:
  979. /* Cleanup for bufobj */
  980. if (bufobj.obj) {
  981. PyBuffer_Release(&bufobj);
  982. }
  983. return return_value;
  984. }
  985. PyDoc_STRVAR(_overlapped_Overlapped_WSARecvFrom__doc__,
  986. "WSARecvFrom($self, handle, size, flags=0, /)\n"
  987. "--\n"
  988. "\n"
  989. "Start overlapped receive.");
  990. #define _OVERLAPPED_OVERLAPPED_WSARECVFROM_METHODDEF \
  991. {"WSARecvFrom", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvFrom), METH_FASTCALL, _overlapped_Overlapped_WSARecvFrom__doc__},
  992. static PyObject *
  993. _overlapped_Overlapped_WSARecvFrom_impl(OverlappedObject *self,
  994. HANDLE handle, DWORD size,
  995. DWORD flags);
  996. static PyObject *
  997. _overlapped_Overlapped_WSARecvFrom(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  998. {
  999. PyObject *return_value = NULL;
  1000. HANDLE handle;
  1001. DWORD size;
  1002. DWORD flags = 0;
  1003. if (!_PyArg_CheckPositional("WSARecvFrom", nargs, 2, 3)) {
  1004. goto exit;
  1005. }
  1006. handle = PyLong_AsVoidPtr(args[0]);
  1007. if (!handle && PyErr_Occurred()) {
  1008. goto exit;
  1009. }
  1010. if (!_PyLong_UnsignedLong_Converter(args[1], &size)) {
  1011. goto exit;
  1012. }
  1013. if (nargs < 3) {
  1014. goto skip_optional;
  1015. }
  1016. if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
  1017. goto exit;
  1018. }
  1019. skip_optional:
  1020. return_value = _overlapped_Overlapped_WSARecvFrom_impl(self, handle, size, flags);
  1021. exit:
  1022. return return_value;
  1023. }
  1024. PyDoc_STRVAR(_overlapped_Overlapped_WSARecvFromInto__doc__,
  1025. "WSARecvFromInto($self, handle, buf, size, flags=0, /)\n"
  1026. "--\n"
  1027. "\n"
  1028. "Start overlapped receive.");
  1029. #define _OVERLAPPED_OVERLAPPED_WSARECVFROMINTO_METHODDEF \
  1030. {"WSARecvFromInto", _PyCFunction_CAST(_overlapped_Overlapped_WSARecvFromInto), METH_FASTCALL, _overlapped_Overlapped_WSARecvFromInto__doc__},
  1031. static PyObject *
  1032. _overlapped_Overlapped_WSARecvFromInto_impl(OverlappedObject *self,
  1033. HANDLE handle, Py_buffer *bufobj,
  1034. DWORD size, DWORD flags);
  1035. static PyObject *
  1036. _overlapped_Overlapped_WSARecvFromInto(OverlappedObject *self, PyObject *const *args, Py_ssize_t nargs)
  1037. {
  1038. PyObject *return_value = NULL;
  1039. HANDLE handle;
  1040. Py_buffer bufobj = {NULL, NULL};
  1041. DWORD size;
  1042. DWORD flags = 0;
  1043. if (!_PyArg_CheckPositional("WSARecvFromInto", nargs, 3, 4)) {
  1044. goto exit;
  1045. }
  1046. handle = PyLong_AsVoidPtr(args[0]);
  1047. if (!handle && PyErr_Occurred()) {
  1048. goto exit;
  1049. }
  1050. if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
  1051. goto exit;
  1052. }
  1053. if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
  1054. _PyArg_BadArgument("WSARecvFromInto", "argument 2", "contiguous buffer", args[1]);
  1055. goto exit;
  1056. }
  1057. if (!_PyLong_UnsignedLong_Converter(args[2], &size)) {
  1058. goto exit;
  1059. }
  1060. if (nargs < 4) {
  1061. goto skip_optional;
  1062. }
  1063. if (!_PyLong_UnsignedLong_Converter(args[3], &flags)) {
  1064. goto exit;
  1065. }
  1066. skip_optional:
  1067. return_value = _overlapped_Overlapped_WSARecvFromInto_impl(self, handle, &bufobj, size, flags);
  1068. exit:
  1069. /* Cleanup for bufobj */
  1070. if (bufobj.obj) {
  1071. PyBuffer_Release(&bufobj);
  1072. }
  1073. return return_value;
  1074. }
  1075. /*[clinic end generated code: output=b2e89694b8de3d00 input=a9049054013a1b77]*/