{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/comments/141138471","pull_request_review_id":65309803,"id":141138471,"diff_hunk":"@@ -0,0 +1,508 @@\n+// Copyright (c) Microsoft. All rights reserved.\n+// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n+\n+#include <stdlib.h>\n+#include <stddef.h>\n+#include <stdint.h>\n+#include <ctype.h>\n+#include <stdio.h>\n+#include <string.h>\n+#include \"azure_c_shared_utility/gballoc.h\"\n+#include \"azure_c_shared_utility/tlsio_appleios.h\"\n+#include \"azure_c_shared_utility/socketio.h\"\n+#include \"azure_c_shared_utility/optimize_size.h\"\n+#include \"azure_c_shared_utility/xlogging.h\"\n+#include \"azure_c_shared_utility/platform.h\"\n+#include \"azure_c_shared_utility/threadapi.h\"\n+#include \"azure_c_shared_utility/optionhandler.h\"\n+\n+#include <CoreFoundation/CoreFoundation.h>\n+#include <CFNetwork/CFSocketStream.h>\n+\n+#define TLSIO_APPLEIOS_STATE_VALUES  \\\n+    TLSIO_APPLEIOS_STATE_CLOSED,     \\\n+    TLSIO_APPLEIOS_STATE_OPENING,    \\\n+    TLSIO_APPLEIOS_STATE_OPEN,       \\\n+    TLSIO_APPLEIOS_STATE_CLOSING,    \\\n+    TLSIO_APPLEIOS_STATE_ERROR,      \\\n+    TLSIO_APPLEIOS_STATE_NULL\n+DEFINE_ENUM(TLSIO_APPLEIOS_STATE, TLSIO_APPLEIOS_STATE_VALUES);\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_001: [ The tlsio_appleios shall implement and export all the Concrete functions in the VTable IO_INTERFACE_DESCRIPTION defined in the `xio.h`. ]*/\n+/* Codes_SRS_TLSIO_APPLEIOS_32_002: [ The tlsio_appleios shall report the open operation status using the IO_OPEN_RESULT enumerator defined in the `xio.h`.]*/\n+/* Codes_SRS_TLSIO_APPLEIOS_32_003: [ The tlsio_appleios shall report the send operation status using the IO_SEND_RESULT enumerator defined in the `xio.h`. ]*/\n+/* Codes_SRS_TLSIO_APPLEIOS_32_004: [ The tlsio_appleios shall call the callbacks functions defined in the `xio.h`. ]*/\n+#include \"azure_c_shared_utility/xio.h\"\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_005: [ The tlsio_appleios shall received the connection information using the TLSIO_CONFIG structure defined in `tlsio.h`. ]*/\n+#include \"azure_c_shared_utility/tlsio.h\"\n+\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_001: [ The tlsio_appleios shall implement and export all the Concrete functions in the VTable IO_INTERFACE_DESCRIPTION defined in the `xio.h`. ]*/\n+static CONCRETE_IO_HANDLE tlsio_appleios_create(void* io_create_parameters);\n+static void tlsio_appleios_destroy(CONCRETE_IO_HANDLE tls_io);\n+static int tlsio_appleios_open_async(CONCRETE_IO_HANDLE tls_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);\n+static int tlsio_appleios_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);\n+static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);\n+static void tlsio_appleios_dowork(CONCRETE_IO_HANDLE tls_io);\n+static int tlsio_appleios_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, const void* value);\n+static OPTIONHANDLER_HANDLE tlsio_appleios_retrieve_options(CONCRETE_IO_HANDLE tls_io);\n+\n+static const IO_INTERFACE_DESCRIPTION tlsio_handle_interface_description =\n+{\n+    tlsio_appleios_retrieve_options,\n+    tlsio_appleios_create,\n+    tlsio_appleios_destroy,\n+    tlsio_appleios_open,\n+    tlsio_appleios_close,\n+    tlsio_appleios_send,\n+    tlsio_appleios_dowork,\n+    tlsio_appleios_setoption\n+};\n+\n+#define RECEIVE_BUFFER_SIZE    128\n+\n+#define CallErrorCallback() do { if (tlsio_instance->on_io_error != NULL) (void)tlsio_instance->on_io_error(tlsio_instance->on_io_error_context); } while((void)0,0)\n+#define CallOpenCallback(status) do { if (tlsio_instance->on_io_open_complete != NULL) (void)tlsio_instance->on_io_open_complete(tlsio_instance->on_io_open_complete_context, status); } while((void)0,0)\n+#define CallCloseCallback() do { if (tlsio_instance->on_io_close_complete != NULL) (void)tlsio_instance->on_io_close_complete(tlsio_instance->on_io_close_complete_context); } while((void)0,0)\n+\n+\n+typedef struct TLS_IO_INSTANCE_TAG\n+{\n+    ON_IO_OPEN_COMPLETE on_io_open_complete;\n+    void* on_io_open_complete_context;\n+\n+    ON_BYTES_RECEIVED on_bytes_received;\n+    void* on_bytes_received_context;\n+\n+    ON_IO_ERROR on_io_error;\n+    void* on_io_error_context;\n+\n+    ON_IO_CLOSE_COMPLETE on_io_close_complete;\n+    void* on_io_close_complete_context;\n+\n+    CFStringRef remote_host;\n+    uint16_t port;\n+\t\n+    CFReadStreamRef sockRead;\n+    CFWriteStreamRef sockWrite;\n+\t\n+    TLSIO_APPLEIOS_STATE state;\n+} TLS_IO_INSTANCE;\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_008: [ The tlsio_appleios_get_interface_description shall return the VTable IO_INTERFACE_DESCRIPTION. ]*/\n+const IO_INTERFACE_DESCRIPTION* tlsio_appleios_get_interface_description(void)\n+{\n+    return &tlsio_handle_interface_description;\n+}\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_005: [ The tlsio_appleios shall received the connection information using the TLSIO_CONFIG structure defined in `tlsio.h`. ]*/\n+/* Codes_SRS_TLSIO_APPLEIOS_32_009: [ The tlsio_appleios_create shall create a new instance of the tlsio for iOS. ]*/\n+/* Codes_SRS_TLSIO_APPLEIOS_32_017: [ The tlsio_appleios_create shall receive the connection configuration (TLSIO_CONFIG). ]*/\n+CONCRETE_IO_HANDLE tlsio_appleios_create(void* io_create_parameters)\n+{\n+    TLS_IO_INSTANCE* tlsio_instance;\n+    if (io_create_parameters == NULL)\n+    {\n+        LogError(\"Invalid TLS parameters.\");\n+        tlsio_instance = NULL;\n+    }\n+    else\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_011: [ The tlsio_appleios_create shall allocate memory to control the tlsio instance. ]*/\n+        tlsio_instance = (TLS_IO_INSTANCE*)malloc(sizeof(TLS_IO_INSTANCE));\n+        if (tlsio_instance == NULL)\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_012: [ If there is not enough memory to control the tlsio, the tlsio_appleios_create shall return NULL as the handle. ]*/\n+            LogError(\"There is not enough memory to create the TLS instance.\");\n+            /* return as is */\n+        }\n+        else\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_005: [ The tlsio_appleios shall received the connection information using the TLSIO_CONFIG structure defined in `tlsio.h`. ]*/\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_017: [ The tlsio_appleios_create shall receive the connection configuration (TLSIO_CONFIG). ]*/\n+            TLSIO_CONFIG* tlsio_config = (TLSIO_CONFIG*)io_create_parameters;\n+            \n+            if (tlsio_config->hostname == NULL)\n+            {\n+                LogError(\"Host name was not provided\");\n+            }\n+            else {\n+                /* Codes_SRS_TLSIO_APPLEIOS_32_016: [ The tlsio_appleios_create shall initialize all callback pointers as NULL. ]*/\n+                tlsio_instance->on_io_open_complete = NULL;\n+                tlsio_instance->on_io_open_complete_context = NULL;\n+                tlsio_instance->on_bytes_received = NULL;\n+                tlsio_instance->on_bytes_received_context = NULL;\n+                tlsio_instance->on_io_error = NULL;\n+                tlsio_instance->on_io_error_context = NULL;\n+                tlsio_instance->on_io_close_complete = NULL;\n+                tlsio_instance->on_io_close_complete_context = NULL;\n+\n+                /* Codes_SRS_TLSIO_APPLEIOS_32_020: [ If tlsio_appleios_create get success to create the tlsio instance, it shall set the tlsio state as TLSIO_APPLEIOS_STATE_CLOSED. ]*/\n+                tlsio_instance->state = TLSIO_APPLEIOS_STATE_CLOSED;\n+\n+                tlsio_instance->port = (uint16_t)tlsio_config->port;\n+                tlsio_instance->sockRead = NULL;\n+                tlsio_instance->sockWrite = NULL;\n+\n+                /* Codes_SRS_TLSIO_APPLEIOS_32_018: [ The tlsio_appleios_create shall store provided hostName. ]*/\n+                tlsio_instance->remote_host = CFStringCreateWithCString(NULL, tlsio_config->hostname, kCFStringEncodingUTF8);\n+                \n+                if (tlsio_instance->remote_host == NULL)\n+                {\n+                    LogError(\"Unable to allocate string for host name\");\n+                    free(tlsio_instance);\n+                    tlsio_instance = NULL;\n+                }\n+            }\n+        }\n+    }\n+\n+    /* Codes_SRS_TLSIO_APPLEIOS_32_010: [ The tlsio_appleios_create shall return a non-NULL handle on success. ]*/\n+    return (CONCRETE_IO_HANDLE)tlsio_instance;\n+}\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_021: [ The tlsio_appleios_destroy shall destroy a created instance of the tlsio for iOS identified by the CONCRETE_IO_HANDLE. ]*/\n+void tlsio_appleios_destroy(CONCRETE_IO_HANDLE tlsio_handle)\n+{\n+    TLS_IO_INSTANCE* tlsio_instance = (TLS_IO_INSTANCE*)tlsio_handle;\n+\n+    if (tlsio_handle == NULL)\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_024: [ If the tlsio_handle is NULL, the tlsio_appleios_destroy shall not do anything. ]*/\n+        LogError(\"NULL TLS handle.\");\n+    }\n+    else\n+    {\n+        if ((tlsio_instance->state == TLSIO_APPLEIOS_STATE_OPENING) ||\n+            (tlsio_instance->state == TLSIO_APPLEIOS_STATE_OPEN) ||\n+            (tlsio_instance->state == TLSIO_APPLEIOS_STATE_CLOSING))\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_026: [ If the tlsio state is TLSIO_APPLEIOS_STATE_OPENING, TLSIO_APPLEIOS_STATE_OPEN, or TLSIO_APPLEIOS_STATE_CLOSING, the tlsio_appleios_destroy shall close destroy the tlsio, but log an error. ]*/\n+            LogError(\"TLS destroyed with a SSL connection still active.\");\n+        }\n+\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_022: [ The tlsio_appleios_destroy shall free the memory allocated for tlsio_instance. ]*/\n+\t\tCFRelease(tlsio_instance->remote_host);\n+\t\tCFRelease(tlsio_instance->sockRead);\n+\t\tCFRelease(tlsio_instance->sockWrite);\n+        free(tlsio_instance);\n+    }\n+}\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_026: [ The tlsio_appleios_open shall star the process to open the ssl connection with the host provided in the tlsio_appleios_create. ]*/\n+int tlsio_appleios_open_async(\n+    CONCRETE_IO_HANDLE tlsio_handle,\n+    ON_IO_OPEN_COMPLETE on_io_open_complete,\n+    void* on_io_open_complete_context,\n+    ON_BYTES_RECEIVED on_bytes_received,\n+    void* on_bytes_received_context,\n+    ON_IO_ERROR on_io_error,\n+    void* on_io_error_context)\n+{\n+    int result = 0;\n+    TLS_IO_INSTANCE* tlsio_instance = (TLS_IO_INSTANCE*)tlsio_handle;\n+\n+    if (tlsio_handle == NULL)\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_036: [ If the tlsio_handle is NULL, the tlsio_appleios_open shall not do anything, and return _LINE_. ]*/\n+        LogError(\"NULL TLS handle.\");\n+        result = __FAILURE__;\n+    }\n+    else\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_004: [ The tlsio_appleios shall call the callbacks functions defined in the `xio.h`. ]*/\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_006: [ The tlsio_appleios shall return the status of all async operations using the callbacks. ]*/\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_007: [ If the callback function is set as NULL. The tlsio_appleios shall not call anything. ]*/\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_028: [ The tlsio_appleios_open shall store the provided on_io_open_complete callback function address. ]*/\n+        tlsio_instance->on_io_open_complete = on_io_open_complete;\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_029: [ The tlsio_appleios_open shall store the provided on_io_open_complete_context handle. ]*/\n+        tlsio_instance->on_io_open_complete_context = on_io_open_complete_context;\n+\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_030: [ The tlsio_appleios_open shall store the provided on_bytes_received callback function address. ]*/\n+        tlsio_instance->on_bytes_received = on_bytes_received;\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_031: [ The tlsio_appleios_open shall store the provided on_bytes_received_context handle. ]*/\n+        tlsio_instance->on_bytes_received_context = on_bytes_received_context;\n+\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_032: [ The tlsio_appleios_open shall store the provided on_io_error callback function address. ]*/\n+        tlsio_instance->on_io_error = on_io_error;\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_033: [ The tlsio_appleios_open shall store the provided on_io_error_context handle. ]*/\n+        tlsio_instance->on_io_error_context = on_io_error_context;\n+\n+        if ((tlsio_instance->state == TLSIO_APPLEIOS_STATE_ERROR) ||\n+            (tlsio_instance->state == TLSIO_APPLEIOS_STATE_OPENING) ||\n+            (tlsio_instance->state == TLSIO_APPLEIOS_STATE_OPEN) ||\n+            (tlsio_instance->state == TLSIO_APPLEIOS_STATE_CLOSING))\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_035: [ If the tlsio state is TLSIO_APPLEIOS_STATE_ERROR, TLSIO_APPLEIOS_STATE_OPENING, TLSIO_APPLEIOS_STATE_OPEN, or TLSIO_APPLEIOS_STATE_CLOSING, the tlsio_appleios_open shall set the tlsio state as TLSIO_APPLEIOS_STATE_ERROR, and return _LINE_. ]*/\n+            LogError(\"Try to open a connection with an already opened TLS.\");\n+            tlsio_instance->state = TLSIO_APPLEIOS_STATE_ERROR;\n+            result = __FAILURE__;\n+        }\n+        else\n+        {\n+\t\t    CFStreamStatus status;\n+\t\t\t\n+\t\t\tstatus = (tlsio_instance->sockRead == NULL)? kCFStreamStatusClosed : CFReadStreamGetStatus(tlsio_instance->sockRead);\n+\t\t\t\n+\t\t\tif (status != kCFStreamStatusClosed)\n+            {\n+                /* Codes_SRS_TLSIO_APPLEIOS_32_037: [ If the ssl client is connected, the tlsio_appleios_open shall change the state to TLSIO_APPLEIOS_STATE_ERROR, log the error, and return _LINE_. ]*/\n+                LogError(\"SSL stream is not closed.\");\n+                tlsio_instance->state = TLSIO_APPLEIOS_STATE_ERROR;\n+                result = __FAILURE__;\n+            }\n+\t\t\telse\n+\t\t\t{\n+\t            CFStreamCreatePairWithSocketToHost(NULL, tlsio_instance->remote_host, tlsio_instance->port, &tlsio_instance->sockRead, &tlsio_instance->sockWrite);\n+\t\t\t\t\n+\t\t\t\tif (tlsio_instance->sockRead == NULL || tlsio_instance->sockWrite == NULL)\n+\t\t\t\t{\n+\t\t\t\t\tLogError(\"Unable to create socket streams.\")\n+\t\t\t\t\ttlsio_instance->state = TLSIO_APPLEIOS_STATE_ERROR;\n+\t\t\t\t\tresult = __FAILURE__;\n+\t\t\t\t}\n+\t\t\t\telse if (!CFReadStreamSetProperty(tlsio_instance->sockRead, kCFStreamPropertySSLSettings, kCFStreamSocketSecurityLevelTLSv1))\n+\t\t\t\t{\n+\t\t\t\t\tLogError(\"Unable to start SSL on socket.\");\n+\t\t\t\t\ttlsio_instance->state = TLSIO_APPLEIOS_STATE_ERROR;\n+\t\t\t\t\tresult = __FAILURE__;\n+\t\t\t\t}\n+\t            else if (!CFReadStreamOpen(tlsio_instance->sockRead) || !CFWriteStreamOpen(tlsio_instance->sockWrite))\n+\t\t\t\t{\n+\t\t\t\t\tLogError(\"Failure: connect failure\");\n+\t\t\t\t\tCFReadStreamClose(tlsio_instance->sockRead);\n+\t\t\t\t\tCFWriteStreamClose(tlsio_instance->sockWrite);\n+\t\t\t\t\ttlsio_instance->sockRead = NULL;\n+\t\t\t\t\ttlsio_instance->sockWrite = NULL;\n+\t\t\t\t\tresult = __FAILURE__;\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t{\n+\t\t\t\t\ttlsio_instance->state = TLSIO_APPLEIOS_STATE_OPENING;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+    }\n+\n+    if (result == 0)\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_041: [ If the tlsio_appleios_open get success opening the tls connection, it shall call the tlsio_appleios_dowork. ]*/\n+        tlsio_appleios_dowork(tlsio_handle);\n+    }\n+\t\n+    return result;\n+}\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_043: [ The tlsio_appleios_close shall start the process to close the ssl connection. ]*/\n+int tlsio_appleios_close(CONCRETE_IO_HANDLE tlsio_handle, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* on_io_close_complete_context)\n+{\n+    int result;\n+    TLS_IO_INSTANCE* tlsio_instance = (TLS_IO_INSTANCE*)tlsio_handle;\n+\n+    if (tlsio_handle == NULL)\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_049: [ If the tlsio_handle is NULL, the tlsio_appleios_close shall not do anything, and return _LINE_. ]*/\n+        LogError(\"NULL TLS handle.\");\n+        result = __FAILURE__;\n+    }\n+    else\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_045: [ The tlsio_appleios_close shall store the provided on_io_close_complete callback function address. ]*/\n+        tlsio_instance->on_io_close_complete = on_io_close_complete;\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_046: [ The tlsio_appleios_close shall store the provided on_io_close_complete_context handle. ]*/\n+        tlsio_instance->on_io_close_complete_context = on_io_close_complete_context;\n+\n+        if ((tlsio_instance->state == TLSIO_APPLEIOS_STATE_CLOSED) || (tlsio_instance->state == TLSIO_APPLEIOS_STATE_ERROR))\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_079: [ If the tlsio state is TLSIO_APPLEIOS_STATE_ERROR, or TLSIO_APPLEIOS_STATE_CLOSED, the tlsio_appleios_close shall set the tlsio state as TLSIO_APPLEIOS_STATE_CLOSE, and return 0. ]*/\n+            tlsio_instance->state = TLSIO_APPLEIOS_STATE_CLOSED;\n+            result = 0;\n+        }\n+        else if ((tlsio_instance->state == TLSIO_APPLEIOS_STATE_OPENING) || (tlsio_instance->state == TLSIO_APPLEIOS_STATE_CLOSING))\n+        {\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_048: [ If the tlsio state is TLSIO_APPLEIOS_STATE_OPENING, or TLSIO_APPLEIOS_STATE_CLOSING, the tlsio_appleios_close shall set the tlsio state as TLSIO_APPLEIOS_STATE_CLOSE, and return _LINE_. ]*/\n+            LogError(\"Try to close the connection with an already closed TLS.\");\n+            tlsio_instance->state = TLSIO_APPLEIOS_STATE_ERROR;\n+            result = __FAILURE__;\n+        }\n+        else\n+        {\n+            CFReadStreamClose(tlsio_instance->sockRead);\n+            CFWriteStreamClose(tlsio_instance->sockWrite);\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_047: [ If tlsio_appleios_close get success to start the process to close the ssl connection, it shall set the tlsio state as TLSIO_APPLEIOS_STATE_CLOSING, and return 0. ]*/\n+            tlsio_instance->state = TLSIO_APPLEIOS_STATE_CLOSING;\n+            /* Codes_SRS_TLSIO_APPLEIOS_32_050: [ If the tlsio_appleios_close get success closing the tls connection, it shall call the tlsio_appleios_dowork. ]*/\n+            tlsio_appleios_dowork(tlsio_handle);\n+            result = 0;\n+        }\n+    }\n+\n+    return result;\n+}\n+\n+/* Codes_SRS_TLSIO_APPLEIOS_32_052: [ The tlsio_appleios_send shall send all bytes in a buffer to the ssl connectio. ]*/\n+int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tlsio_handle, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context)\n+{\n+    int result;\n+    TLS_IO_INSTANCE* tlsio_instance = (TLS_IO_INSTANCE*)tlsio_handle;\n+\n+    if ((tlsio_handle == NULL) || (buffer == NULL) || (size == 0))\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_059: [ If the tlsio_handle is NULL, the tlsio_appleios_send shall not do anything, and return _LINE_. ]*/\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_060: [ If the buffer is NULL, the tlsio_appleios_send shall not do anything, and return _LINE_. ]*/\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_061: [ If the size is 0, the tlsio_appleios_send shall not do anything, and return _LINE_. ]*/\n+        LogError(\"Invalid parameter\");\n+        result = __FAILURE__;\n+    }\n+    else if (tlsio_instance->state != TLSIO_APPLEIOS_STATE_OPEN)\n+    {\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_058: [ If the tlsio state is TLSIO_APPLEIOS_STATE_ERROR, TLSIO_APPLEIOS_STATE_OPENING, TLSIO_APPLEIOS_STATE_CLOSING, or TLSIO_APPLEIOS_STATE_CLOSED, the tlsio_appleios_send shall call the on_send_complete with IO_SEND_ERROR, and return _LINE_. ]*/\n+        LogError(\"TLS is not ready to send data\");\n+        result = __FAILURE__;\n+    }\n+    else\n+    {\n+        CFIndex send_result;\n+        size_t send_size = size;\n+        const uint8_t* runBuffer = (const uint8_t *)buffer;\n+        result = __FAILURE__;\n+        /* Codes_SRS_TLSIO_APPLEIOS_32_055: [ if the ssl was not able to send all data in the buffer, the tlsio_appleios_send shall call the ssl again to send the remaining bytes. ]*/\n+        while (send_size > 0)","path":"adapters/tlsio_appleios.c","position":371,"original_position":371,"commit_id":"ec9ae3cb2aeb5812c726e978aeea494579dffcf9","original_commit_id":"ec9ae3cb2aeb5812c726e978aeea494579dffcf9","user":{"login":"mamokarz","id":18200629,"avatar_url":"https://avatars3.githubusercontent.com/u/18200629?v=4","gravatar_id":"","url":"https://api.github.com/users/mamokarz","html_url":"https://github.com/mamokarz","followers_url":"https://api.github.com/users/mamokarz/followers","following_url":"https://api.github.com/users/mamokarz/following{/other_user}","gists_url":"https://api.github.com/users/mamokarz/gists{/gist_id}","starred_url":"https://api.github.com/users/mamokarz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mamokarz/subscriptions","organizations_url":"https://api.github.com/users/mamokarz/orgs","repos_url":"https://api.github.com/users/mamokarz/repos","events_url":"https://api.github.com/users/mamokarz/events{/privacy}","received_events_url":"https://api.github.com/users/mamokarz/received_events","type":"User","site_admin":false},"body":">while (send_size > 0) [](start = 8, length = 21)\r\n\r\nThis is not async. To be async, this function should store the information (buffer, callback, etc) and leave the send steps to the dowork.","created_at":"2017-09-26T18:11:30Z","updated_at":"2017-09-26T18:11:30Z","html_url":"https://github.com/Azure/azure-c-shared-utility/pull/109#discussion_r141138471","pull_request_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/comments/141138471"},"html":{"href":"https://github.com/Azure/azure-c-shared-utility/pull/109#discussion_r141138471"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109","id":141171223,"html_url":"https://github.com/Azure/azure-c-shared-utility/pull/109","diff_url":"https://github.com/Azure/azure-c-shared-utility/pull/109.diff","patch_url":"https://github.com/Azure/azure-c-shared-utility/pull/109.patch","issue_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/109","number":109,"state":"open","locked":false,"title":"Mriosbuild","user":{"login":"markrad","id":12402055,"avatar_url":"https://avatars2.githubusercontent.com/u/12402055?v=4","gravatar_id":"","url":"https://api.github.com/users/markrad","html_url":"https://github.com/markrad","followers_url":"https://api.github.com/users/markrad/followers","following_url":"https://api.github.com/users/markrad/following{/other_user}","gists_url":"https://api.github.com/users/markrad/gists{/gist_id}","starred_url":"https://api.github.com/users/markrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markrad/subscriptions","organizations_url":"https://api.github.com/users/markrad/orgs","repos_url":"https://api.github.com/users/markrad/repos","events_url":"https://api.github.com/users/markrad/events{/privacy}","received_events_url":"https://api.github.com/users/markrad/received_events","type":"User","site_admin":false},"body":"Add iOS adapters for cross compiling and running SDK on iPhone. ","created_at":"2017-09-14T20:36:56Z","updated_at":"2017-09-26T18:11:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbd2507dc88bad19060ff22a80ca216d114aec7c","assignee":{"login":"markrad","id":12402055,"avatar_url":"https://avatars2.githubusercontent.com/u/12402055?v=4","gravatar_id":"","url":"https://api.github.com/users/markrad","html_url":"https://github.com/markrad","followers_url":"https://api.github.com/users/markrad/followers","following_url":"https://api.github.com/users/markrad/following{/other_user}","gists_url":"https://api.github.com/users/markrad/gists{/gist_id}","starred_url":"https://api.github.com/users/markrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markrad/subscriptions","organizations_url":"https://api.github.com/users/markrad/orgs","repos_url":"https://api.github.com/users/markrad/repos","events_url":"https://api.github.com/users/markrad/events{/privacy}","received_events_url":"https://api.github.com/users/markrad/received_events","type":"User","site_admin":false},"assignees":[{"login":"markrad","id":12402055,"avatar_url":"https://avatars2.githubusercontent.com/u/12402055?v=4","gravatar_id":"","url":"https://api.github.com/users/markrad","html_url":"https://github.com/markrad","followers_url":"https://api.github.com/users/markrad/followers","following_url":"https://api.github.com/users/markrad/following{/other_user}","gists_url":"https://api.github.com/users/markrad/gists{/gist_id}","starred_url":"https://api.github.com/users/markrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markrad/subscriptions","organizations_url":"https://api.github.com/users/markrad/orgs","repos_url":"https://api.github.com/users/markrad/repos","events_url":"https://api.github.com/users/markrad/events{/privacy}","received_events_url":"https://api.github.com/users/markrad/received_events","type":"User","site_admin":false},{"login":"mamokarz","id":18200629,"avatar_url":"https://avatars3.githubusercontent.com/u/18200629?v=4","gravatar_id":"","url":"https://api.github.com/users/mamokarz","html_url":"https://github.com/mamokarz","followers_url":"https://api.github.com/users/mamokarz/followers","following_url":"https://api.github.com/users/mamokarz/following{/other_user}","gists_url":"https://api.github.com/users/mamokarz/gists{/gist_id}","starred_url":"https://api.github.com/users/mamokarz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mamokarz/subscriptions","organizations_url":"https://api.github.com/users/mamokarz/orgs","repos_url":"https://api.github.com/users/mamokarz/repos","events_url":"https://api.github.com/users/mamokarz/events{/privacy}","received_events_url":"https://api.github.com/users/mamokarz/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"jebrando","id":8583083,"avatar_url":"https://avatars0.githubusercontent.com/u/8583083?v=4","gravatar_id":"","url":"https://api.github.com/users/jebrando","html_url":"https://github.com/jebrando","followers_url":"https://api.github.com/users/jebrando/followers","following_url":"https://api.github.com/users/jebrando/following{/other_user}","gists_url":"https://api.github.com/users/jebrando/gists{/gist_id}","starred_url":"https://api.github.com/users/jebrando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jebrando/subscriptions","organizations_url":"https://api.github.com/users/jebrando/orgs","repos_url":"https://api.github.com/users/jebrando/repos","events_url":"https://api.github.com/users/jebrando/events{/privacy}","received_events_url":"https://api.github.com/users/jebrando/received_events","type":"User","site_admin":false},{"login":"ewertons","id":12401690,"avatar_url":"https://avatars0.githubusercontent.com/u/12401690?v=4","gravatar_id":"","url":"https://api.github.com/users/ewertons","html_url":"https://github.com/ewertons","followers_url":"https://api.github.com/users/ewertons/followers","following_url":"https://api.github.com/users/ewertons/following{/other_user}","gists_url":"https://api.github.com/users/ewertons/gists{/gist_id}","starred_url":"https://api.github.com/users/ewertons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewertons/subscriptions","organizations_url":"https://api.github.com/users/ewertons/orgs","repos_url":"https://api.github.com/users/ewertons/repos","events_url":"https://api.github.com/users/ewertons/events{/privacy}","received_events_url":"https://api.github.com/users/ewertons/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/109/comments","statuses_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/statuses/ec9ae3cb2aeb5812c726e978aeea494579dffcf9","head":{"label":"Azure:mriosbuild","ref":"mriosbuild","sha":"ec9ae3cb2aeb5812c726e978aeea494579dffcf9","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":44986892,"name":"azure-c-shared-utility","full_name":"Azure/azure-c-shared-utility","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-c-shared-utility","description":"Azure C SDKs common code","fork":false,"url":"https://api.github.com/repos/Azure/azure-c-shared-utility","forks_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/forks","keys_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/teams","hooks_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/events","assignees_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/tags","blobs_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/subscription","commits_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/merges","archive_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/downloads","issues_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/deployments","created_at":"2015-10-26T17:53:51Z","updated_at":"2017-08-18T13:07:54Z","pushed_at":"2017-09-26T17:51:43Z","git_url":"git://github.com/Azure/azure-c-shared-utility.git","ssh_url":"git@github.com:Azure/azure-c-shared-utility.git","clone_url":"https://github.com/Azure/azure-c-shared-utility.git","svn_url":"https://github.com/Azure/azure-c-shared-utility","homepage":"","size":8838,"stargazers_count":19,"watchers_count":19,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":65,"mirror_url":null,"open_issues_count":16,"forks":65,"open_issues":16,"watchers":19,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"2b0fda287f7b33ccfc6058dec5f35b501d6ca76a","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":44986892,"name":"azure-c-shared-utility","full_name":"Azure/azure-c-shared-utility","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-c-shared-utility","description":"Azure C SDKs common code","fork":false,"url":"https://api.github.com/repos/Azure/azure-c-shared-utility","forks_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/forks","keys_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/teams","hooks_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/events","assignees_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/tags","blobs_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/subscription","commits_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/merges","archive_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/downloads","issues_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-c-shared-utility/deployments","created_at":"2015-10-26T17:53:51Z","updated_at":"2017-08-18T13:07:54Z","pushed_at":"2017-09-26T17:51:43Z","git_url":"git://github.com/Azure/azure-c-shared-utility.git","ssh_url":"git@github.com:Azure/azure-c-shared-utility.git","clone_url":"https://github.com/Azure/azure-c-shared-utility.git","svn_url":"https://github.com/Azure/azure-c-shared-utility","homepage":"","size":8838,"stargazers_count":19,"watchers_count":19,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":65,"mirror_url":null,"open_issues_count":16,"forks":65,"open_issues":16,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109"},"html":{"href":"https://github.com/Azure/azure-c-shared-utility/pull/109"},"issue":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/109"},"comments":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/issues/109/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/pulls/109/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-c-shared-utility/statuses/ec9ae3cb2aeb5812c726e978aeea494579dffcf9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mamokarz"}}