| 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 |
import sys |
| 8 |
from libc cimport stdint |
| 9 |
|
| 10 |
cimport c_strings |
| 11 |
|
| 12 |
|
| 13 |
cdef extern from "Python.h": |
| 14 |
|
| 15 |
ctypedef int Py_intptr_t |
| 16 |
ctypedef size_t Py_ssize_t |
| 17 |
|
| 18 |
|
| 19 |
cdef extern from "azure_c_shared_utility/sastoken.h": |
| 20 |
bint SASToken_Validate(c_strings.STRING_HANDLE sasToken) |
| 21 |
c_strings.STRING_HANDLE SASToken_Create(c_strings.STRING_HANDLE key, c_strings.STRING_HANDLE scope, c_strings.STRING_HANDLE keyName, size_t expiry) |
| 22 |
c_strings.STRING_HANDLE SASToken_CreateString(const char* key, const char* scope, const char* keyName, size_t expiry) |
| 23 |
|
| 24 |
|
| 25 |
cdef extern from "azure_c_shared_utility/buffer_.h": |
| 26 |
|
| 27 |
ctypedef struct BUFFER_HANDLE: |
| 28 |
pass |
| 29 |
|
| 30 |
BUFFER_HANDLE BUFFER_create(const unsigned char* source, size_t size); |
| 31 |
void BUFFER_delete(BUFFER_HANDLE handle) |
| 32 |
|
| 33 |
|
| 34 |
cdef extern from "azure_c_shared_utility/map.h": |
| 35 |
|
| 36 |
cdef enum MAP_RESULT_TAG: |
| 37 |
MAP_OK, |
| 38 |
MAP_ERROR, |
| 39 |
MAP_INVALIDARG, |
| 40 |
MAP_KEYEXISTS, |
| 41 |
MAP_KEYNOTFOUND, |
| 42 |
MAP_FILTER_REJECT |
| 43 |
|
| 44 |
ctypedef struct MAP_HANDLE: |
| 45 |
pass |
| 46 |
|
| 47 |
ctypedef int (*MAP_FILTER_CALLBACK)(const char* mapProperty, const char* mapValue) |
| 48 |
|
| 49 |
MAP_RESULT_TAG Map_GetInternals(MAP_HANDLE handle, const char*const** keys, const char*const** values, size_t* count) |
| 50 |
MAP_HANDLE Map_Create(MAP_FILTER_CALLBACK mapFilterFunc) |
| 51 |
MAP_RESULT_TAG Map_Add(MAP_HANDLE handle, const char* key, const char* value) |
| 52 |
MAP_RESULT_TAG Map_AddOrUpdate(MAP_HANDLE handle, const char* key, const char* value) |
| 53 |
void Map_Destroy(MAP_HANDLE handle) |
| 54 |
|
| 55 |
|
| 56 |
cdef extern from "azure_c_shared_utility/urlencode.h": |
| 57 |
|
| 58 |
c_strings.STRING_HANDLE URL_EncodeString(const char* textEncode) |
| 59 |
c_strings.STRING_HANDLE URL_Encode(c_strings.STRING_HANDLE input) |
| 60 |
|
| 61 |
|
| 62 |
cdef extern from "azure_c_shared_utility/azure_base64.h": |
| 63 |
|
| 64 |
c_strings.STRING_HANDLE Azure_Base64_Encode(BUFFER_HANDLE input) |
| 65 |
c_strings.STRING_HANDLE Azure_Base64_Encode_Bytes(const unsigned char* source, size_t size) |
| 66 |
BUFFER_HANDLE Base64_Decoder(const char* source) |
| 67 |
|
| 68 |
|
| 69 |
cdef extern from "azure_c_shared_utility/tickcounter.h": |
| 70 |
|
| 71 |
ctypedef struct TICK_COUNTER_HANDLE: |
| 72 |
pass |
| 73 |
|
| 74 |
# TODO: This is only for windows |
| 75 |
ctypedef stdint.uint_fast64_t tickcounter_ms_t # Use 64-bit because of QueryPerformanceCounter call |
| 76 |
void tickcounter_destroy(TICK_COUNTER_HANDLE tick_counter) |
| 77 |
TICK_COUNTER_HANDLE tickcounter_create() |
| 78 |
int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_t* current_ms) |
| 79 |
|
| 80 |
|
| 81 |
cdef extern from "azure_c_shared_utility/doublylinkedlist.h": |
| 82 |
|
| 83 |
ctypedef struct DLIST_ENTRY_TAG: |
| 84 |
DLIST_ENTRY_TAG *Flink |
| 85 |
DLIST_ENTRY_TAG *Blink |
| 86 |
|
| 87 |
ctypedef DLIST_ENTRY_TAG DLIST_ENTRY |
| 88 |
ctypedef DLIST_ENTRY_TAG *PDLIST_ENTRY |
| 89 |
|
| 90 |
void DList_InitializeListHead(PDLIST_ENTRY listHead) |
| 91 |
int DList_IsListEmpty(const PDLIST_ENTRY listHead) |
| 92 |
void DList_InsertTailList(PDLIST_ENTRY listHead, PDLIST_ENTRY listEntry) |
| 93 |
void DList_InsertHeadList(PDLIST_ENTRY listHead, PDLIST_ENTRY listEntry) |
| 94 |
void DList_AppendTailList(PDLIST_ENTRY listHead, PDLIST_ENTRY ListToAppend) |
| 95 |
int DList_RemoveEntryList(PDLIST_ENTRY listEntry) |
| 96 |
PDLIST_ENTRY DList_RemoveHeadList(PDLIST_ENTRY listHead) |
| 97 |
|
| 98 |
|
| 99 |
cdef extern from "azure_c_shared_utility/optionhandler.h": |
| 100 |
|
| 101 |
cdef enum OPTIONHANDLER_RESULT_TAG: |
| 102 |
OPTIONHANDLER_OK, |
| 103 |
OPTIONHANDLER_ERROR, |
| 104 |
OPTIONHANDLER_INVALIDARG |
| 105 |
|
| 106 |
ctypedef struct OPTIONHANDLER_HANDLE: |
| 107 |
pass |
| 108 |
|
| 109 |
ctypedef void* (*pfCloneOption)(const char* name, const void* value) |
| 110 |
ctypedef void (*pfDestroyOption)(const char* name, const void* value) |
| 111 |
ctypedef int (*pfSetOption)(void* handle, const char* name, const void* value) |
| 112 |
|
| 113 |
OPTIONHANDLER_HANDLE OptionHandler_Create(pfCloneOption cloneOption, pfDestroyOption destroyOption, pfSetOption setOption) |
| 114 |
OPTIONHANDLER_HANDLE OptionHandler_Clone(OPTIONHANDLER_HANDLE handler) |
| 115 |
OPTIONHANDLER_RESULT_TAG OptionHandler_AddOption(OPTIONHANDLER_HANDLE handle, const char* name, const void* value) |
| 116 |
OPTIONHANDLER_RESULT_TAG OptionHandler_FeedOptions(OPTIONHANDLER_HANDLE handle, void* destinationHandle) |
| 117 |
void OptionHandler_Destroy(OPTIONHANDLER_HANDLE handle) |