|
5 | 5 | #include "module.h"
|
6 | 6 |
|
7 | 7 | #include "auth.h"
|
| 8 | +#include "cbor.h" |
8 | 9 | #include "checksums.h"
|
9 | 10 | #include "common.h"
|
10 | 11 | #include "crypto.h"
|
@@ -117,6 +118,14 @@ PyObject *PyUnicode_FromAwsString(const struct aws_string *aws_str) {
|
117 | 118 | return PyUnicode_FromStringAndSize(aws_string_c_str(aws_str), aws_str->len);
|
118 | 119 | }
|
119 | 120 |
|
| 121 | +PyObject *PyBytes_FromAwsByteCursor(const struct aws_byte_cursor *cursor) { |
| 122 | + if (cursor->len > PY_SSIZE_T_MAX) { |
| 123 | + PyErr_SetString(PyExc_OverflowError, "Cursor exceeds PY_SSIZE_T_MAX"); |
| 124 | + return NULL; |
| 125 | + } |
| 126 | + return PyBytes_FromStringAndSize((const char *)cursor->ptr, (Py_ssize_t)cursor->len); |
| 127 | +} |
| 128 | + |
120 | 129 | uint32_t PyObject_GetAttrAsUint32(PyObject *o, const char *class_name, const char *attr_name) {
|
121 | 130 | uint32_t result = UINT32_MAX;
|
122 | 131 |
|
@@ -899,6 +908,41 @@ static PyMethodDef s_module_methods[] = {
|
899 | 908 | AWS_PY_METHOD_DEF(websocket_increment_read_window, METH_VARARGS),
|
900 | 909 | AWS_PY_METHOD_DEF(websocket_create_handshake_request, METH_VARARGS),
|
901 | 910 |
|
| 911 | + /* CBOR Encode */ |
| 912 | + AWS_PY_METHOD_DEF(cbor_encoder_new, METH_VARARGS), |
| 913 | + AWS_PY_METHOD_DEF(cbor_encoder_get_encoded_data, METH_VARARGS), |
| 914 | + AWS_PY_METHOD_DEF(cbor_encoder_write_uint, METH_VARARGS), |
| 915 | + AWS_PY_METHOD_DEF(cbor_encoder_write_negint, METH_VARARGS), |
| 916 | + AWS_PY_METHOD_DEF(cbor_encoder_write_float, METH_VARARGS), |
| 917 | + AWS_PY_METHOD_DEF(cbor_encoder_write_bytes, METH_VARARGS), |
| 918 | + AWS_PY_METHOD_DEF(cbor_encoder_write_text, METH_VARARGS), |
| 919 | + AWS_PY_METHOD_DEF(cbor_encoder_write_array_start, METH_VARARGS), |
| 920 | + AWS_PY_METHOD_DEF(cbor_encoder_write_map_start, METH_VARARGS), |
| 921 | + AWS_PY_METHOD_DEF(cbor_encoder_write_tag, METH_VARARGS), |
| 922 | + AWS_PY_METHOD_DEF(cbor_encoder_write_bool, METH_VARARGS), |
| 923 | + AWS_PY_METHOD_DEF(cbor_encoder_write_simple_types, METH_VARARGS), |
| 924 | + AWS_PY_METHOD_DEF(cbor_encoder_write_py_list, METH_VARARGS), |
| 925 | + AWS_PY_METHOD_DEF(cbor_encoder_write_py_dict, METH_VARARGS), |
| 926 | + AWS_PY_METHOD_DEF(cbor_encoder_write_data_item, METH_VARARGS), |
| 927 | + |
| 928 | + /* CBOR Decode */ |
| 929 | + AWS_PY_METHOD_DEF(cbor_decoder_new, METH_VARARGS), |
| 930 | + AWS_PY_METHOD_DEF(cbor_decoder_peek_type, METH_VARARGS), |
| 931 | + AWS_PY_METHOD_DEF(cbor_decoder_get_remaining_bytes_len, METH_VARARGS), |
| 932 | + AWS_PY_METHOD_DEF(cbor_decoder_consume_next_element, METH_VARARGS), |
| 933 | + AWS_PY_METHOD_DEF(cbor_decoder_consume_next_data_item, METH_VARARGS), |
| 934 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_unsigned_int, METH_VARARGS), |
| 935 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_negative_int, METH_VARARGS), |
| 936 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_float, METH_VARARGS), |
| 937 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_boolean, METH_VARARGS), |
| 938 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_bytes, METH_VARARGS), |
| 939 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_text, METH_VARARGS), |
| 940 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_array_start, METH_VARARGS), |
| 941 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_map_start, METH_VARARGS), |
| 942 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_tag, METH_VARARGS), |
| 943 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_py_list, METH_VARARGS), |
| 944 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_py_dict, METH_VARARGS), |
| 945 | + AWS_PY_METHOD_DEF(cbor_decoder_pop_next_data_item, METH_VARARGS), |
902 | 946 | {NULL, NULL, 0, NULL},
|
903 | 947 | };
|
904 | 948 |
|
|
0 commit comments