| 1 |
#------------------------------------------------------------------------- |
| 2 |
# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 |
# Licensed under the MIT License. See License.txt in the project root for |
| 4 |
# license information. |
| 5 |
#-------------------------------------------------------------------------- |
| 6 |
|
| 7 |
from libc cimport stdint |
| 8 |
|
| 9 |
cimport c_utils |
| 10 |
|
| 11 |
|
| 12 |
cdef extern from "azure_c_shared_utility/xio.h": |
| 13 |
|
| 14 |
ctypedef void* CONCRETE_IO_HANDLE |
| 15 |
ctypedef void* XIO_HANDLE |
| 16 |
|
| 17 |
cdef enum IO_SEND_RESULT_TAG: |
| 18 |
IO_SEND_OK, |
| 19 |
IO_SEND_ERROR, |
| 20 |
IO_SEND_CANCELLED |
| 21 |
|
| 22 |
cdef enum IO_OPEN_RESULT_TAG: |
| 23 |
IO_OPEN_OK, |
| 24 |
IO_OPEN_ERROR, |
| 25 |
IO_OPEN_CANCELLED |
| 26 |
|
| 27 |
ctypedef void (*ON_BYTES_RECEIVED)(void* context, const unsigned char* buffer, size_t size) |
| 28 |
ctypedef void (*ON_SEND_COMPLETE)(void* context, IO_SEND_RESULT_TAG send_result) |
| 29 |
ctypedef void (*ON_IO_OPEN_COMPLETE)(void* context, IO_OPEN_RESULT_TAG open_result) |
| 30 |
ctypedef void (*ON_IO_CLOSE_COMPLETE)(void* context) |
| 31 |
ctypedef void (*ON_IO_ERROR)(void* context) |
| 32 |
|
| 33 |
ctypedef c_utils.OPTIONHANDLER_HANDLE (*IO_RETRIEVEOPTIONS)(CONCRETE_IO_HANDLE concrete_io) |
| 34 |
ctypedef CONCRETE_IO_HANDLE (*IO_CREATE)(void* io_create_parameters) |
| 35 |
ctypedef void (*IO_DESTROY)(CONCRETE_IO_HANDLE concrete_io) |
| 36 |
ctypedef int (*IO_OPEN)(CONCRETE_IO_HANDLE concrete_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context) |
| 37 |
ctypedef int (*IO_CLOSE)(CONCRETE_IO_HANDLE concrete_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context) |
| 38 |
ctypedef int (*IO_SEND)(CONCRETE_IO_HANDLE concrete_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context) |
| 39 |
ctypedef void (*IO_DOWORK)(CONCRETE_IO_HANDLE concrete_io) |
| 40 |
ctypedef int (*IO_SETOPTION)(CONCRETE_IO_HANDLE concrete_io, const char* optionName, const void* value) |
| 41 |
|
| 42 |
ctypedef struct IO_INTERFACE_DESCRIPTION_TAG: |
| 43 |
IO_RETRIEVEOPTIONS concrete_io_retrieveoptions |
| 44 |
IO_CREATE concrete_io_create |
| 45 |
IO_DESTROY concrete_io_destroy |
| 46 |
IO_OPEN concrete_io_open |
| 47 |
IO_CLOSE concrete_io_close |
| 48 |
IO_SEND concrete_io_send |
| 49 |
IO_DOWORK concrete_io_dowork |
| 50 |
IO_SETOPTION concrete_io_setoption |
| 51 |
|
| 52 |
ctypedef IO_INTERFACE_DESCRIPTION_TAG IO_INTERFACE_DESCRIPTION |
| 53 |
|
| 54 |
XIO_HANDLE xio_create(const IO_INTERFACE_DESCRIPTION* io_interface_description, const void* io_create_parameters) |
| 55 |
void xio_destroy(XIO_HANDLE xio) |
| 56 |
int xio_open(XIO_HANDLE xio, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context) |
| 57 |
int xio_close(XIO_HANDLE xio, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context) |
| 58 |
int xio_send(XIO_HANDLE xio, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context) |
| 59 |
void xio_dowork(XIO_HANDLE xio) |
| 60 |
int xio_setoption(XIO_HANDLE xio, const char* optionName, const void* value) |
| 61 |
c_utils.OPTIONHANDLER_HANDLE xio_retrieveoptions(XIO_HANDLE xio) |