Merge branch 'master' into sqm_info3

This commit is contained in:
Jelani Brandon 2019-03-22 12:53:24 -07:00 коммит произвёл GitHub
Родитель 927c6a47f3 a3cec5cda0
Коммит 70e4beefd7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
166 изменённых файлов: 7314 добавлений и 8329 удалений

Просмотреть файл

@ -172,7 +172,7 @@ include_directories(${UMOCK_C_INC_FOLDER})
#these are the C source files
set(source_c_files
./src/base32.c
./src/base64.c
./src/azure_base64.c
./src/buffer.c
./src/constbuffer_array.c
./src/connection_string_parser.c
@ -282,7 +282,7 @@ endif()
set(source_h_files
./inc/azure_c_shared_utility/agenttime.h
./inc/azure_c_shared_utility/base32.h
./inc/azure_c_shared_utility/base64.h
./inc/azure_c_shared_utility/azure_base64.h
./inc/azure_c_shared_utility/buffer_.h
./inc/azure_c_shared_utility/constbuffer_array.h
./inc/azure_c_shared_utility/connection_string_parser.h

Просмотреть файл

@ -11,7 +11,7 @@
#include "time.h"
#include "linux_time.h"
DEFINE_ENUM_STRINGS(COND_RESULT, COND_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(COND_RESULT, COND_RESULT_VALUES);
pthread_cond_t* create_cond(void)
{

Просмотреть файл

@ -8,7 +8,7 @@
#include "azure_c_shared_utility/xlogging.h"
#include "azure_c_shared_utility/gballoc.h"
DEFINE_ENUM_STRINGS(COND_RESULT, COND_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(COND_RESULT, COND_RESULT_VALUES);
typedef struct CONDITION_TAG
{

Просмотреть файл

@ -39,7 +39,7 @@
/*Codes_SRS_HTTPAPI_COMPACT_21_083: [ The HTTPAPI_ExecuteRequest shall wait, at least, 100 milliseconds between retries. ]*/
#define RETRY_INTERVAL_IN_MICROSECONDS 100
DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
MU_DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
typedef struct HTTP_HANDLE_DATA_TAG
{
@ -1202,33 +1202,33 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
HTTPHeaders_GetHeaderCount(httpHeadersHandle, &headersCount) != HTTP_HEADERS_OK)
{
result = HTTPAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_21_024: [ The HTTPAPI_ExecuteRequest shall open the transport connection with the host to send the request. ]*/
else if ((result = OpenXIOConnection(http_instance)) != HTTPAPI_OK)
{
LogError("Open HTTP connection failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Open HTTP connection failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_21_026: [ If the open process succeed, the HTTPAPI_ExecuteRequest shall send the request message to the host. ]*/
else if ((result = SendHeadsToXIO(http_instance, requestType, relativePath, httpHeadersHandle, headersCount)) != HTTPAPI_OK)
{
LogError("Send heads to HTTP failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Send heads to HTTP failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_21_042: [ The request can contain the a content message, provided in content parameter. ]*/
else if ((result = SendContentToXIO(http_instance, content, contentLength)) != HTTPAPI_OK)
{
LogError("Send content to HTTP failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Send content to HTTP failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_21_030: [ At the end of the transmission, the HTTPAPI_ExecuteRequest shall receive the response from the host. ]*/
/*Codes_SRS_HTTPAPI_COMPACT_21_073: [ The message received by the HTTPAPI_ExecuteRequest shall starts with a valid header. ]*/
else if ((result = ReceiveHeaderFromXIO(http_instance, statusCode)) != HTTPAPI_OK)
{
LogError("Receive header from HTTP failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Receive header from HTTP failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_21_074: [ After the header, the message received by the HTTPAPI_ExecuteRequest can contain addition information about the content. ]*/
else if ((result = ReceiveContentInfoFromXIO(http_instance, responseHeadersHandle, &bodyLength, &chunked)) != HTTPAPI_OK)
{
LogError("Receive content information from HTTP failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Receive content information from HTTP failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/*Codes_SRS_HTTPAPI_COMPACT_42_084: [ The message received by the HTTPAPI_ExecuteRequest should not contain http body. ]*/
else if (requestType != HTTPAPI_REQUEST_HEAD)
@ -1236,7 +1236,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
/*Codes_SRS_HTTPAPI_COMPACT_21_075: [ The message received by the HTTPAPI_ExecuteRequest can contain a body with the message content. ]*/
if ((result = ReadHTTPResponseBodyFromXIO(http_instance, bodyLength, chunked, responseContent)) != HTTPAPI_OK)
{
LogError("Read HTTP response body from HTTP failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Read HTTP response body from HTTP failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}

Просмотреть файл

@ -25,7 +25,7 @@
#define TEMP_BUFFER_SIZE 1024
DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
typedef struct HTTP_HANDLE_DATA_TAG
{
@ -59,7 +59,7 @@ HTTPAPI_RESULT HTTPAPI_Init(void)
if (curl_global_init(CURL_GLOBAL_NOTHING) != 0)
{
result = HTTPAPI_INIT_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -307,12 +307,12 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
)
{
result = HTTPAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (HTTPHeaders_GetHeaderCount(httpHeadersHandle, &headersCount) != HTTP_HEADERS_OK)
{
result = HTTPAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -322,56 +322,56 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (tempHostURL == NULL)
{
result = HTTPAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_VERBOSE, httpHandleData->verbose) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_VERBOSE (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_VERBOSE (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if ((strcpy_s(tempHostURL, tempHostURL_size, httpHandleData->hostURL) != 0) ||
(strcat_s(tempHostURL, tempHostURL_size, relativePath) != 0))
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
/* set the URL */
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_URL, tempHostURL) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_URL (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_URL (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_TIMEOUT_MS, httpHandleData->timeout) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_TIMEOUT_MS (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_TIMEOUT_MS (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_LOW_SPEED_LIMIT, httpHandleData->lowSpeedLimit) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_LOW_SPEED_LIMIT (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_LOW_SPEED_LIMIT (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_LOW_SPEED_TIME, httpHandleData->lowSpeedTime) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_LOW_SPEED_TIME (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_LOW_SPEED_TIME (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_FRESH_CONNECT, httpHandleData->freshConnect) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_FRESH_CONNECT (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_FRESH_CONNECT (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_FORBID_REUSE, httpHandleData->forbidReuse) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_FORBID_REUSE (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_FORBID_REUSE (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("failed to set CURLOPT_HTTP_VERSION (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("failed to set CURLOPT_HTTP_VERSION (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -381,21 +381,21 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
{
default:
result = HTTPAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
case HTTPAPI_REQUEST_GET:
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_HTTPGET, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, NULL) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
@ -405,17 +405,17 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_HTTPGET, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_NOBODY, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, NULL) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
break;
@ -424,14 +424,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_POST, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, NULL) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
@ -441,14 +441,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_POST, 1L))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, "PUT") != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
break;
@ -457,14 +457,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_POST, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, "DELETE") != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
break;
@ -473,14 +473,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_POST, 1L) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_CUSTOMREQUEST, "PATCH") != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
@ -500,7 +500,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
{
/* error */
result = HTTPAPI_HTTP_HEADERS_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else
@ -509,7 +509,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (newHeaders == NULL)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(tempBuffer);
break;
}
@ -526,7 +526,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_HTTPHEADER, headers) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -538,7 +538,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(curl_easy_setopt(httpHandleData->curl, CURLOPT_POSTFIELDSIZE, contentLength) != CURLE_OK))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
else
@ -549,7 +549,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(curl_easy_setopt(httpHandleData->curl, CURLOPT_POSTFIELDSIZE, 0) != CURLE_OK))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
else
@ -565,7 +565,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(curl_easy_setopt(httpHandleData->curl, CURLOPT_WRITEFUNCTION, ContentWriteFunction) != CURLE_OK))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -576,7 +576,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(curl_easy_setopt(httpHandleData->curl, CURLOPT_HEADERFUNCTION, HeadersWriteFunction) != CURLE_OK))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
}
@ -589,7 +589,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_setopt(httpHandleData->curl, CURLOPT_WRITEDATA, &responseContentBuffer) != CURLE_OK)
{
result = HTTPAPI_SET_OPTION_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
if (result == HTTPAPI_OK)
@ -600,7 +600,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
{
LogError("curl_easy_perform() failed: %s\n", curl_easy_strerror(curlRes));
result = HTTPAPI_OPEN_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -610,12 +610,12 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (curl_easy_getinfo(httpHandleData->curl, CURLINFO_RESPONSE_CODE, &httpCode) != CURLE_OK)
{
result = HTTPAPI_QUERY_HEADERS_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (responseContentBuffer.error)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -630,7 +630,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if ((responseContentBuffer.bufferSize > 0) && (BUFFER_build(responseContent, responseContentBuffer.buffer, responseContentBuffer.bufferSize) != 0))
{
result = HTTPAPI_INSUFFICIENT_RESPONSE_BUFFER;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -888,7 +888,7 @@ HTTPAPI_RESULT HTTPAPI_CloneOption(const char* optionName, const void* value, co
if (temp == NULL)
{
result = HTTPAPI_ERROR;
LogError("malloc failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("malloc failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -972,7 +972,7 @@ HTTPAPI_RESULT HTTPAPI_CloneOption(const char* optionName, const void* value, co
if (temp == NULL)
{
result = HTTPAPI_ERROR;
LogError("malloc failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("malloc failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{

Просмотреть файл

@ -15,7 +15,7 @@
#define CHAR_COUNT(A) (sizeof(A) - 1)
DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
MU_DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
// data structure that contains all the information required to manage a connection
class HTTP_HANDLE_DATA
@ -262,7 +262,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
HTTPHeaders_GetHeaderCount(httpHeadersHandle, &headersCount) != HTTP_HEADERS_OK)
{
result = HTTPAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -333,14 +333,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
|| ret >= sizeof(buf))
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
LogInfo("HTTPAPI_ExecuteRequest::Sending=%*.*s", strlen(buf), strlen(buf), buf);
if (send(httpHandle->_sock_fd, buf, strlen(buf), 0) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -351,21 +351,21 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (HTTPHeaders_GetHeader(httpHeadersHandle, i, &header) != HTTP_HEADERS_OK)
{
result = HTTPAPI_HTTP_HEADERS_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
LogInfo("HTTPAPI_ExecuteRequest::Sending=%*.*s", strlen(header), strlen(header), header);
if (send(httpHandle->_sock_fd, header, strlen(header), 0) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(header);
goto exit;
}
if (send(httpHandle->_sock_fd, "\r\n", 2, 0) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(header);
goto exit;
}
@ -376,7 +376,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (send(httpHandle->_sock_fd, "\r\n", 2, 0) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -387,7 +387,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (send(httpHandle->_sock_fd, (char*)content, contentLength, 0) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@ -396,7 +396,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (readLine(httpHandle->_sock_fd, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -406,7 +406,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
//Cannot match string, error
LogInfo("HTTPAPI_ExecuteRequest::Not a correct HTTP answer=%s", buf);
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (statusCode)
@ -417,7 +417,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (readLine(httpHandle->_sock_fd, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -433,7 +433,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (sscanf(buf + CHAR_COUNT(ContentLength), " %d", &bodyLength) != 1)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@ -455,7 +455,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (readLine(httpHandle->_sock_fd, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@ -471,20 +471,20 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (BUFFER_pre_build(responseContent, bodyLength) != 0)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (BUFFER_content(responseContent, &receivedContent) != 0)
{
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
if (readChunk(httpHandle->_sock_fd, (char*)receivedContent, bodyLength) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
else
@ -514,14 +514,14 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (readLine(httpHandle->_sock_fd, buf, sizeof(buf)) < 0) // read [length in hex]/r/n
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (sscanf(buf, "%x", &chunkSize) != 1) // chunkSize is length of next line (/r/n is not counted)
{
//Cannot match string, error
result = HTTPAPI_RECEIVE_RESPONSE_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@ -534,7 +534,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
break;
@ -548,20 +548,20 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (BUFFER_content(responseContent, &receivedContent) != 0)
{
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
if (readChunk(httpHandle->_sock_fd, (char*)receivedContent + size, chunkSize) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@ -570,7 +570,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
if (skipN(httpHandle->_sock_fd, chunkSize, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@ -579,7 +579,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
|| buf[0] != '\r' || buf[1] != '\n') // skip /r/n
{
result = HTTPAPI_READ_DATA_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
size += chunkSize;

Просмотреть файл

@ -17,7 +17,7 @@
#include "azure_c_shared_utility/x509_schannel.h"
#include "azure_c_shared_utility/shared_util_options.h"
DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
MU_DEFINE_ENUM_STRINGS(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES)
typedef enum HTTPAPI_STATE_TAG
{
@ -100,7 +100,7 @@ static HTTPAPI_RESULT ConstructHeadersString(HTTP_HEADERS_HANDLE httpHeadersHand
if (HTTPHeaders_GetHeaderCount(httpHeadersHandle, &headersCount) != HTTP_HEADERS_OK)
{
result = HTTPAPI_ERROR;
LogError("HTTPHeaders_GetHeaderCount failed (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("HTTPHeaders_GetHeaderCount failed (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -141,17 +141,17 @@ static HTTPAPI_RESULT ConstructHeadersString(HTTP_HEADERS_HANDLE httpHeadersHand
else if ((requiredCharactersForHeaders = MultiByteToWideChar(CP_ACP, 0, httpHeadersA, -1, NULL, 0)) == 0)
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
LogError("MultiByteToWideChar failed, GetLastError=0x%08x (result = %s)", GetLastError(), ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("MultiByteToWideChar failed, GetLastError=0x%08x (result = %s)", GetLastError(), MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if ((*httpHeaders = (wchar_t*)malloc((requiredCharactersForHeaders + 1) * sizeof(wchar_t))) == NULL)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("Cannot allocate memory (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("Cannot allocate memory (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (MultiByteToWideChar(CP_ACP, 0, httpHeadersA, -1, *httpHeaders, (int)requiredCharactersForHeaders) == 0)
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
LogError("MultiByteToWideChar failed, GetLastError=0x%08x (result = %s)", GetLastError(), ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("MultiByteToWideChar failed, GetLastError=0x%08x (result = %s)", GetLastError(), MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(*httpHeaders);
*httpHeaders = NULL;
}
@ -439,7 +439,7 @@ static HTTPAPI_RESULT InitiateWinhttpRequest(HTTP_HANDLE_DATA* handleData, HTTPA
if ((requestTypeString = GetHttpRequestString(requestType)) == NULL)
{
result = HTTPAPI_INVALID_ARG;
LogError("requestTypeString was NULL (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("requestTypeString was NULL (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if ((requiredCharactersForRelativePath = MultiByteToWideChar(CP_ACP, 0, relativePath, -1, NULL, 0)) == 0)
{
@ -449,12 +449,12 @@ static HTTPAPI_RESULT InitiateWinhttpRequest(HTTP_HANDLE_DATA* handleData, HTTPA
else if ((relativePathTemp = (wchar_t*)malloc((requiredCharactersForRelativePath + 1) * sizeof(wchar_t))) == NULL)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("malloc failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("malloc failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (MultiByteToWideChar(CP_ACP, 0, relativePath, -1, relativePathTemp, (int)requiredCharactersForRelativePath) == 0)
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
LogError("MultiByteToWideChar was 0. (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("MultiByteToWideChar was 0. (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if ((*requestHandle = WinHttpOpenRequest(
handleData->ConnectionHandle,
@ -466,7 +466,7 @@ static HTTPAPI_RESULT InitiateWinhttpRequest(HTTP_HANDLE_DATA* handleData, HTTPA
WINHTTP_FLAG_SECURE)) == NULL)
{
result = HTTPAPI_OPEN_REQUEST_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpOpenRequest failed (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpOpenRequest failed (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if ((handleData->x509SchannelHandle!=NULL) &&
!WinHttpSetOption(
@ -502,7 +502,7 @@ static HTTPAPI_RESULT SendHttpRequest(HTTP_HANDLE_DATA* handleData, HINTERNET re
) == FALSE)
{
result = HTTPAPI_SET_TIMEOUTS_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpOpenRequest failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpOpenRequest failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -527,7 +527,7 @@ static HTTPAPI_RESULT SendHttpRequest(HTTP_HANDLE_DATA* handleData, HINTERNET re
sizeof(dwSecurityFlags)))
{
result = HTTPAPI_SET_OPTION_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpSetOption failed (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpSetOption failed (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (!WinHttpSendRequest(
requestHandle,
@ -539,7 +539,7 @@ static HTTPAPI_RESULT SendHttpRequest(HTTP_HANDLE_DATA* handleData, HINTERNET re
(DWORD_PTR)handleData))
{
result = HTTPAPI_SEND_REQUEST_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpSendRequest: (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpSendRequest: (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -639,7 +639,7 @@ static HTTPAPI_RESULT ReceiveResponseAndStatusCode(HINTERNET requestHandle, unsi
0))
{
result = HTTPAPI_RECEIVE_RESPONSE_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpReceiveResponse: (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpReceiveResponse: (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (statusCode != NULL)
{
@ -655,7 +655,7 @@ static HTTPAPI_RESULT ReceiveResponseAndStatusCode(HINTERNET requestHandle, unsi
WINHTTP_NO_HEADER_INDEX))
{
result = HTTPAPI_QUERY_HEADERS_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryHeaders failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryHeaders failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -682,7 +682,7 @@ static HTTPAPI_RESULT ReceiveResponseContent(HINTERNET requestHandle, BUFFER_HAN
if (!WinHttpQueryDataAvailable(requestHandle, &responseBytesAvailable))
{
result = HTTPAPI_QUERY_DATA_AVAILABLE_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryDataAvailable failed (result = %s).", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryDataAvailable failed (result = %s).", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else if (responseBytesAvailable == 0)
@ -694,7 +694,7 @@ static HTTPAPI_RESULT ReceiveResponseContent(HINTERNET requestHandle, BUFFER_HAN
else if (BUFFER_enlarge(responseContent, responseBytesAvailable) != 0)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else
@ -706,13 +706,13 @@ static HTTPAPI_RESULT ReceiveResponseContent(HINTERNET requestHandle, BUFFER_HAN
if (BUFFER_content(responseContent, &bufferContent) != 0)
{
result = HTTPAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else if (BUFFER_size(responseContent, &bufferSize) != 0)
{
result = HTTPAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else
@ -721,7 +721,7 @@ static HTTPAPI_RESULT ReceiveResponseContent(HINTERNET requestHandle, BUFFER_HAN
if (!WinHttpReadData(requestHandle, (LPVOID)(bufferContent + bufferSize - responseBytesAvailable), responseBytesAvailable, &bytesReceived))
{
result = HTTPAPI_READ_DATA_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpReadData failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpReadData failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
/*if for some reason bytesReceived is zero If you are using WinHttpReadData synchronously, and the return value is TRUE and the number of bytes read is zero, the transfer has been completed and there are no more bytes to read on the handle.*/
@ -729,7 +729,7 @@ static HTTPAPI_RESULT ReceiveResponseContent(HINTERNET requestHandle, BUFFER_HAN
{
/*end of everything, but this looks like an error still, or a non-conformance between WinHttpQueryDataAvailable and WinHttpReadData*/
result = HTTPAPI_READ_DATA_FAILED;
LogError("bytesReceived was unexpectedly zero (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("bytesReceived was unexpectedly zero (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
break;
}
else
@ -764,7 +764,7 @@ static HTTPAPI_RESULT ReceiveResponseHeaders(HINTERNET requestHandle, HTTP_HEADE
if ((responseHeadersTemp = (wchar_t*)malloc(responseHeadersTempLength + 2)) == NULL)
{
result = HTTPAPI_ALLOC_FAILED;
LogError("malloc failed: (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("malloc failed: (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (! WinHttpQueryHeaders(
requestHandle,
@ -775,7 +775,7 @@ static HTTPAPI_RESULT ReceiveResponseHeaders(HINTERNET requestHandle, HTTP_HEADE
WINHTTP_NO_HEADER_INDEX))
{
result = HTTPAPI_QUERY_HEADERS_FAILED;
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryHeaders failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogErrorWinHTTPWithGetLastErrorAsString("WinHttpQueryHeaders failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -858,7 +858,7 @@ HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE r
(httpHeadersHandle == NULL))
{
result = HTTPAPI_INVALID_ARG;
LogError("NULL parameter detected (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("NULL parameter detected (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{
@ -981,7 +981,7 @@ HTTPAPI_RESULT HTTPAPI_SetOption(HTTP_HANDLE handle, const char* optionName, con
if (value == NULL)
{
LogError("Invalid paramater: OPTION_TRUSTED_CERT value=NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -994,7 +994,7 @@ HTTPAPI_RESULT HTTPAPI_SetOption(HTTP_HANDLE handle, const char* optionName, con
if (mallocAndStrcpy_s((char**)&httpHandleData->trustedCertificate, (const char*)value) != 0)
{
LogError("unable to mallocAndStrcpy_s option trusted certificate");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1106,7 +1106,7 @@ HTTPAPI_RESULT HTTPAPI_CloneOption(const char* optionName, const void* value, co
if (temp == NULL)
{
result = HTTPAPI_ERROR;
LogError("malloc failed (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
LogError("malloc failed (result = %s)", MU_ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else
{

Просмотреть файл

@ -4,6 +4,7 @@
#include "azure_c_shared_utility/lock.h"
#include <windows.h>
#include <stdlib.h>
#include "azure_c_shared_utility/gballoc.h"
#include "azure_c_shared_utility/xlogging.h"
#include "azure_c_shared_utility/macro_utils.h"
@ -12,10 +13,14 @@ LOCK_HANDLE Lock_Init(void)
{
/* Codes_SRS_LOCK_10_002: [Lock_Init on success shall return a valid lock handle which should be a non NULL value] */
/* Codes_SRS_LOCK_10_003: [Lock_Init on error shall return NULL ] */
HANDLE result = CreateSemaphoreW(NULL, 1, 1, NULL);
SRWLOCK* result = malloc(sizeof(SRWLOCK));
if (result == NULL)
{
LogError("CreateSemaphore failed.");
LogError("Allocate SRWLOCK failed.");
}
else
{
InitializeSRWLock(result);
}
return (LOCK_HANDLE)result;
@ -33,7 +38,7 @@ LOCK_RESULT Lock_Deinit(LOCK_HANDLE handle)
else
{
/* Codes_SRS_LOCK_10_012: [Lock_Deinit frees the memory pointed by handle] */
CloseHandle((HANDLE)handle);
free(handle);
result = LOCK_OK;
}
@ -51,34 +56,12 @@ LOCK_RESULT Lock(LOCK_HANDLE handle)
}
else
{
DWORD rv = WaitForSingleObject((HANDLE)handle, INFINITE);
switch (rv)
{
case WAIT_OBJECT_0:
/* Codes_SRS_LOCK_10_005: [Lock on success shall return LOCK_OK] */
result = LOCK_OK;
break;
case WAIT_ABANDONED:
LogError("WaitForSingleObject returned 'abandoned'.");
/* Codes_SRS_LOCK_10_006: [Lock on error shall return LOCK_ERROR] */
result = LOCK_ERROR;
break;
case WAIT_TIMEOUT:
LogError("WaitForSingleObject timed out.");
/* Codes_SRS_LOCK_10_006: [Lock on error shall return LOCK_ERROR] */
result = LOCK_ERROR;
break;
case WAIT_FAILED:
LogError("WaitForSingleObject failed: %d", GetLastError());
/* Codes_SRS_LOCK_10_006: [Lock on error shall return LOCK_ERROR] */
result = LOCK_ERROR;
break;
default:
LogError("WaitForSingleObject returned an invalid value.");
/* Codes_SRS_LOCK_10_006: [Lock on error shall return LOCK_ERROR] */
result = LOCK_ERROR;
break;
}
AcquireSRWLockExclusive((SRWLOCK*)handle);
/* Codes_SRS_LOCK_10_005: [Lock on success shall return LOCK_OK] */
result = LOCK_OK;
// Cannot fail
/* Codes_SRS_LOCK_10_006: [Lock on error shall return LOCK_ERROR] */
}
return result;
@ -95,17 +78,12 @@ LOCK_RESULT Unlock(LOCK_HANDLE handle)
}
else
{
if (ReleaseSemaphore((HANDLE)handle, 1, NULL))
{
/* Codes_SRS_LOCK_10_009: [Unlock on success shall return LOCK_OK] */
result = LOCK_OK;
}
else
{
/* Codes_SRS_LOCK_10_010: [Unlock on error shall return LOCK_ERROR] */
LogError("ReleaseSemaphore failed: %d", GetLastError());
result = LOCK_ERROR;
}
ReleaseSRWLockExclusive((SRWLOCK*)handle);
/* Codes_SRS_LOCK_10_009: [Unlock on success shall return LOCK_OK] */
result = LOCK_OK;
// Cannot fail
/* Codes_SRS_LOCK_10_010: [Unlock on error shall return LOCK_ERROR] */
}
return result;

Просмотреть файл

@ -16,14 +16,14 @@ int setupRealTime(void)
if (EthernetInterface::connect())
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
NTPClient ntp;
if (ntp.setTime("0.pool.ntp.org") != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -41,15 +41,15 @@ int platform_init(void)
if (EthernetInterface::init())
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if (setupRealTime() != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if (EthernetInterface::connect())
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -31,7 +31,7 @@ int platform_init(void)
if (error_code != 0)
{
LogError("WSAStartup failed: 0x%x", error_code);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -210,7 +210,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)malloc(sizeof(PENDING_SOCKET_IO));
if (pending_socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -219,7 +219,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
{
LogError("Allocation Failure: Unable to allocate pending list.");
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -234,7 +234,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
LogError("Failure: Unable to add socket to pending list.");
free(pending_socket_io->bytes);
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -275,7 +275,7 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
if (err != 0)
{
LogError("Failure: getaddrinfo failure %d.", err);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -290,7 +290,7 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
if (hostname_len + 1 > sizeof(addrInfoUn.sun_path))
{
LogError("Hostname %s is too long for a unix socket (max len = %lu)", socket_io_instance->hostname, (unsigned long)sizeof(addrInfoUn.sun_path));
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -313,7 +313,7 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
(fcntl(socket_io_instance->socket, F_SETFL, flags | O_NONBLOCK) == -1))
{
LogError("Failure: fcntl failure.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -321,7 +321,7 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
if ((err != 0) && (errno != EINPROGRESS))
{
LogError("Failure: connect failure %d.", errno);
result = __FAILURE__;
result = MU_FAILURE;
}
}
}
@ -362,7 +362,7 @@ static int wait_for_connection(SOCKET_IO_INSTANCE* socket_io_instance)
if (retval != 1)
{
LogError("Failure: select failure.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -372,13 +372,13 @@ static int wait_for_connection(SOCKET_IO_INSTANCE* socket_io_instance)
if (err != 0)
{
LogError("Failure: getsockopt failure %d.", errno);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (so_error != 0)
{
err = so_error;
LogError("Failure: connect failure %d.", so_error);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -503,7 +503,7 @@ static int get_network_interface_descriptions(int socket, NETWORK_INTERFACE_DESC
if (ioctl(socket, SIOCGIFCONF, &ifc) == -1)
{
LogError("ioctl failed querying socket (SIOCGIFCONF, errno=%d)", errno);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -522,25 +522,25 @@ static int get_network_interface_descriptions(int socket, NETWORK_INTERFACE_DESC
if (ioctl(socket, SIOCGIFFLAGS, &ifr) != 0)
{
LogError("ioctl failed querying socket (SIOCGIFFLAGS, errno=%d)", errno);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else if (ioctl(socket, SIOCGIFHWADDR, &ifr) != 0)
{
LogError("ioctl failed querying socket (SIOCGIFHWADDR, errno=%d)", errno);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else if (ioctl(socket, SIOCGIFADDR, &ifr) != 0)
{
LogError("ioctl failed querying socket (SIOCGIFADDR, errno=%d)", errno);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else if ((new_nid = create_network_interface_description(&ifr, new_nid)) == NULL)
{
LogError("Failed creating network interface description");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else if (root_nid == NULL)
@ -570,7 +570,7 @@ static int set_target_network_interface(int socket, char* mac_address)
if (get_network_interface_descriptions(socket, &nid) != 0)
{
LogError("Failed getting network interface descriptions");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -589,12 +589,12 @@ static int set_target_network_interface(int socket, char* mac_address)
if (current_nid == NULL)
{
LogError("Did not find a network interface matching MAC ADDRESS");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, current_nid->name, strlen(current_nid->name)) != 0)
{
LogError("setsockopt failed (%d)", errno);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -718,14 +718,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
if (socket_io == NULL)
{
LogError("Invalid argument: SOCKET_IO_INSTANCE is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (socket_io_instance->io_state != IO_STATE_CLOSED)
{
LogError("Failure: socket state is not closed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (socket_io_instance->socket != INVALID_SOCKET)
{
@ -745,14 +745,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
if (socket_io_instance->socket < SOCKET_SUCCESS)
{
LogError("Failure: socket create failure %d.", socket_io_instance->socket);
result = __FAILURE__;
result = MU_FAILURE;
}
#ifndef __APPLE__
else if (socket_io_instance->target_mac_address != NULL &&
set_target_network_interface(socket_io_instance->socket, socket_io_instance->target_mac_address) != 0)
{
LogError("Failure: failed selecting target network interface (MACADDR=%s).", socket_io_instance->target_mac_address);
result = __FAILURE__;
result = MU_FAILURE;
}
#endif //__APPLE__
else if ((result = lookup_address_and_initiate_socket_connection(socket_io_instance)) != 0)
@ -799,7 +799,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if (socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -834,7 +834,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
{
/* Invalid arguments */
LogError("Invalid argument: send given invalid parameter");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -842,7 +842,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (socket_io_instance->io_state != IO_STATE_OPEN)
{
LogError("Failure: socket state is not opened.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -852,7 +852,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (add_pending_io(socket_io_instance, buffer, size, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -876,7 +876,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
else
{
LogError("Failure: sending socket failed. errno=%d (%s).", errno, strerror(errno));
result = __FAILURE__;
result = MU_FAILURE;
}
}
else
@ -885,7 +885,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (add_pending_io(socket_io_instance, buffer + send_result, size - send_result, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1033,7 +1033,7 @@ static int socketio_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance
if (socket_io_instance->io_state != IO_STATE_CLOSED)
{
LogError("Socket's type can only be changed when in state 'IO_STATE_CLOSED'. Current state=%d", socket_io_instance->io_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (strcmp(addressType, OPTION_ADDRESS_TYPE_DOMAIN_SOCKET) == 0)
{
@ -1048,7 +1048,7 @@ static int socketio_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance
else
{
LogError("Address type %s is not supported", addressType);
result = __FAILURE__;
result = MU_FAILURE;
}
return result;
@ -1062,7 +1062,7 @@ int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, con
optionName == NULL ||
value == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1091,24 +1091,24 @@ int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, con
{
#ifdef __APPLE__
LogError("option not supported.");
result = __FAILURE__;
result = MU_FAILURE;
#else
if (strlen(value) == 0)
{
LogError("option value must be a valid mac address");
result = __FAILURE__;
result = MU_FAILURE;
}
else if ((socket_io_instance->target_mac_address = (char*)malloc(sizeof(char) * (strlen(value) + 1))) == NULL)
{
LogError("failed setting net_interface_mac_address option (malloc failed)");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (strcpy(socket_io_instance->target_mac_address, value) == NULL)
{
LogError("failed setting net_interface_mac_address option (strcpy failed)");
free(socket_io_instance->target_mac_address);
socket_io_instance->target_mac_address = NULL;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1123,7 +1123,7 @@ int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, con
}
else
{
result = __FAILURE__;
result = MU_FAILURE;
}
}

Просмотреть файл

@ -102,7 +102,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)malloc(sizeof(PENDING_SOCKET_IO));
if (pending_socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -110,7 +110,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
if (pending_socket_io->bytes == NULL)
{
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -124,7 +124,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
{
free(pending_socket_io->bytes);
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -219,14 +219,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
SOCKET_IO_INSTANCE* socket_io_instance = (SOCKET_IO_INSTANCE*)socket_io;
if (socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
socket_io_instance->tcp_socket_connection = tcpsocketconnection_create();
if (socket_io_instance->tcp_socket_connection == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -234,7 +234,7 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
{
tcpsocketconnection_destroy(socket_io_instance->tcp_socket_connection);
socket_io_instance->tcp_socket_connection = NULL;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -267,7 +267,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if (socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -276,7 +276,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if ((socket_io_instance->io_state == IO_STATE_CLOSED) ||
(socket_io_instance->io_state == IO_STATE_CLOSING))
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -305,14 +305,14 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
(size == 0))
{
/* Invalid arguments */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
SOCKET_IO_INSTANCE* socket_io_instance = (SOCKET_IO_INSTANCE*)socket_io;
if (socket_io_instance->io_state != IO_STATE_OPEN)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -321,7 +321,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
{
if (add_pending_io(socket_io_instance, buffer, size, on_send_complete, callback_context) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -341,7 +341,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
/* queue data */
if (add_pending_io(socket_io_instance, (unsigned char*)buffer + send_result, size - send_result, on_send_complete, callback_context) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -451,7 +451,7 @@ void socketio_dowork(CONCRETE_IO_HANDLE socket_io)
int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value)
{
/* Not implementing any options */
return __FAILURE__;
return MU_FAILURE;
}
const IO_INTERFACE_DESCRIPTION* socketio_get_interface_description(void)

Просмотреть файл

@ -108,7 +108,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)malloc(sizeof(PENDING_SOCKET_IO));
if (pending_socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -116,7 +116,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
if (pending_socket_io->bytes == NULL)
{
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -129,7 +129,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
{
free(pending_socket_io->bytes);
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -354,14 +354,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
if (socket_io_instance == NULL ||
socket_io_instance->io_state != IO_STATE_CLOSED)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
socket_io_instance->tcp_socket_connection = tcpsocketconnection_create();
if (socket_io_instance->tcp_socket_connection == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -369,7 +369,7 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
{
tcpsocketconnection_destroy(socket_io_instance->tcp_socket_connection);
socket_io_instance->tcp_socket_connection = NULL;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -402,7 +402,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if (socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -410,7 +410,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if (socket_io_instance->io_state == IO_STATE_CLOSED ||
socket_io_instance->io_state == IO_STATE_ERROR)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -435,7 +435,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
(size == 0))
{
/* Invalid arguments */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -444,14 +444,14 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
SOCKET_IO_INSTANCE* socket_io_instance = (SOCKET_IO_INSTANCE*)socket_io;
if (socket_io_instance->io_state != IO_STATE_OPEN)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
// Queue the data, and the socketio_dowork sends the package later
if (add_pending_io(socket_io_instance, buffer, size, on_send_complete, callback_context) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
}
}

Просмотреть файл

@ -110,7 +110,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)malloc(sizeof(PENDING_SOCKET_IO));
if (pending_socket_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -119,7 +119,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
{
LogError("Allocation Failure: Unable to allocate pending list.");
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -134,7 +134,7 @@ static int add_pending_io(SOCKET_IO_INSTANCE* socket_io_instance, const unsigned
LogError("Failure: Unable to add socket to pending list.");
free(pending_socket_io->bytes);
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -259,12 +259,12 @@ static int connect_socket(SOCKET socket, struct sockaddr* addr, size_t len)
if (connect(socket, addr, (int)len) != 0)
{
LogError("Failure: connect failure %d.", WSAGetLastError());
result = __FAILURE__;
result = MU_FAILURE;
}
else if (ioctlsocket(socket, FIONBIO, &iMode) != 0)
{
LogError("Failure: ioctlsocket failure %d.", WSAGetLastError());
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -292,12 +292,12 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
if (sprintf(portString, "%u", socket_io_instance->port) < 0)
{
LogError("Failure: sprintf failed to encode the port.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (getaddrinfo(socket_io_instance->hostname, portString, &addrHint, &addr_info) != 0)
{
LogError("Failure: getaddrinfo failure %d.", WSAGetLastError());
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -326,7 +326,7 @@ static int lookup_address_and_initiate_socket_connection(SOCKET_IO_INSTANCE* soc
if (path_len + 1 > sizeof(addr_un.sun_path))
{
LogError("Path '%s' is too long for a unix socket (max len = %lu)", path, (unsigned long)sizeof(addr_un.sun_path));
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -351,14 +351,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
if (socket_io == NULL)
{
LogError("Invalid argument: SOCKET_IO_INSTANCE is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (socket_io_instance->io_state != IO_STATE_CLOSED)
{
LogError("Failure: socket state is not closed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (socket_io_instance->socket != INVALID_SOCKET)
{
@ -383,14 +383,14 @@ int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_c
if (socket_io_instance->socket == INVALID_SOCKET)
{
LogError("Failure: socket create failure %d.", WSAGetLastError());
result = __FAILURE__;
result = MU_FAILURE;
}
else if (lookup_address_and_initiate_socket_connection(socket_io_instance) != 0)
{
LogError("lookup_address_and_connect_socket failed");
(void)closesocket(socket_io_instance->socket);
socket_io_instance->socket = INVALID_SOCKET;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -421,7 +421,7 @@ int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_clos
if (socket_io == NULL)
{
LogError("Invalid argument: socket_io is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -454,7 +454,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
{
/* Invalid arguments */
LogError("Invalid argument: send given invalid parameter");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -462,7 +462,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (socket_io_instance->io_state != IO_STATE_OPEN)
{
LogError("Failure: socket state is not opened.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -472,7 +472,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (add_pending_io(socket_io_instance, (const unsigned char*)buffer, size, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -490,7 +490,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (last_error != WSAEWOULDBLOCK)
{
LogError("Failure: sending socket failed %d.", last_error);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -498,7 +498,7 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
if (add_pending_io(socket_io_instance, (const unsigned char*)buffer, size, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -620,7 +620,7 @@ static int set_keepalive(SOCKET_IO_INSTANCE* socket_io, struct tcp_keepalive* ke
if (err != 0)
{
LogError("Failure: setting keep-alive on the socket: %d.", err == SOCKET_ERROR ? WSAGetLastError() : err);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -638,7 +638,7 @@ static int socketio_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance
if (socket_io_instance->io_state != IO_STATE_CLOSED)
{
LogError("Socket's type can only be changed when in state 'IO_STATE_CLOSED'. Current state=%d", socket_io_instance->io_state);
result = __FAILURE__;
result = MU_FAILURE;
}
#ifdef AF_UNIX_ON_WINDOWS
else if (strcmp(addressType, OPTION_ADDRESS_TYPE_DOMAIN_SOCKET) == 0)
@ -655,7 +655,7 @@ static int socketio_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance
else
{
LogError("Address type %s is not supported", addressType);
result = __FAILURE__;
result = MU_FAILURE;
}
return result;
@ -669,7 +669,7 @@ int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, con
optionName == NULL ||
value == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -704,7 +704,7 @@ int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, con
}
else
{
result = __FAILURE__;
result = MU_FAILURE;
}
}

Просмотреть файл

@ -6,7 +6,7 @@
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/xlogging.h"
DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC func, void* arg)
{

Просмотреть файл

@ -19,7 +19,7 @@
#include <time.h>
#include "azure_c_shared_utility/xlogging.h"
DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
typedef struct THREAD_INSTANCE_TAG
{
@ -43,7 +43,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
(func == NULL))
{
result = THREADAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@ -51,7 +51,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
if (threadInstance == NULL)
{
result = THREADAPI_NO_MEMORY;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@ -64,7 +64,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
free(threadInstance);
result = THREADAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
break;
case 0:
@ -76,7 +76,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
free(threadInstance);
result = THREADAPI_NO_MEMORY;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
break;
}
}
@ -93,7 +93,7 @@ THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int* res)
if (threadInstance == NULL)
{
result = THREADAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@ -101,7 +101,7 @@ THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int* res)
if (pthread_join(threadInstance->Pthread_handle, &threadResult) != 0)
{
result = THREADAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{

Просмотреть файл

@ -5,7 +5,7 @@
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/xlogging.h"
DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC func, void* arg)
{
@ -14,7 +14,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
(func == NULL))
{
result = THREADAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@ -23,7 +23,7 @@ THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC
{
result = (GetLastError() == ERROR_OUTOFMEMORY) ? THREADAPI_NO_MEMORY : THREADAPI_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@ -41,7 +41,7 @@ THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int *res)
if (threadHandle == NULL)
{
result = THREADAPI_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{

Просмотреть файл

@ -53,14 +53,14 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
if (tick_counter == NULL || current_ms == NULL)
{
LogError("tickcounter failed: Invalid Arguments.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
time_t time_value = get_time_s();
if (time_value == INVALID_TIME_VALUE)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -34,7 +34,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
int result;
if (tick_counter == NULL || current_ms == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -75,7 +75,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
int result;
if (tick_counter == NULL || current_ms == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -52,14 +52,14 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
if (tick_counter == NULL || current_ms == NULL)
{
LogError("tickcounter failed: Invalid Arguments.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
time_t time_value = time(NULL);
if (time_value == INVALID_TIME_VALUE)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -70,7 +70,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
if (tick_counter == NULL || current_ms == NULL)
{
LogError("tickcounter failed: Invalid Arguments.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -82,7 +82,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
if (!QueryPerformanceCounter(&curr_perf_item))
{
LogError("tickcounter failed: QueryPerformanceCounter failed %d.", GetLastError() );
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -105,7 +105,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
time_t time_value = time(NULL);
if (time_value == INVALID_TIME_VALUE)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -542,7 +542,7 @@ int tlsio_mbedtls_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io == NULL)
{
LogError("Invalid parameter specified tls_io: NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -551,7 +551,7 @@ int tlsio_mbedtls_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN)
{
LogError("IO should not be open: %d", tls_io_instance->tlsio_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -574,7 +574,7 @@ int tlsio_mbedtls_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
LogError("Underlying IO open failed");
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
}
}
@ -588,7 +588,7 @@ int tlsio_mbedtls_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
if (tls_io == NULL)
{
LogError("Invalid parameter specified tls_io: NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -598,7 +598,7 @@ int tlsio_mbedtls_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
(tls_io_instance->tlsio_state == TLSIO_STATE_CLOSING))
{
LogError("IO should not be closed: %d", tls_io_instance->tlsio_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -608,7 +608,7 @@ int tlsio_mbedtls_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
if (xio_close(tls_io_instance->socket_io, on_underlying_io_close_complete_during_close, tls_io_instance) != 0)
{
LogError("xio_close failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -634,7 +634,7 @@ int tlsio_mbedtls_send(CONCRETE_IO_HANDLE tls_io, const void *buffer, size_t siz
if (tls_io == NULL || (buffer == NULL) || (size == 0))
{
LogError("Invalid parameter specified tls_io: %p, buffer: %p, size: %ul", tls_io, buffer, (unsigned int)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -642,7 +642,7 @@ int tlsio_mbedtls_send(CONCRETE_IO_HANDLE tls_io, const void *buffer, size_t siz
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("Invalid state specified %d", tls_io_instance->tlsio_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -652,7 +652,7 @@ int tlsio_mbedtls_send(CONCRETE_IO_HANDLE tls_io, const void *buffer, size_t siz
if (res != (int)size)
{
LogError("Unexpected data size returned from mbedtls_ssl_write %d/%d", res, (int)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -797,7 +797,7 @@ int tlsio_mbedtls_setoption(CONCRETE_IO_HANDLE tls_io, const char *optionName, c
if (tls_io == NULL || optionName == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -814,7 +814,7 @@ int tlsio_mbedtls_setoption(CONCRETE_IO_HANDLE tls_io, const char *optionName, c
if (mallocAndStrcpy_s(&tls_io_instance->trusted_certificates, (const char *)value) != 0)
{
LogError("unable to mallocAndStrcpy_s");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -822,7 +822,7 @@ int tlsio_mbedtls_setoption(CONCRETE_IO_HANDLE tls_io, const char *optionName, c
if (parse_result != 0)
{
LogInfo("Malformed pem certificate");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -841,15 +841,15 @@ int tlsio_mbedtls_setoption(CONCRETE_IO_HANDLE tls_io, const char *optionName, c
if (mallocAndStrcpy_s(&tls_io_instance->x509_certificate, (const char *)value) != 0)
{
LogError("unable to mallocAndStrcpy_s on certificate");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (mbedtls_x509_crt_parse(&tls_io_instance->owncert, (const unsigned char *)value, (int)(strlen(value) + 1)) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if (tls_io_instance->pKey.pk_info != NULL && mbedtls_ssl_conf_own_cert(&tls_io_instance->config, &tls_io_instance->owncert, &tls_io_instance->pKey) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -867,15 +867,15 @@ int tlsio_mbedtls_setoption(CONCRETE_IO_HANDLE tls_io, const char *optionName, c
if (mallocAndStrcpy_s(&tls_io_instance->x509_private_key, (const char *)value) != 0)
{
LogError("unable to mallocAndStrcpy_s on private key");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (mbedtls_pk_parse_key(&tls_io_instance->pKey, (const unsigned char *)value, (int)(strlen(value) + 1), NULL, 0) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if (tls_io_instance->owncert.version > 0 && mbedtls_ssl_conf_own_cert(&tls_io_instance->config, &tls_io_instance->owncert, &tls_io_instance->pKey))
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -542,7 +542,7 @@ static int openssl_static_locks_install(void)
if (openssl_locks != NULL)
{
LogError("Locks already initialized");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -550,7 +550,7 @@ static int openssl_static_locks_install(void)
if (openssl_locks == NULL)
{
LogError("Failed to allocate locks");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -572,7 +572,7 @@ static int openssl_static_locks_install(void)
{
Lock_Deinit(openssl_locks[j]);
}
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -625,21 +625,21 @@ static int write_outgoing_bytes(TLS_IO_INSTANCE* tls_io_instance, ON_SEND_COMPLE
if (bytes_to_send == NULL)
{
LogError("NULL bytes_to_send.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (BIO_read(tls_io_instance->out_bio, bytes_to_send, (int)pending) != (int)pending)
{
log_ERR_get_error("BIO_read not in pending state.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (xio_send(tls_io_instance->underlying_io, bytes_to_send, pending, on_send_complete, callback_context) != 0)
{
LogError("Error in xio_send.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -795,7 +795,7 @@ static int decode_ssl_received_bytes(TLS_IO_INSTANCE* tls_io_instance)
if (tls_io_instance->ssl == NULL)
{
LogError("SSL channel closed in decode_ssl_received_bytes.");
result = __FAILURE__;
result = MU_FAILURE;
return result;
}
@ -860,7 +860,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
if (cert_store == NULL)
{
log_ERR_get_error("failure in SSL_CTX_get_cert_store.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -873,7 +873,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
if (bio_method == NULL)
{
log_ERR_get_error("failure in BIO_s_mem");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -882,7 +882,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
if (cert_memory_bio == NULL)
{
log_ERR_get_error("failure in BIO_new");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -890,14 +890,14 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
if (puts_result < 0)
{
log_ERR_get_error("failure in BIO_puts");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if ((size_t)puts_result != strlen(certValue))
{
log_ERR_get_error("mismatching legths");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -919,7 +919,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
else
{
/*previous while loop terminated unfortunately*/
result = __FAILURE__;
result = MU_FAILURE;
}
}
}
@ -960,7 +960,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
if (tlsInstance->ssl_context == NULL)
{
log_ERR_get_error("Failed allocating OpenSSL context.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if ((tlsInstance->cipher_list != NULL) &&
(SSL_CTX_set_cipher_list(tlsInstance->ssl_context, tlsInstance->cipher_list)) != 1)
@ -968,14 +968,14 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("unable to set cipher list.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (add_certificate_to_store(tlsInstance, tlsInstance->certificate) != 0)
{
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("unable to add_certificate_to_store.");
result = __FAILURE__;
result = MU_FAILURE;
}
/*x509 authentication can only be build before underlying connection is realized*/
else if (
@ -987,7 +987,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("unable to use x509 authentication");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -999,7 +999,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("Failed BIO_new for in BIO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1010,7 +1010,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("Failed BIO_new for out BIO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1022,7 +1022,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
LogError("Failed BIO_set_mem_eof_return.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1043,7 +1043,7 @@ static int create_openssl_instance(TLS_IO_INSTANCE* tlsInstance)
SSL_CTX_free(tlsInstance->ssl_context);
tlsInstance->ssl_context = NULL;
log_ERR_get_error("Failed creating OpenSSL instance.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1069,7 +1069,7 @@ int tlsio_openssl_init(void)
if (openssl_static_locks_install() != 0)
{
LogError("Failed to install static locks in OpenSSL!");
return __FAILURE__;
return MU_FAILURE;
}
openssl_dynamic_locks_install();
@ -1221,7 +1221,7 @@ int tlsio_openssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
LogError("NULL tls_io.");
}
else
@ -1231,7 +1231,7 @@ int tlsio_openssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN)
{
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_NOT_OPEN.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1250,7 +1250,7 @@ int tlsio_openssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
{
LogError("Failed creating the OpenSSL instance.");
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else if (xio_open(tls_io_instance->underlying_io, on_underlying_io_open_complete, tls_io_instance,
on_underlying_io_bytes_received, tls_io_instance, on_underlying_io_error, tls_io_instance) != 0)
@ -1258,7 +1258,7 @@ int tlsio_openssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
LogError("Failed opening the underlying I/O.");
close_openssl_instance(tls_io_instance);
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1281,7 +1281,7 @@ int tlsio_openssl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
if (tls_io == NULL)
{
LogError("NULL tls_io.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1340,7 +1340,7 @@ int tlsio_openssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (tls_io == NULL)
{
LogError("NULL tls_io.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1349,7 +1349,7 @@ int tlsio_openssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_OPEN.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1357,7 +1357,7 @@ int tlsio_openssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (tls_io_instance->ssl == NULL)
{
LogError("SSL channel closed in tlsio_openssl_send.");
result = __FAILURE__;
result = MU_FAILURE;
return result;
}
@ -1365,14 +1365,14 @@ int tlsio_openssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (res != (int)size)
{
log_ERR_get_error("SSL_write error.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (write_outgoing_bytes(tls_io_instance, on_send_complete, callback_context) != 0)
{
LogError("Error in write_outgoing_bytes.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1441,7 +1441,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io == NULL || optionName == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1464,7 +1464,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
tls_io_instance->certificate = malloc(len + 1);
if (tls_io_instance->certificate == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1491,7 +1491,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (mallocAndStrcpy_s((char**)&tls_io_instance->cipher_list, value) != 0)
{
LogError("unable to mallocAndStrcpy_s %s", optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1503,7 +1503,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io_instance->x509_certificate != NULL)
{
LogError("unable to set x509 options more than once");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1511,7 +1511,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (mallocAndStrcpy_s((char**)&tls_io_instance->x509_certificate, value) != 0)
{
LogError("unable to mallocAndStrcpy_s %s", optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1524,7 +1524,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io_instance->x509_private_key != NULL)
{
LogError("unable to set more than once x509 options");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1532,7 +1532,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (mallocAndStrcpy_s((char**)&tls_io_instance->x509_private_key, value) != 0)
{
LogError("unable to mallocAndStrcpy_s %s", optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1574,7 +1574,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io_instance->ssl_context != NULL)
{
LogError("Unable to set the tls version after the tls connection is established");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1604,7 +1604,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (OptionHandler_FeedOptions((OPTIONHANDLER_HANDLE)value, (void*)tls_io_instance->underlying_io) != OPTIONHANDLER_OK)
{
LogError("failed feeding options to underlying I/O instance");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1619,7 +1619,7 @@ int tlsio_openssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
{
if (tls_io_instance->underlying_io == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -32,8 +32,8 @@
TLSIO_STATE_CLOSING, \
TLSIO_STATE_ERROR
DEFINE_ENUM(TLSIO_STATE, TLSIO_STATE_VALUES);
DEFINE_ENUM_STRINGS(TLSIO_STATE, TLSIO_STATE_VALUES);
MU_DEFINE_ENUM(TLSIO_STATE, TLSIO_STATE_VALUES);
MU_DEFINE_ENUM_STRINGS(TLSIO_STATE, TLSIO_STATE_VALUES);
typedef struct PENDING_SEND_TAG
{
@ -246,7 +246,7 @@ static int resize_receive_buffer(TLS_IO_INSTANCE* tls_io_instance, size_t needed
if (new_buffer == NULL)
{
LogError("realloc failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -434,12 +434,12 @@ static int verify_custom_certificate_if_needed(TLS_IO_INSTANCE* tls_io_instance)
if (status != SEC_E_OK)
{
LogError("QueryContextAttributes failed: %x", status);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (x509_verify_certificate_in_chain(tls_io_instance->trustedCertificate, serverCertificateToVerify) != 0)
{
LogError("Failed to verify trusted certificate in chain");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -463,7 +463,7 @@ static int set_receive_buffer(TLS_IO_INSTANCE* tls_io_instance, size_t buffer_si
if (new_buffer == NULL)
{
LogError("realloc failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -484,15 +484,15 @@ static int send_chunk(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size
(size == 0))
{
LogError("invalid argument detected: CONCRETE_IO_HANDLE tls_io = %p, const void* buffer = %p, size_t size = %lu", tls_io, buffer, (unsigned long)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("invalid tls_io_instance->tlsio_state: %s", ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = __FAILURE__;
LogError("invalid tls_io_instance->tlsio_state: %s", MU_ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = MU_FAILURE;
}
else
{
@ -501,7 +501,7 @@ static int send_chunk(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size
if (status != SEC_E_OK)
{
LogError("QueryContextAttributes failed: %x", status);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -512,7 +512,7 @@ static int send_chunk(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size
if (out_buffer == NULL)
{
LogError("malloc failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -539,14 +539,14 @@ static int send_chunk(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t size
if (FAILED(status))
{
LogError("EncryptMessage failed: %x", status);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (xio_send(tls_io_instance->socket_io, out_buffer, security_buffers[0].cbBuffer + security_buffers[1].cbBuffer + security_buffers[2].cbBuffer, on_send_complete, callback_context) != 0)
{
LogError("xio_send failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -587,7 +587,7 @@ static int internal_send(TLS_IO_INSTANCE* tls_io_instance, const void* buffer, s
if (size > 0)
{
LogError("send_chunk failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1209,7 +1209,7 @@ int tlsio_schannel_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_ope
if (tls_io == NULL)
{
LogError("invalid argument detected: CONCRETE_IO_HANDLE tls_io = %p", tls_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1217,8 +1217,8 @@ int tlsio_schannel_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_ope
if (tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN)
{
LogError("invalid tls_io_instance->tlsio_state = %s", ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = __FAILURE__;
LogError("invalid tls_io_instance->tlsio_state = %s", MU_ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = MU_FAILURE;
}
else
{
@ -1237,7 +1237,7 @@ int tlsio_schannel_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_ope
{
LogError("xio_open failed");
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1256,7 +1256,7 @@ int tlsio_schannel_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_c
if (tls_io == NULL)
{
LogError("invalid argument detected: tls_io = %p", tls_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1265,8 +1265,8 @@ int tlsio_schannel_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_c
if ((tls_io_instance->tlsio_state == TLSIO_STATE_NOT_OPEN) ||
(tls_io_instance->tlsio_state == TLSIO_STATE_CLOSING))
{
LogError("invalid tls_io_instance->tlsio_state = %s", ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = __FAILURE__;
LogError("invalid tls_io_instance->tlsio_state = %s", MU_ENUM_TO_STRING(TLSIO_STATE, tls_io_instance->tlsio_state));
result = MU_FAILURE;
}
else
{
@ -1276,7 +1276,7 @@ int tlsio_schannel_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_c
if (xio_close(tls_io_instance->socket_io, on_underlying_io_close_complete, tls_io_instance) != 0)
{
LogError("xio_close failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1300,7 +1300,7 @@ int tlsio_schannel_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t si
if (new_pending_send == NULL)
{
LogError("Cannot allocate memory for pending IO");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1308,7 +1308,7 @@ int tlsio_schannel_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t si
if (new_pending_send->bytes == NULL)
{
LogError("Cannot allocate memory for pending IO payload");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1320,7 +1320,7 @@ int tlsio_schannel_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t si
if (singlylinkedlist_add(tls_io_instance->pending_io_list, new_pending_send) == NULL)
{
LogError("Cannot add pending IO to list");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1334,7 +1334,7 @@ int tlsio_schannel_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t si
if (internal_send((TLS_IO_INSTANCE*)tls_io, buffer, size, on_send_complete, callback_context) != 0)
{
LogError("send failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1361,7 +1361,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io == NULL || optionName == NULL)
{
LogError("invalid argument detected: CONCRETE_IO_HANDLE tls_io = %p, const char* optionName = %p", tls_io, optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1371,7 +1371,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509certificate != NULL)
{
LogError("x509certificate has already been specified");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1379,7 +1379,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509certificate == NULL)
{
LogError("tlsio_schannel_CloneOption failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1389,7 +1389,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509_schannel_handle == NULL)
{
LogError("x509_schannel_create failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1409,7 +1409,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509privatekey != NULL)
{
LogError("x509privatekey has already been specified");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1417,7 +1417,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509privatekey == NULL)
{
LogError("tlsio_schannel_CloneOption failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1427,7 +1427,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io_instance->x509_schannel_handle == NULL)
{
LogError("x509_schannel_create failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1447,7 +1447,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (value == NULL)
{
LogError("Invalid paramater: OPTION_TRUSTED_CERT value=NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1460,7 +1460,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (mallocAndStrcpy_s((char**)&tls_io_instance->trustedCertificate, value) != 0)
{
LogError("unable to mallocAndStrcpy_s %s", optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1477,7 +1477,7 @@ int tlsio_schannel_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
else if (tls_io_instance->socket_io == NULL)
{
LogError("tls_io_instance->socket_io is not set");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -19,8 +19,8 @@
TLSIO_STATE_CLOSING, \
TLSIO_STATE_ERROR
DEFINE_ENUM(TLSIO_STATE, TLSIO_STATE_VALUES);
DEFINE_ENUM_STRINGS(TLSIO_STATE, TLSIO_STATE_VALUES);
MU_DEFINE_ENUM(TLSIO_STATE, TLSIO_STATE_VALUES);
MU_DEFINE_ENUM_STRINGS(TLSIO_STATE, TLSIO_STATE_VALUES);
typedef struct TLS_IO_INSTANCE_TAG
{
@ -148,7 +148,7 @@ int tlsio_template_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_ope
if (tls_io == NULL)
{
LogError("invalid argument detected: CONCRETE_IO_HANDLE tls_io = %p", tls_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -168,7 +168,7 @@ int tlsio_template_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_c
if (tls_io == NULL)
{
LogError("invalid argument detected: tls_io = %p", tls_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -210,7 +210,7 @@ int tlsio_template_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName,
if (tls_io == NULL || optionName == NULL)
{
LogError("invalid argument detected: CONCRETE_IO_HANDLE tls_io = %p, const char* optionName = %p", tls_io, optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -458,7 +458,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance)
if (res != SSL_SUCCESS)
{
LogError("wolfSSL_CTX_load_verify_buffer failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -479,18 +479,18 @@ static int x509_wolfssl_add_credentials(WOLFSSL* ssl, char* x509certificate, cha
if (wolfSSL_use_certificate_chain_buffer(ssl, (unsigned char*)x509certificate, strlen(x509certificate)) != SSL_SUCCESS)
{
LogError("unable to load x509 client certificate");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (wolfSSL_use_PrivateKey_buffer(ssl, (unsigned char*)x509privatekey, strlen(x509privatekey), SSL_FILETYPE_PEM) != SSL_SUCCESS)
{
LogError("unable to load x509 client private key");
result = __FAILURE__;
result = MU_FAILURE;
}
#ifdef HAVE_SECURE_RENEGOTIATION
else if (wolfSSL_UseSecureRenegotiation(ssl) != SSL_SUCCESS)
{
LogError("unable to enable secure renegotiation");
result = __FAILURE__;
result = MU_FAILURE;
}
#endif
else
@ -513,7 +513,7 @@ static int create_wolfssl_instance(TLS_IO_INSTANCE* tls_io_instance)
if (tls_io_instance->ssl == NULL)
{
LogError("Failed to add certificates to store");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -542,7 +542,7 @@ static int prepare_wolfssl_open(TLS_IO_INSTANCE* tls_io_instance)
if (add_certificate_to_store(tls_io_instance) != 0)
{
LogError("Failed to add certificates to store");
result = __FAILURE__;
result = MU_FAILURE;
}
/*x509 authentication can only be build before underlying connection is realized*/
else if ((tls_io_instance->x509certificate != NULL) &&
@ -551,13 +551,13 @@ static int prepare_wolfssl_open(TLS_IO_INSTANCE* tls_io_instance)
{
destroy_wolfssl_instance(tls_io_instance);
LogError("unable to use x509 authentication");
result = __FAILURE__;
result = MU_FAILURE;
}
#ifdef INVALID_DEVID
else if (tls_io_instance->wolfssl_device_id != INVALID_DEVID && wolfSSL_SetDevId(tls_io_instance->ssl, tls_io_instance->wolfssl_device_id) != WOLFSSL_SUCCESS)
{
LogError("Failure setting device id");
result = __FAILURE__;
result = MU_FAILURE;
}
#endif
else
@ -708,7 +708,7 @@ int tlsio_wolfssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io == NULL)
{
LogError("NULL tls_io instance");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -717,7 +717,7 @@ int tlsio_wolfssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN)
{
LogError("Invalid state encountered.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -736,13 +736,13 @@ int tlsio_wolfssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
{
LogError("Cannot create wolfssl instance.");
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else if (xio_open(tls_io_instance->socket_io, on_underlying_io_open_complete, tls_io_instance, on_underlying_io_bytes_received, tls_io_instance, on_underlying_io_error, tls_io_instance) != 0)
{
LogError("Cannot open the underlying IO.");
tls_io_instance->tlsio_state = TLSIO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -750,7 +750,7 @@ int tlsio_wolfssl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE on_io_open
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("Failed to connect to server. The certificates may not be correct.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -770,7 +770,7 @@ int tlsio_wolfssl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
if (tls_io == NULL)
{
LogError("NULL tls_io handle.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -780,7 +780,7 @@ int tlsio_wolfssl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
(tls_io_instance->tlsio_state == TLSIO_STATE_CLOSING))
{
LogError("Close called while not open.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -791,7 +791,7 @@ int tlsio_wolfssl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLETE on_io_cl
if (xio_close(tls_io_instance->socket_io, on_underlying_io_close_complete, tls_io_instance) != 0)
{
LogError("xio_close failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -810,7 +810,7 @@ int tlsio_wolfssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (tls_io == NULL || buffer == NULL || size == 0)
{
LogError("Invalid parameter specified tls_io: %p, buffer: %p, size: %ul", tls_io, buffer, (unsigned int)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -819,7 +819,7 @@ int tlsio_wolfssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("send called while not open");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -830,7 +830,7 @@ int tlsio_wolfssl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer, size_t siz
if ((res < 0) || ((size_t)res != size)) // Best way I can think of to safely compare an int to a size_t
{
LogError("Error writing data through WolfSSL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -873,7 +873,7 @@ static int process_option(char** destination, const char* name, const char* valu
if (mallocAndStrcpy_s(destination, value) != 0)
{
LogError("unable to process option %s",name);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -889,7 +889,7 @@ int tlsio_wolfssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io == NULL || optionName == NULL)
{
LogError("Bad arguments, tls_io = %p, optionName = %p", tls_io, optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -916,7 +916,7 @@ int tlsio_wolfssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io_instance->ssl != NULL && wolfSSL_SetDevId(tls_io_instance->ssl, device_id) != WOLFSSL_SUCCESS)
{
LogError("Failure setting device id on ssl");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -936,7 +936,7 @@ int tlsio_wolfssl_setoption(CONCRETE_IO_HANDLE tls_io, const char* optionName, c
if (tls_io_instance->socket_io == NULL)
{
LogError("NULL underlying IO handle");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -8,7 +8,7 @@
#include "azure_c_shared_utility/uniqueid.h"
#include "azure_c_shared_utility/xlogging.h"
DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t len)
{
@ -19,7 +19,7 @@ UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t len)
if (uid == NULL || len < 37)
{
result = UNIQUEID_INVALID_ARG;
LogError("Buffer Size is Null. (result = %s)", ENUM_TO_STRING(UNIQUEID_RESULT, result));
LogError("Buffer Size is Null. (result = %s)", MU_ENUM_TO_STRING(UNIQUEID_RESULT, result));
}
else
{

Просмотреть файл

@ -7,7 +7,7 @@
#include "azure_c_shared_utility/xlogging.h"
#include <time.h>
DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
static const char tochar[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static void generate128BitUUID(unsigned char* arrayOfByte)

Просмотреть файл

@ -7,7 +7,7 @@
#include "azure_c_shared_utility/xlogging.h"
#include <rpc.h>
DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t len)
{

Просмотреть файл

@ -47,7 +47,7 @@ static int load_certificate_chain(SSL_CTX* ssl_ctx, const char* certificate)
if ((bio_cert = BIO_new_mem_buf((char*)certificate, -1)) == NULL)
{
log_ERR_get_error("cannot create BIO");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -55,14 +55,14 @@ static int load_certificate_chain(SSL_CTX* ssl_ctx, const char* certificate)
if ((x509_value = PEM_read_bio_X509_AUX(bio_cert, NULL, NULL, NULL)) == NULL)
{
log_ERR_get_error("Failure PEM_read_bio_X509_AUX");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (SSL_CTX_use_certificate(ssl_ctx, x509_value) != 1)
{
log_ERR_get_error("Failure PEM_read_bio_X509_AUX");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -87,7 +87,7 @@ static int load_certificate_chain(SSL_CTX* ssl_ctx, const char* certificate)
if (SSL_CTX_add_extra_chain_cert(ssl_ctx, ca_chain) != 1)
{
X509_free(ca_chain);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
}
@ -102,7 +102,7 @@ static int load_certificate_chain(SSL_CTX* ssl_ctx, const char* certificate)
}
else
{
result = __FAILURE__;
result = MU_FAILURE;
}
}
}
@ -121,7 +121,7 @@ static int load_ecc_key(SSL_CTX* ssl_ctx, EVP_PKEY* evp_key)
if (SSL_CTX_use_PrivateKey(ssl_ctx, evp_key) != 1)
{
LogError("Failed SSL_CTX_use_PrivateKey");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -140,7 +140,7 @@ static int load_key_RSA(SSL_CTX* ssl_ctx, EVP_PKEY* evp_key)
{
/*Codes_SRS_X509_OPENSSL_02_009: [ Otherwise x509_openssl_add_credentials shall fail and return a non-zero number. ]*/
log_ERR_get_error("Failure reading RSA private key");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -149,7 +149,7 @@ static int load_key_RSA(SSL_CTX* ssl_ctx, EVP_PKEY* evp_key)
{
/*Codes_SRS_X509_OPENSSL_02_009: [ Otherwise x509_openssl_add_credentials shall fail and return a non-zero number. ]*/
log_ERR_get_error("Failure calling SSL_CTX_use_RSAPrivateKey");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -169,7 +169,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
{
/*Codes_SRS_X509_OPENSSL_02_009: [ Otherwise x509_openssl_add_credentials shall fail and return a non-zero number. ]*/
LogError("invalid parameter detected: ssl_ctx=%p, x509certificate=%p, x509privatekey=%p", ssl_ctx, x509certificate, x509privatekey);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -177,7 +177,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
if (bio_key == NULL)
{
log_ERR_get_error("cannot create private key BIO");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -186,7 +186,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
if (evp_key == NULL)
{
log_ERR_get_error("Failure creating private key evp_key");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -197,7 +197,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
if (load_key_RSA(ssl_ctx, evp_key) != 0)
{
LogError("failure loading RSA private key cert");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -209,7 +209,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
if (load_ecc_key(ssl_ctx, evp_key) != 0)
{
LogError("failure loading ECC private key cert");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -223,7 +223,7 @@ int x509_openssl_add_credentials(SSL_CTX* ssl_ctx, const char* x509certificate,
if (load_certificate_chain(ssl_ctx, x509certificate) != 0)
{
LogError("failure loading private key cert");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -249,8 +249,8 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
if ((certificates == NULL) || (ssl_ctx == NULL))
{
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
LogError("invalid argument SSL_CTX* ssl_ctx=%p, const char* certificates=%s", ssl_ctx, P_OR_NULL(certificates));
result = __FAILURE__;
LogError("invalid argument SSL_CTX* ssl_ctx=%p, const char* certificates=%s", ssl_ctx, MU_P_OR_NULL(certificates));
result = MU_FAILURE;
}
else
{
@ -259,7 +259,7 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
{
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
log_ERR_get_error("failure in SSL_CTX_get_cert_store.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -274,7 +274,7 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
{
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
log_ERR_get_error("failure in BIO_s_mem");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -284,7 +284,7 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
{
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
log_ERR_get_error("failure in BIO_new");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -294,7 +294,7 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
{
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
log_ERR_get_error("failure in BIO_puts");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -333,7 +333,7 @@ int x509_openssl_add_certificates(SSL_CTX* ssl_ctx, const char* certificates)
{
/*previous while loop terminated unfortunately*/
/*Codes_SRS_X509_OPENSSL_02_018: [ In case of any failure x509_openssl_add_certificates shall fail and return a non-zero value. ]*/
result = __FAILURE__;
result = MU_FAILURE;
}
}
BIO_free(cert_memory_bio);

Просмотреть файл

@ -166,7 +166,7 @@ static int set_ecc_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
/*Codes_SRS_X509_SCHANNEL_02_010: [ Otherwise, x509_schannel_create shall fail and return a NULL X509_SCHANNEL_HANDLE. ]*/
LogError("Failed to malloc NCrypt private key blob");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -185,7 +185,7 @@ static int set_ecc_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
/* Codes_SRS_X509_SCHANNEL_02_010: [ Otherwise, x509_schannel_create shall fail and return a NULL X509_SCHANNEL_HANDLE. ]*/
LogError("NCryptOpenStorageProvider failed with error 0x%08X", status);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -228,13 +228,13 @@ static int set_ecc_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
/*Codes_SRS_X509_SCHANNEL_02_010: [ Otherwise, x509_schannel_create shall fail and return a NULL X509_SCHANNEL_HANDLE. ]*/
LogError("NCryptImportKey failed with error 0x%08X", status);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (!CertSetCertificateContextProperty(x509_handle->x509certificate_context, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo))
{
/*Codes_SRS_X509_SCHANNEL_02_010: [ Otherwise, x509_schannel_create shall fail and return a NULL X509_SCHANNEL_HANDLE. ]*/
LogErrorWinHTTPWithGetLastErrorAsString("CertSetCertificateContextProperty failed to set NCrypt key handle property");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -247,7 +247,7 @@ static int set_ecc_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
(void)x509_handle;
(void)x509privatekeyBlob;
LogError("SChannel ECC is not supported in this compliation");
result = __FAILURE__;
result = MU_FAILURE;
#endif
return result;
}
@ -261,7 +261,7 @@ static int set_rsa_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
/*Codes_SRS_X509_SCHANNEL_02_010: [ Otherwise, x509_schannel_create shall fail and return a NULL X509_SCHANNEL_HANDLE. ]*/
LogErrorWinHTTPWithGetLastErrorAsString("CryptAcquireContext failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -274,7 +274,7 @@ static int set_rsa_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
LogErrorWinHTTPWithGetLastErrorAsString("unable to CryptReleaseContext");
}
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -292,7 +292,7 @@ static int set_rsa_certificate_info(X509_SCHANNEL_HANDLE_DATA* x509_handle, unsi
{
LogErrorWinHTTPWithGetLastErrorAsString("unable to CryptReleaseContext");
}
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -495,7 +495,7 @@ static int add_certificates_to_store(const char* trustedCertificate, HCERTSTORE
if (numCertificatesAdded == 0)
{
LogError("Certificate missing closing %s. No certificates can be added to stare", end_certificate_in_pem);
result = __FAILURE__;
result = MU_FAILURE;
}
break;
}
@ -509,13 +509,13 @@ static int add_certificates_to_store(const char* trustedCertificate, HCERTSTORE
if ((trustedCertificateEncoded = convert_cert_to_binary(trustedCertCurrentRead, (DWORD)(endCertificateCurrentRead - trustedCertCurrentRead), &trustedCertificateEncodedLen)) == NULL)
{
LogError("Cannot encode trusted certificate");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (CertAddEncodedCertificateToStore(hCertStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, trustedCertificateEncoded, trustedCertificateEncodedLen, CERT_STORE_ADD_NEW, NULL) != TRUE)
{
lastError = GetLastError();
LogError("CertAddEncodedCertificateToStore failed with error 0x%08x", lastError);
result = __FAILURE__;
result = MU_FAILURE;
}
if (trustedCertificateEncoded != NULL)
@ -542,19 +542,19 @@ int x509_verify_certificate_in_chain(const char* trustedCertificate, PCCERT_CONT
if ((trustedCertificate == NULL) || (pCertContextToVerify == NULL))
{
result = __FAILURE__;
result = MU_FAILURE;
}
// Creates an in-memory certificate store that is destroyed at end of this function.
else if (NULL == (hCertStore = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_STORE_CREATE_NEW_FLAG, NULL)))
{
lastError = GetLastError();
LogError("CertOpenStore failed with error 0x%08x", lastError);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (add_certificates_to_store(trustedCertificate, hCertStore) != 0)
{
LogError("Cannot add certificates to store");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -580,24 +580,24 @@ int x509_verify_certificate_in_chain(const char* trustedCertificate, PCCERT_CONT
{
lastError = GetLastError();
LogError("CertCreateCertificateChainEngine failed with error 0x%08x", lastError);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (CertGetCertificateChain(hChainEngine, pCertContextToVerify, NULL, pCertContextToVerify->hCertStore, &ChainPara, 0, NULL, &pChainContextToVerify) != TRUE)
{
lastError = GetLastError();
LogError("CertGetCertificateChain failed with error 0x%08x", lastError);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, pChainContextToVerify, &PolicyPara, &PolicyStatus) != TRUE)
{
lastError = GetLastError();
LogError("CertVerifyCertificateChainPolicy failed with error 0x%08x", lastError);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (PolicyStatus.dwError != 0)
{
LogError("CertVerifyCertificateChainPolicy sets certificateStatus = 0x%08x", PolicyStatus.dwError);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -290,7 +290,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
(on_bytes_received == NULL) ||
(on_io_error == NULL))
{
result = __FAILURE__;
result = MU_FAILURE;
LogError("NULL tls_io.");
}
else
@ -300,7 +300,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
/* Codes_SRS_TLSIO_CYCLONESSL_01_034: [ If tlsio_cyclonessl_open is called while the IO is open, tlsio_cyclonessl_open shall fail and return a non-zero value without performing any work to open the IO. ]*/
if (tls_io_instance->tlsio_state != TLSIO_STATE_NOT_OPEN)
{
result = __FAILURE__;
result = MU_FAILURE;
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_NOT_OPEN.");
}
else
@ -316,7 +316,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
{
/* Codes_SRS_TLSIO_CYCLONESSL_01_026: [ If tlsio_cyclonessl_socket_create fails, then tlsio_cyclonessl_open shall return a non-zero value. ]*/
LogError("Error: Cannot open socket");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -327,7 +327,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
tlsio_cyclonessl_socket_destroy(tls_io_instance->socket);
tls_io_instance->socket = (TlsSocket)NULL;
LogError("Error: tlsSetSocket");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -348,7 +348,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
tlsio_cyclonessl_socket_destroy(tls_io_instance->socket);
tls_io_instance->socket = (TlsSocket)NULL;
LogError("tlsSetTrustedCaList failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -359,7 +359,7 @@ static int tlsio_cyclonessl_open(CONCRETE_IO_HANDLE tls_io, ON_IO_OPEN_COMPLETE
tlsio_cyclonessl_socket_destroy(tls_io_instance->socket);
tls_io_instance->socket = (TlsSocket)NULL;
LogError("tlsConnect failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -387,7 +387,7 @@ static int tlsio_cyclonessl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLET
if (tls_io == NULL)
{
LogError("NULL tls_io.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -396,7 +396,7 @@ static int tlsio_cyclonessl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLET
/* Codes_SRS_TLSIO_CYCLONESSL_01_041: [ If tlsio_cyclonessl_close is called when not open, tlsio_cyclonessl_close shall fail and return a non-zero value. ]*/
if (tls_io_instance->tlsio_state == TLSIO_STATE_NOT_OPEN)
{
result = __FAILURE__;
result = MU_FAILURE;
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_NOT_OPEN or TLSIO_STATE_CLOSING.");
}
else
@ -406,7 +406,7 @@ static int tlsio_cyclonessl_close(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COMPLET
{
/* Codes_SRS_TLSIO_CYCLONESSL_01_038: [ If tlsShutdown fails, tlsio_cyclonessl_close shall fail and return a non-zero value. ]*/
LogError("tlsShutdown failed\r\n");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -441,7 +441,7 @@ static int tlsio_cyclonessl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer,
(size == 0))
{
LogError("NULL tls_io.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -453,7 +453,7 @@ static int tlsio_cyclonessl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer,
if (tls_io_instance->tlsio_state != TLSIO_STATE_OPEN)
{
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_OPEN.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -461,7 +461,7 @@ static int tlsio_cyclonessl_send(CONCRETE_IO_HANDLE tls_io, const void* buffer,
if (tlsWrite(tls_io_instance->tlsContext, buffer, size, 0) != 0)
{
LogError("SSL_write error.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -532,7 +532,7 @@ static int tlsio_cyclonessl_setoption(CONCRETE_IO_HANDLE tls_io, const char* opt
if ((tls_io == NULL) || (optionName == NULL))
{
LogError("NULL tls_io");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -563,7 +563,7 @@ static int tlsio_cyclonessl_setoption(CONCRETE_IO_HANDLE tls_io, const char* opt
{
/* Codes_SRS_TLSIO_CYCLONESSL_01_061: [ If copying the char\* passed in value fails then tlsio_cyclonessl_setoption shall return a non-zero value. ]*/
LogError("Error allocating memory for certificates");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -576,7 +576,7 @@ static int tlsio_cyclonessl_setoption(CONCRETE_IO_HANDLE tls_io, const char* opt
{
/* Codes_SRS_TLSIO_CYCLONESSL_01_058: [ If the option_name argument indicates an option that is not handled by tlsio_cyclonessl, then tlsio_cyclonessl_setoption shall return a non-zero value. ]*/
LogError("Unrecognized option");
result = __FAILURE__;
result = MU_FAILURE;
}
}

Просмотреть файл

@ -22,7 +22,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
(new_socket == NULL))
{
LogError("Invalid arguments: hostname = %p, new_socket = %p", hostname, new_socket);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -32,7 +32,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
{
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
LogError("socketOpen failed, cannot create socket");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -44,7 +44,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
socketClose(socket);
LogError("Cannot resolve host");
result = __FAILURE__;
result = MU_FAILURE;
}
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_01_006: [ tlsio_cyclonessl_socket_create shall call socketConnect and pass the obtained address in order to connect the socket. ]*/
else if (socketConnect(socket, &ipAddr, port) != 0)
@ -52,7 +52,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
socketClose(socket);
LogError("Failed to connect");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -30,7 +30,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
(new_socket == NULL))
{
LogError("Invalid arguments: hostname = %p, new_socket = %p", hostname, new_socket);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -40,7 +40,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
{
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_BSD_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
LogError("Error: Cannot create socket (%d)\r\n", WSAGetLastError());
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -59,7 +59,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_BSD_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
LogError("Failure: getaddrinfo failure %d.", WSAGetLastError());
(void)closesocket(sock);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -69,7 +69,7 @@ int tlsio_cyclonessl_socket_create(const char* hostname, unsigned int port, TlsS
/* Codes_SRS_TLSIO_CYCLONESSL_SOCKET_BSD_01_007: [ If any of the socket calls fails, then tlsio_cyclonessl_socket_create shall fail and return a non-zero value. ]*/
LogError("Error: Failed to connect (%d)\r\n", WSAGetLastError());
closesocket(sock);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -13,7 +13,7 @@ This module is used to encode a BUFFER using the standard base64 encoding stream
```c
extern STRING_HANDLE Base64_Encode(BUFFER_HANDLE input);
extern STRING_HANDLE Base64_Encode_Bytes(const unsigned char* source, size_t size);
extern BUFFER_HANDLE Base64_Decode(const char* source);
extern BUFFER_HANDLE Azure_Base64_Decode(const char* source);
```
### Base64_Encode
@ -46,15 +46,15 @@ Base64_Encode_Bytes shall produce a STRING_HANDLE containing the base64 encoding
**SRS_BASE64_02_004: [** In case of any errors, Base64_Encode_Bytes shall return NULL. **]**
### Base64_Decode
### Azure_Base64_Decode
```c
extern BUFFER_HANDLE Base64_Decode(const char* source);
extern BUFFER_HANDLE Azure_Base64_Decode(const char* source);
```
**SRS_BASE64_06_008: [** If source is NULL then Base64_Decode shall return NULL. **]**
**SRS_BASE64_06_008: [** If source is NULL then Azure_Base64_Decode shall return NULL. **]**
**SRS_BASE64_06_009: [** If the string pointed to by source is zero length then the handle returned shall refer to a zero length buffer. **]**
**SRS_BASE64_06_010: [** If there is any memory allocation failure during the decode then Base64_Decode shall return NULL. **]**
**SRS_BASE64_06_010: [** If there is any memory allocation failure during the decode then Azure_Base64_Decode shall return NULL. **]**
**SRS_BASE64_06_011: [** If the source string has an invalid length for a base 64 encoded string then Base64_Decode shall return NULL. **]**
**SRS_BASE64_06_011: [** If the source string has an invalid length for a base 64 encoded string then Azure_Base64_Decode shall return NULL. **]**

Просмотреть файл

@ -86,19 +86,19 @@ extern int connectionstringparser_splitHostName_from_char(const char* hostName,
**SRS_CONNECTIONSTRINGPARSER_21_025: [** If connectionstringparser_splitHostName_from_char get success splitting the hostName, it shall return 0. **]**
**SRS_CONNECTIONSTRINGPARSER_21_026: [** If the hostName is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_026: [** If the hostName is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_027: [** If the hostName is an empty string, connectionstringparser_splitHostName_from_char shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_027: [** If the hostName is an empty string, connectionstringparser_splitHostName_from_char shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_028: [** If the nameString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_028: [** If the nameString is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_029: [** If the suffixString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_029: [** If the suffixString is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_030: [** If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_030: [** If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_031: [** If connectionstringparser_splitHostName_from_char get error copying the name to the nameString, it shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_031: [** If connectionstringparser_splitHostName_from_char get error copying the name to the nameString, it shall return MU_FAILURE. **]**
**SRS_CONNECTIONSTRINGPARSER_21_032: [** If connectionstringparser_splitHostName_from_char get error copying the suffix to the suffixString, it shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_032: [** If connectionstringparser_splitHostName_from_char get error copying the suffix to the suffixString, it shall return MU_FAILURE. **]**
### connectionstringparser_splitHostName
@ -109,4 +109,4 @@ extern int connectionstringparser_splitHostName(STRING_HANDLE hostNameString, ST
**SRS_CONNECTIONSTRINGPARSER_21_033: [** connectionstringparser_splitHostName shall convert the hostNameString to a connection_string passed in as argument, and call connectionstringparser_splitHostName_from_char. **]**
**SRS_CONNECTIONSTRINGPARSER_21_034: [** If the hostNameString is NULL, connectionstringparser_splitHostName shall return __FAILURE__. **]**
**SRS_CONNECTIONSTRINGPARSER_21_034: [** If the hostNameString is NULL, connectionstringparser_splitHostName shall return MU_FAILURE. **]**

Просмотреть файл

@ -19,7 +19,7 @@ Const Map is a module that implements a read-only dictionary of `const char*` ke
CONSTMAP_INVALIDARG, \
CONSTMAP_KEYNOTFOUND
DEFINE_ENUM(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
MU_DEFINE_ENUM(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
typedef struct CONSTMAP_HANDLE_DATA_TAG* CONSTMAP_HANDLE;

Просмотреть файл

@ -149,7 +149,7 @@ MOCKABLE_FUNCTION(, HTTPAPI_RESULT, HTTPAPI_CloneOption, const char*, optionName
/** @brief Enumeration specifying the HTTP request verbs accepted by
* the HTTPAPI module.
*/
DEFINE_ENUM(HTTPAPI_REQUEST_TYPE, HTTPAPI_REQUEST_TYPE_VALUES);
MU_DEFINE_ENUM(HTTPAPI_REQUEST_TYPE, HTTPAPI_REQUEST_TYPE_VALUES);
```
**]**
@ -179,7 +179,7 @@ HTTPAPI_SET_TIMEOUTS_FAILED \
/** @brief Enumeration specifying the possible return values for the APIs in
* this module.
*/
DEFINE_ENUM(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
MU_DEFINE_ENUM(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
```
**]**

Просмотреть файл

@ -20,7 +20,7 @@ HTTAPIEX is a utility module that provides HTTP requests with build-in retry cap
HTTPAPIEX_RECOVERYFAILED
/*to be continued*/
DEFINE_ENUM(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
MU_DEFINE_ENUM(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
extern HTTPAPIEX_HANDLE HTTPAPIEX_Create(const char* hostName);

Просмотреть файл

@ -21,7 +21,7 @@ Map is a module that implements a dictionary of STRING_HANDLE key to STRING_HAND
MAP_KEYNOTFOUND, \
MAP_FILTER_REJECT
DEFINE_ENUM(MAP_RESULT, MAP_RESULT_VALUES);
MU_DEFINE_ENUM(MAP_RESULT, MAP_RESULT_VALUES);
typedef void* MAP_HANDLE;

Просмотреть файл

@ -14,7 +14,7 @@ OPTIONHANDLER_OK,
OPTIONHANDLER_ERROR,
OPTIONHANDLER_INVALIDARG
DEFINE_ENUM(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
MU_DEFINE_ENUM(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
#ifdef __cplusplus
extern "C" {

Просмотреть файл

@ -9,9 +9,9 @@ It wraps the structure that needs to be ref counted into another structure that
## Exposed API
```c
#define REFCOUNT_TYPE_CREATE(type) C2(REFCOUNT_SHORT_TYPE(type), _Create)()
#define REFCOUNT_TYPE_CREATE_WITH_EXTRA_SIZE(type, size) C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)(size)
#define REFCOUNT_TYPE_DESTROY(type, var) C2(REFCOUNT_SHORT_TYPE(type), _Destroy)(var)
#define REFCOUNT_TYPE_CREATE(type) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create)()
#define REFCOUNT_TYPE_CREATE_WITH_EXTRA_SIZE(type, size) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)(size)
#define REFCOUNT_TYPE_DESTROY(type, var) MU_C2(REFCOUNT_SHORT_TYPE(type), _Destroy)(var)
#define DEFINE_REFCOUNT_TYPE(type) \
...

Просмотреть файл

@ -24,7 +24,7 @@ Add any reference that can support this implementation here. For example, it the
TARGET_RESULT_OK, \
TARGET_RESULT_FAIL, \
TARGET_RESULT_OUT_OF_MEMORY
DEFINE_ENUM(TARGET_RESULT, TARGET_RESULT_VALUES);
MU_DEFINE_ENUM(TARGET_RESULT, TARGET_RESULT_VALUES);
```
**]**

Просмотреть файл

@ -11,7 +11,7 @@ The UniqueIDs module provides pseudo unique identifiers to the rest of the modul
UNIQUEID_INVALID_ARG, \
UNIQUEID_ERROR
DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
MU_DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
extern UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t bufferSize);
```

Просмотреть файл

@ -18,7 +18,7 @@ typedef struct UWS_CLIENT_INSTANCE_TAG* UWS_CLIENT_HANDLE;
WS_SEND_FRAME_ERROR, \
WS_SEND_FRAME_CANCELLED
DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
MU_DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
#define WS_OPEN_RESULT_VALUES \
WS_OPEN_OK, \
@ -36,7 +36,7 @@ DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
WS_OPEN_ERROR_BAD_UPGRADE_RESPONSE, \
WS_OPEN_ERROR_BAD_RESPONSE_STATUS
DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
MU_DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
#define WS_ERROR_VALUES \
WS_ERROR_NOT_ENOUGH_MEMORY, \
@ -45,7 +45,7 @@ DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
WS_ERROR_UNDERLYING_IO_ERROR, \
WS_ERROR_CANNOT_CLOSE_UNDERLYING_IO
DEFINE_ENUM(WS_ERROR, WS_ERROR_VALUES);
MU_DEFINE_ENUM(WS_ERROR, WS_ERROR_VALUES);
#define WS_FRAME_TYPE_TEXT 0x01
#define WS_FRAME_TYPE_BINARY 0x02

Просмотреть файл

@ -33,7 +33,7 @@ RFC6455 - The WebSocket Protocol.
WS_RESERVED_CONTROL_FRAME_E = 0x0E, \
WS_RESERVED_CONTROL_FRAME_F = 0x0F
DEFINE_ENUM(WS_FRAME_TYPE, WS_FRAME_TYPE_VALUES);
MU_DEFINE_ENUM(WS_FRAME_TYPE, WS_FRAME_TYPE_VALUES);
extern int uws_frame_encoder_encode(BUFFER_HANDLE encode_buffer, WS_FRAME_TYPE opcode, const unsigned char* payload, size_t length, bool is_masked, bool is_final, unsigned char reserved);
```

Просмотреть файл

@ -37,7 +37,7 @@ extern "C" {
*
* @return A @c STRING_HANDLE containing the base64 encoding of @p input.
*/
MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode, BUFFER_HANDLE, input);
MOCKABLE_FUNCTION(, STRING_HANDLE, Azure_Base64_Encode, BUFFER_HANDLE, input);
/**
* @brief Base64 encodes the buffer pointed to by @p source and returns the resulting string.
@ -57,7 +57,7 @@ MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode, BUFFER_HANDLE, input);
* of @p input.
*
*/
MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode_Bytes, const unsigned char*, source, size_t, size);
MOCKABLE_FUNCTION(, STRING_HANDLE, Azure_Base64_Encode_Bytes, const unsigned char*, source, size_t, size);
/**
* @brief Base64 decodes the buffer pointed to by @p source and returns the resulting buffer.
@ -66,15 +66,15 @@ MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode_Bytes, const unsigned char*, so
*
* This function decodes the string pointed at by @p source using base64 decoding and
* returns the resulting buffer. If @p source is @c NULL then
* @c Base64_Decode returns NULL. If the string pointed to by @p source is zero
* @c Azure_Base64_Decode returns NULL. If the string pointed to by @p source is zero
* length then the handle returned refers to a zero length buffer. If there is any
* memory allocation failure during the decode or if the source string has an invalid
* length for a base 64 encoded string then @c Base64_Decode returns @c NULL.
* length for a base 64 encoded string then @c Azure_Base64_Decode returns @c NULL.
*
* @return A @c BUFFER_HANDLE pointing to a buffer containing the result of base64 decoding @p
* source.
*/
MOCKABLE_FUNCTION(, BUFFER_HANDLE, Base64_Decode, const char*, source);
MOCKABLE_FUNCTION(, BUFFER_HANDLE, Azure_Base64_Decode, const char*, source);
#ifdef __cplusplus
}

Просмотреть файл

@ -23,7 +23,7 @@ typedef void* COND_HANDLE;
/**
* @brief Enumeration specifying the lock status.
*/
DEFINE_ENUM(COND_RESULT, COND_RESULT_VALUES);
MU_DEFINE_ENUM(COND_RESULT, COND_RESULT_VALUES);
/**
* @brief This API creates and returns a valid condition handle.

Просмотреть файл

@ -32,7 +32,7 @@ extern "C"
/** @brief Enumeration specifying the status of calls to various APIs in this
* module.
*/
DEFINE_ENUM(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
MU_DEFINE_ENUM(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
typedef struct CONSTMAP_HANDLE_DATA_TAG* CONSTMAP_HANDLE;

Просмотреть файл

@ -17,7 +17,7 @@ extern "C" {
HMACSHA256_INVALID_ARG, \
HMACSHA256_ERROR
DEFINE_ENUM(HMACSHA256_RESULT, HMACSHA256_RESULT_VALUES)
MU_DEFINE_ENUM(HMACSHA256_RESULT, HMACSHA256_RESULT_VALUES)
MOCKABLE_FUNCTION(, HMACSHA256_RESULT, HMACSHA256_ComputeHash, const unsigned char*, key, size_t, keyLen, const unsigned char*, payload, size_t, payloadLen, BUFFER_HANDLE, hash);

Просмотреть файл

@ -53,7 +53,7 @@ HTTPAPI_SET_TIMEOUTS_FAILED \
/** @brief Enumeration specifying the possible return values for the APIs in
* this module.
*/
DEFINE_ENUM(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
MU_DEFINE_ENUM(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
#define HTTPAPI_REQUEST_TYPE_VALUES\
HTTPAPI_REQUEST_GET, \
@ -67,7 +67,7 @@ DEFINE_ENUM(HTTPAPI_RESULT, HTTPAPI_RESULT_VALUES);
/** @brief Enumeration specifying the HTTP request verbs accepted by
* the HTTPAPI module.
*/
DEFINE_ENUM(HTTPAPI_REQUEST_TYPE, HTTPAPI_REQUEST_TYPE_VALUES);
MU_DEFINE_ENUM(HTTPAPI_REQUEST_TYPE, HTTPAPI_REQUEST_TYPE_VALUES);
#define MAX_HOSTNAME_LEN 65
#define MAX_USERNAME_LEN 65

Просмотреть файл

@ -38,7 +38,7 @@ typedef struct HTTPAPIEX_HANDLE_DATA_TAG* HTTPAPIEX_HANDLE;
/** @brief Enumeration specifying the status of calls to various APIs in this module.
*/
DEFINE_ENUM(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
MU_DEFINE_ENUM(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
/**
* @brief Creates an @c HTTPAPIEX_HANDLE that can be used in further calls.

Просмотреть файл

@ -41,7 +41,7 @@ HTTP_HEADERS_ERROR \
/** @brief Enumeration specifying the status of calls to various APIs in this module.
*/
DEFINE_ENUM(HTTP_HEADERS_RESULT, HTTP_HEADERS_RESULT_VALUES);
MU_DEFINE_ENUM(HTTP_HEADERS_RESULT, HTTP_HEADERS_RESULT_VALUES);
typedef struct HTTP_HEADERS_HANDLE_DATA_TAG* HTTP_HEADERS_HANDLE;
/**

Просмотреть файл

@ -29,7 +29,7 @@ typedef void* LOCK_HANDLE;
/** @brief Enumeration specifying the lock status.
*/
DEFINE_ENUM(LOCK_RESULT, LOCK_RESULT_VALUES);
MU_DEFINE_ENUM(LOCK_RESULT, LOCK_RESULT_VALUES);
/**
* @brief This API creates and returns a valid lock handle.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,7 +33,7 @@ extern "C"
/** @brief Enumeration specifying the status of calls to various APIs in this
* module.
*/
DEFINE_ENUM(MAP_RESULT, MAP_RESULT_VALUES);
MU_DEFINE_ENUM(MAP_RESULT, MAP_RESULT_VALUES);
typedef struct MAP_HANDLE_DATA_TAG* MAP_HANDLE;

Просмотреть файл

@ -15,9 +15,9 @@
#endif
#if (defined OPTIMIZE_RETURN_CODES)
#define __FAILURE__ 1
#define MU_FAILURE 1
#else
#define __FAILURE__ __LINE__
#define MU_FAILURE __LINE__
#endif
#endif // OPTIMIZE_SIZE_H

Просмотреть файл

@ -11,7 +11,7 @@ OPTIONHANDLER_OK, \
OPTIONHANDLER_ERROR, \
OPTIONHANDLER_INVALIDARG
DEFINE_ENUM(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
MU_DEFINE_ENUM(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
#ifdef __cplusplus
extern "C" {

Просмотреть файл

@ -31,17 +31,17 @@ extern "C"
#include "refcount_os.h"
#define REFCOUNT_TYPE(type) \
struct C2(C2(REFCOUNT_, type), _TAG)
struct MU_C2(MU_C2(REFCOUNT_, type), _TAG)
#define REFCOUNT_SHORT_TYPE(type) \
C2(REFCOUNT_, type)
MU_C2(REFCOUNT_, type)
#define REFCOUNT_TYPE_DECLARE_CREATE(type) C2(REFCOUNT_SHORT_TYPE(type), _Create)
#define REFCOUNT_TYPE_DECLARE_CREATE_WITH_EXTRA_SIZE(type) C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)
#define REFCOUNT_TYPE_CREATE(type) C2(REFCOUNT_SHORT_TYPE(type), _Create)()
#define REFCOUNT_TYPE_CREATE_WITH_EXTRA_SIZE(type, size) C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)(size)
#define REFCOUNT_TYPE_DECLARE_DESTROY(type) C2(REFCOUNT_SHORT_TYPE(type), _Destroy)
#define REFCOUNT_TYPE_DESTROY(type, var) C2(REFCOUNT_SHORT_TYPE(type), _Destroy)(var)
#define REFCOUNT_TYPE_DECLARE_CREATE(type) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create)
#define REFCOUNT_TYPE_DECLARE_CREATE_WITH_EXTRA_SIZE(type) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)
#define REFCOUNT_TYPE_CREATE(type) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create)()
#define REFCOUNT_TYPE_CREATE_WITH_EXTRA_SIZE(type, size) MU_C2(REFCOUNT_SHORT_TYPE(type), _Create_With_Extra_Size)(size)
#define REFCOUNT_TYPE_DECLARE_DESTROY(type) MU_C2(REFCOUNT_SHORT_TYPE(type), _Destroy)
#define REFCOUNT_TYPE_DESTROY(type, var) MU_C2(REFCOUNT_SHORT_TYPE(type), _Destroy)(var)
/*this introduces a new refcount'd type based on another type */
/*and an initializer for that new type that also sets the ref count to 1. The type must not have a flexible array*/

Просмотреть файл

@ -27,7 +27,7 @@ typedef int(*THREAD_START_FUNC)(void *);
/** @brief Enumeration specifying the possible return values for the APIs in
* this module.
*/
DEFINE_ENUM(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
MU_DEFINE_ENUM(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
typedef void* THREAD_HANDLE;

Просмотреть файл

@ -22,12 +22,12 @@
#include "azure_c_shared_utility/macro_utils.h"
#define UMOCK_C_PROD_ARG_IN_SIGNATURE(count, arg_type, arg_name) arg_type arg_name IFCOMMA(count)
#define UMOCK_C_PROD_ARG_IN_SIGNATURE(count, arg_type, arg_name) arg_type arg_name MU_IFCOMMA(count)
/* Codes_SRS_UMOCK_C_LIB_01_002: [The macro shall generate a function signature in case ENABLE_MOCKS is not defined.] */
/* Codes_SRS_UMOCK_C_LIB_01_005: [**If ENABLE_MOCKS is not defined, MOCKABLE_FUNCTION shall only generate a declaration for the function.] */
/* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/
#define MOCKABLE_FUNCTION(modifiers, result, function, ...) \
result modifiers function(IF(COUNT_ARG(__VA_ARGS__),,void) FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__));
result modifiers function(MU_IF(MU_COUNT_ARG(__VA_ARGS__),,void) MU_FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__));
#endif

Просмотреть файл

@ -20,7 +20,7 @@ extern "C" {
UNIQUEID_INVALID_ARG, \
UNIQUEID_ERROR
DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
MU_DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
MOCKABLE_FUNCTION(, UNIQUEID_RESULT, UniqueId_Generate, char*, uid, size_t, bufferSize);

Просмотреть файл

@ -25,7 +25,7 @@ typedef struct UWS_CLIENT_INSTANCE_TAG* UWS_CLIENT_HANDLE;
WS_SEND_FRAME_ERROR, \
WS_SEND_FRAME_CANCELLED
DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
MU_DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
#define WS_OPEN_RESULT_VALUES \
WS_OPEN_OK, \
@ -44,7 +44,7 @@ DEFINE_ENUM(WS_SEND_FRAME_RESULT, WS_SEND_FRAME_RESULT_VALUES);
WS_OPEN_ERROR_BAD_RESPONSE_STATUS, \
WS_OPEN_ERROR_BASE64_ENCODE_FAILED
DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
MU_DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
#define WS_ERROR_VALUES \
WS_ERROR_NOT_ENOUGH_MEMORY, \
@ -53,7 +53,7 @@ DEFINE_ENUM(WS_OPEN_RESULT, WS_OPEN_RESULT_VALUES);
WS_ERROR_UNDERLYING_IO_ERROR, \
WS_ERROR_CANNOT_CLOSE_UNDERLYING_IO
DEFINE_ENUM(WS_ERROR, WS_ERROR_VALUES);
MU_DEFINE_ENUM(WS_ERROR, WS_ERROR_VALUES);
#define WS_FRAME_TYPE_UNKNOWN 0x00
#define WS_FRAME_TYPE_TEXT 0x01

Просмотреть файл

@ -38,7 +38,7 @@ extern "C" {
WS_RESERVED_CONTROL_FRAME_E, \
WS_RESERVED_CONTROL_FRAME_F
DEFINE_ENUM(WS_FRAME_TYPE, WS_FRAME_TYPE_VALUES);
MU_DEFINE_ENUM(WS_FRAME_TYPE, WS_FRAME_TYPE_VALUES);
MOCKABLE_FUNCTION(, BUFFER_HANDLE, uws_frame_encoder_encode, WS_FRAME_TYPE, opcode, const unsigned char*, payload, size_t, length, bool, is_masked, bool, is_final, unsigned char, reserved);

Просмотреть файл

@ -24,14 +24,14 @@ typedef void* CONCRETE_IO_HANDLE;
IO_SEND_ERROR, \
IO_SEND_CANCELLED
DEFINE_ENUM(IO_SEND_RESULT, IO_SEND_RESULT_VALUES);
MU_DEFINE_ENUM(IO_SEND_RESULT, IO_SEND_RESULT_VALUES);
#define IO_OPEN_RESULT_VALUES \
IO_OPEN_OK, \
IO_OPEN_ERROR, \
IO_OPEN_CANCELLED
DEFINE_ENUM(IO_OPEN_RESULT, IO_OPEN_RESULT_VALUES);
MU_DEFINE_ENUM(IO_OPEN_RESULT, IO_OPEN_RESULT_VALUES);
typedef void(*ON_BYTES_RECEIVED)(void* context, const unsigned char* buffer, size_t size);
typedef void(*ON_SEND_COMPLETE)(void* context, IO_SEND_RESULT send_result);

Просмотреть файл

@ -59,7 +59,7 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
/* Codes_SRS_TICKCOUNTER_FREERTOS_30_007: [ If the tick_counter parameter is NULL, tickcounter_get_current_ms shall return a non-zero value to indicate error. ] */
/* Codes_SRS_TICKCOUNTER_FREERTOS_30_008: [ If the current_ms parameter is NULL, tickcounter_get_current_ms shall return a non-zero value to indicate error. ] */
LogError("Invalid Arguments.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -69,7 +69,7 @@ MOCKABLE_FUNCTION(, SOCKET_ASYNC_HANDLE, socket_async_create, uint32_t, host_ipv
* @param is_created Receives the completion state if successful, set to false on failure.
*
* @return @c 0 if the API call is successful.
* __FAILURE__ means an unexpected error has occurred and the socket must be destroyed.
* MU_FAILURE means an unexpected error has occurred and the socket must be destroyed.
*/
MOCKABLE_FUNCTION(, int, socket_async_is_create_complete, SOCKET_ASYNC_HANDLE, sock, bool*, is_complete);
@ -86,7 +86,7 @@ MOCKABLE_FUNCTION(, int, socket_async_is_create_complete, SOCKET_ASYNC_HANDLE, s
* case means normal operation but the socket's outgoing buffer was full.
*
* @return @c 0 if successful.
* __FAILURE__ means an unexpected error has occurred and the socket must be destroyed.
* MU_FAILURE means an unexpected error has occurred and the socket must be destroyed.
*/
MOCKABLE_FUNCTION(, int, socket_async_send, SOCKET_ASYNC_HANDLE, sock, const void*, buffer, size_t, size, size_t*, sent_count);
@ -102,7 +102,7 @@ MOCKABLE_FUNCTION(, int, socket_async_send, SOCKET_ASYNC_HANDLE, sock, const voi
* @param received_count Receives the number of bytes received into the buffer.
*
* @return @c 0 if successful.
* __FAILURE__ means an unexpected error has occurred and the socket must be destroyed.
* MU_FAILURE means an unexpected error has occurred and the socket must be destroyed.
*/
MOCKABLE_FUNCTION(, int, socket_async_receive, SOCKET_ASYNC_HANDLE, sock, void*, buffer, size_t, size, size_t*, received_count);

Просмотреть файл

@ -299,14 +299,14 @@ static int tlsio_appleios_open_async(CONCRETE_IO_HANDLE tls_io,
{
/* Codes_SRS_TLSIO_30_031: [ If the on_io_open_complete parameter is NULL, tlsio_open shall log an error and return FAILURE. ]*/
LogError("Required parameter on_io_open_complete is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (tls_io == NULL)
{
/* Codes_SRS_TLSIO_30_030: [ If the tlsio_handle parameter is NULL, tlsio_open shall log an error and return FAILURE. ]*/
result = __FAILURE__;
result = MU_FAILURE;
LogError("NULL tlsio");
}
else
@ -315,7 +315,7 @@ static int tlsio_appleios_open_async(CONCRETE_IO_HANDLE tls_io,
{
/* Codes_SRS_TLSIO_30_032: [ If the on_bytes_received parameter is NULL, tlsio_open shall log an error and return FAILURE. ]*/
LogError("Required parameter on_bytes_received is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -323,7 +323,7 @@ static int tlsio_appleios_open_async(CONCRETE_IO_HANDLE tls_io,
{
/* Codes_SRS_TLSIO_30_033: [ If the on_io_error parameter is NULL, tlsio_open shall log an error and return FAILURE. ]*/
LogError("Required parameter on_io_error is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -333,7 +333,7 @@ static int tlsio_appleios_open_async(CONCRETE_IO_HANDLE tls_io,
{
/* Codes_SRS_TLSIO_30_037: [ If the adapter is in any state other than TLSIO_STATE_EXT_CLOSED when tlsio_open is called, it shall log an error, and return FAILURE. ]*/
LogError("Invalid tlsio_state. Expected state is TLSIO_STATE_CLOSED.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -371,7 +371,7 @@ static int tlsio_appleios_close_async(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COM
{
/* Codes_SRS_TLSIO_30_050: [ If the tlsio_handle parameter is NULL, tlsio_appleios_close_async shall log an error and return FAILURE. ]*/
LogError("NULL tlsio");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -379,7 +379,7 @@ static int tlsio_appleios_close_async(CONCRETE_IO_HANDLE tls_io, ON_IO_CLOSE_COM
{
/* Codes_SRS_TLSIO_30_055: [ If the on_io_close_complete parameter is NULL, tlsio_appleios_close_async shall log an error and return FAILURE. ]*/
LogError("NULL on_io_close_complete");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -620,7 +620,7 @@ static int tlsio_appleios_setoption(CONCRETE_IO_HANDLE tls_io, const char* optio
if (tls_io_instance == NULL)
{
LogError("NULL tlsio");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -631,7 +631,7 @@ static int tlsio_appleios_setoption(CONCRETE_IO_HANDLE tls_io, const char* optio
if (options_result != TLSIO_OPTIONS_RESULT_SUCCESS)
{
LogError("Failed tlsio_options_set");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -647,7 +647,7 @@ static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buff
if (on_send_complete == NULL || tls_io == NULL || buffer == NULL || size == 0 || on_send_complete == NULL)
{
/* Codes_SRS_TLSIO_30_062: [ If the on_send_complete is NULL, tlsio_appleios_compact_send shall log the error and return FAILURE. ]*/
result = __FAILURE__;
result = MU_FAILURE;
LogError("Invalid parameter specified: tls_io: %p, buffer: %p, size: %lu, on_send_complete: %p", tls_io, buffer, (unsigned long)size, on_send_complete);
}
else
@ -657,7 +657,7 @@ static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buff
{
/* Codes_SRS_TLSIO_30_060: [ If the tlsio_handle parameter is NULL, tlsio_appleios_compact_send shall log an error and return FAILURE. ]*/
/* Codes_SRS_TLSIO_30_065: [ If tlsio_appleios_compact_open has not been called or the opening process has not been completed, tlsio_appleios_compact_send shall log an error and return FAILURE. ]*/
result = __FAILURE__;
result = MU_FAILURE;
LogError("tlsio_appleios_send_async without a prior successful open");
}
else
@ -666,7 +666,7 @@ static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buff
if (pending_transmission == NULL)
{
/* Codes_SRS_TLSIO_30_064: [ If the supplied message cannot be enqueued for transmission, tlsio_appleios_compact_send shall log an error and return FAILURE. ]*/
result = __FAILURE__;
result = MU_FAILURE;
LogError("malloc failed");
}
else
@ -691,7 +691,7 @@ static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buff
/* Codes_SRS_TLSIO_30_064: [ If the supplied message cannot be enqueued for transmission, tlsio_appleios_compact_send shall log an error and return FAILURE. ]*/
LogError("malloc failed");
free(pending_transmission);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -717,7 +717,7 @@ static int tlsio_appleios_send_async(CONCRETE_IO_HANDLE tls_io, const void* buff
LogError("Unable to add socket to pending list.");
free(pending_transmission->bytes);
free(pending_transmission);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -164,7 +164,7 @@ int socket_async_is_create_complete(SOCKET_ASYNC_HANDLE sock, bool* is_complete)
{
/* Codes_SRS_SOCKET_ASYNC_30_026: [ If the is_complete parameter is NULL, socket_async_is_create_complete shall log an error and return FAILURE. ]*/
LogError("is_complete is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -186,7 +186,7 @@ int socket_async_is_create_complete(SOCKET_ASYNC_HANDLE sock, bool* is_complete)
{
/* Codes_SRS_SOCKET_ASYNC_30_028: [ On failure, the is_complete value shall be set to false and socket_async_create shall return FAILURE. ]*/
LogError("Socket select failed: %d", get_socket_errno(sock));
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -194,7 +194,7 @@ int socket_async_is_create_complete(SOCKET_ASYNC_HANDLE sock, bool* is_complete)
{
/* Codes_SRS_SOCKET_ASYNC_30_028: [ On failure, the is_complete value shall be set to false and socket_async_create shall return FAILURE. ]*/
LogError("Socket select errset non-empty: %d", get_socket_errno(sock));
result = __FAILURE__;
result = MU_FAILURE;
}
else if (FD_ISSET(sock, &writeset))
{
@ -222,7 +222,7 @@ int socket_async_send(SOCKET_ASYNC_HANDLE sock, const void* buffer, size_t size,
{
/* Codes_SRS_SOCKET_ASYNC_30_033: [ If the buffer parameter is NULL, socket_async_send shall log the error return FAILURE. ]*/
LogError("buffer is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -230,7 +230,7 @@ int socket_async_send(SOCKET_ASYNC_HANDLE sock, const void* buffer, size_t size,
{
/* Codes_SRS_SOCKET_ASYNC_30_034: [ If the sent_count parameter is NULL, socket_async_send shall log the error return FAILURE. ]*/
LogError("sent_count is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
if (size == 0)
@ -258,7 +258,7 @@ int socket_async_send(SOCKET_ASYNC_HANDLE sock, const void* buffer, size_t size,
/* Codes_SRS_SOCKET_ASYNC_30_037: [ If socket_async_send fails unexpectedly, socket_async_send shall log the error return FAILURE. ]*/
// Something bad happened
LogError("Unexpected send error: %d", sock_err);
result = __FAILURE__;
result = MU_FAILURE;
}
}
else
@ -280,7 +280,7 @@ int socket_async_receive(SOCKET_ASYNC_HANDLE sock, void* buffer, size_t size, si
{
/* Codes_SRS_SOCKET_ASYNC_30_052: [ If the buffer parameter is NULL, socket_async_receive shall log the error and return FAILURE. ]*/
LogError("buffer is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -288,14 +288,14 @@ int socket_async_receive(SOCKET_ASYNC_HANDLE sock, void* buffer, size_t size, si
{
/* Codes_SRS_SOCKET_ASYNC_30_053: [ If the received_count parameter is NULL, socket_async_receive shall log the error and return FAILURE. ]*/
LogError("received_count is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
if (size == 0)
{
/* Codes_SRS_SOCKET_ASYNC_30_072: [ If the size parameter is 0, socket_async_receive shall log an error and return FAILURE. ]*/
LogError("size is 0");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -315,7 +315,7 @@ int socket_async_receive(SOCKET_ASYNC_HANDLE sock, void* buffer, size_t size, si
/* Codes_SRS_SOCKET_ASYNC_30_056: [ If the underlying socket fails unexpectedly, socket_async_receive shall log the error and return FAILURE. ]*/
// Something bad happened
LogError("Unexpected recv error: %d", sock_err);
result = __FAILURE__;
result = MU_FAILURE;
}
}
else

Просмотреть файл

@ -52,14 +52,14 @@ int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, tickcounter_ms_
if (tick_counter == NULL || current_ms == NULL)
{
LogError("tickcounter failed: Invalid Arguments.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
time_t time_value = time(NULL);
if (time_value == INVALID_TIME_VALUE)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -32,7 +32,7 @@ static int set_and_validate_x509_type(TLSIO_OPTIONS* options, TLSIO_OPTIONS_x509
{
// This case also rejects the nonsensical TLSIO_OPTIONS_x509_TYPE_UNSPECIFIED
LogError("Unsupported x509 type: %d", x509_type);
result = __FAILURE__;
result = MU_FAILURE;
}
else if (options->x509_type == TLSIO_OPTIONS_x509_TYPE_UNSPECIFIED)
{
@ -43,7 +43,7 @@ static int set_and_validate_x509_type(TLSIO_OPTIONS* options, TLSIO_OPTIONS_x509
else if (options->x509_type != x509_type)
{
LogError("Supplied x509 type conflicts with previously set x509");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -58,7 +58,7 @@ int main(int argc, char** argv)
if (platform_init() != 0)
{
(void)printf("Cannot initialize platform.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -66,7 +66,7 @@ int main(int argc, char** argv)
if (socketio_interface == NULL)
{
(void)printf("Error getting socketio interface description.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -79,14 +79,14 @@ int main(int argc, char** argv)
if (socketio == NULL)
{
(void)printf("Error creating socket IO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (xio_open(socketio, on_io_open_complete, socketio, on_io_bytes_received, socketio, on_io_error, socketio) != 0)
{
(void)printf("Error opening socket IO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -58,7 +58,7 @@ int main(int argc, char** argv)
if (platform_init() != 0)
{
(void)printf("Cannot initialize platform.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -66,7 +66,7 @@ int main(int argc, char** argv)
if (tlsio_interface == NULL)
{
(void)printf("Error getting tlsio interface description.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -77,14 +77,14 @@ int main(int argc, char** argv)
if (tlsio == NULL)
{
(void)printf("Error creating TLS IO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (xio_open(tlsio, on_io_open_complete, tlsio, on_io_bytes_received, tlsio, on_io_error, tlsio) != 0)
{
(void)printf("Error opening TLS IO.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -17,9 +17,9 @@ EXPORTS
BUFFER_u_char
BUFFER_unbuild
Base64_Decode
Base64_Encode
Base64_Encode_Bytes
Azure_Base64_Decode
Azure_Base64_Encode
Azure_Base64_Encode_Bytes
Base32_Decode
Base32_Decode_String
Base32_Encode

Просмотреть файл

@ -5,7 +5,7 @@
#include "azure_c_shared_utility/gballoc.h"
#include <stddef.h>
#include <stdint.h>
#include "azure_c_shared_utility/base64.h"
#include "azure_c_shared_utility/azure_base64.h"
#include "azure_c_shared_utility/xlogging.h"
@ -184,10 +184,10 @@ static void Base64decode(unsigned char *decodedString, const char *base64String)
}
}
BUFFER_HANDLE Base64_Decode(const char* source)
BUFFER_HANDLE Azure_Base64_Decode(const char* source)
{
BUFFER_HANDLE result;
/*Codes_SRS_BASE64_06_008: [If source is NULL then Base64_Decode shall return NULL.]*/
/*Codes_SRS_BASE64_06_008: [If source is NULL then Azure_Base64_Decode shall return NULL.]*/
if (source == NULL)
{
LogError("invalid parameter const char* source=%p", source);
@ -197,7 +197,7 @@ BUFFER_HANDLE Base64_Decode(const char* source)
{
if ((strlen(source) % 4) != 0)
{
/*Codes_SRS_BASE64_06_011: [If the source string has an invalid length for a base 64 encoded string then Base64_Decode shall return NULL.]*/
/*Codes_SRS_BASE64_06_011: [If the source string has an invalid length for a base 64 encoded string then Azure_Base64_Decode shall return NULL.]*/
LogError("Invalid length Base64 string!");
result = NULL;
}
@ -205,7 +205,7 @@ BUFFER_HANDLE Base64_Decode(const char* source)
{
if ((result = BUFFER_new()) == NULL)
{
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Base64_Decode shall return NULL.]*/
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Azure_Base64_Decode shall return NULL.]*/
LogError("Could not create a buffer to decoding.");
}
else
@ -216,7 +216,7 @@ BUFFER_HANDLE Base64_Decode(const char* source)
{
if (BUFFER_pre_build(result, sizeOfOutputBuffer) != 0)
{
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Base64_Decode shall return NULL.]*/
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Azure_Base64_Decode shall return NULL.]*/
LogError("Could not prebuild a buffer for base 64 decoding.");
BUFFER_delete(result);
result = NULL;
@ -313,7 +313,7 @@ static STRING_HANDLE Base64_Encode_Internal(const unsigned char* source, size_t
return result;
}
STRING_HANDLE Base64_Encode_Bytes(const unsigned char* source, size_t size)
STRING_HANDLE Azure_Base64_Encode_Bytes(const unsigned char* source, size_t size)
{
STRING_HANDLE result;
/*Codes_SRS_BASE64_02_001: [If source is NULL then Base64_Encode_Bytes shall return NULL.] */
@ -333,7 +333,7 @@ STRING_HANDLE Base64_Encode_Bytes(const unsigned char* source, size_t size)
return result;
}
STRING_HANDLE Base64_Encode(BUFFER_HANDLE input)
STRING_HANDLE Azure_Base64_Encode(BUFFER_HANDLE input)
{
STRING_HANDLE result;
/*the following will happen*/

Просмотреть файл

@ -42,7 +42,7 @@ static int BUFFER_safemalloc(BUFFER* handleptr, size_t size)
{
/*Codes_SRS_BUFFER_02_003: [If allocating memory fails, then BUFFER_create shall return NULL.]*/
LogError("Failure allocating data");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -151,7 +151,7 @@ int BUFFER_build(BUFFER_HANDLE handle, const unsigned char* source, size_t size)
if (handle == NULL)
{
/* Codes_SRS_BUFFER_07_009: [BUFFER_build shall return nonzero if handle is NULL ] */
result = __FAILURE__;
result = MU_FAILURE;
}
/* Codes_SRS_BUFFER_01_002: [The size argument can be zero, in which case the underlying buffer held by the buffer instance shall be freed.] */
else if (size == 0)
@ -169,7 +169,7 @@ int BUFFER_build(BUFFER_HANDLE handle, const unsigned char* source, size_t size)
if (source == NULL)
{
/* Codes_SRS_BUFFER_01_001: [If size is positive and source is NULL, BUFFER_build shall return nonzero] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -180,7 +180,7 @@ int BUFFER_build(BUFFER_HANDLE handle, const unsigned char* source, size_t size)
{
/* Codes_SRS_BUFFER_07_010: [BUFFER_build shall return nonzero if any error is encountered.] */
LogError("Failure reallocating buffer");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -204,7 +204,7 @@ int BUFFER_append_build(BUFFER_HANDLE handle, const unsigned char* source, size_
{
/* Codes_SRS_BUFFER_07_029: [ BUFFER_append_build shall return nonzero if handle or source are NULL or if size is 0. ] */
LogError("BUFFER_append_build failed invalid parameter handle: %p, source: %p, size: %lu", handle, source, (unsigned long)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -215,7 +215,7 @@ int BUFFER_append_build(BUFFER_HANDLE handle, const unsigned char* source, size_
{
/* Codes_SRS_BUFFER_07_035: [ If any error is encountered BUFFER_append_build shall return a non-null value. ] */
LogError("Failure with BUFFER_safemalloc");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -233,7 +233,7 @@ int BUFFER_append_build(BUFFER_HANDLE handle, const unsigned char* source, size_
{
/* Codes_SRS_BUFFER_07_035: [ If any error is encountered BUFFER_append_build shall return a non-null value. ] */
LogError("Failure reallocating temporary buffer");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -259,12 +259,12 @@ int BUFFER_pre_build(BUFFER_HANDLE handle, size_t size)
if (handle == NULL)
{
/* Codes_SRS_BUFFER_07_006: [If handle is NULL or size is 0 then BUFFER_pre_build shall return a nonzero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else if (size == 0)
{
/* Codes_SRS_BUFFER_07_006: [If handle is NULL or size is 0 then BUFFER_pre_build shall return a nonzero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -273,7 +273,7 @@ int BUFFER_pre_build(BUFFER_HANDLE handle, size_t size)
{
/* Codes_SRS_BUFFER_07_007: [BUFFER_pre_build shall return nonzero if the buffer has been previously allocated and is not NULL.] */
LogError("Failure buffer data is NULL");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -281,7 +281,7 @@ int BUFFER_pre_build(BUFFER_HANDLE handle, size_t size)
{
/* Codes_SRS_BUFFER_07_013: [BUFFER_pre_build shall return nonzero if any error is encountered.] */
LogError("Failure allocating buffer");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -300,7 +300,7 @@ int BUFFER_content(BUFFER_HANDLE handle, const unsigned char** content)
if ((handle == NULL) || (content == NULL))
{
/* Codes_SRS_BUFFER_07_020: [If the handle and/or content*is NULL BUFFER_content shall return nonzero.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -319,7 +319,7 @@ extern int BUFFER_unbuild(BUFFER_HANDLE handle)
if (handle == NULL)
{
/* Codes_SRS_BUFFER_07_014: [BUFFER_unbuild shall return a nonzero value if BUFFER_HANDLE is NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -335,7 +335,7 @@ extern int BUFFER_unbuild(BUFFER_HANDLE handle)
else
{
/* Codes_SRS_BUFFER_07_015: [BUFFER_unbuild shall return a nonzero value if the unsigned char* referenced by BUFFER_HANDLE is NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
}
return result;
@ -349,13 +349,13 @@ int BUFFER_enlarge(BUFFER_HANDLE handle, size_t enlargeSize)
{
/* Codes_SRS_BUFFER_07_017: [BUFFER_enlarge shall return a nonzero result if any parameters are NULL or zero.] */
LogError("Failure: handle is invalid.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (enlargeSize == 0)
{
/* Codes_SRS_BUFFER_07_017: [BUFFER_enlarge shall return a nonzero result if any parameters are NULL or zero.] */
LogError("Failure: enlargeSize size is 0.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -365,7 +365,7 @@ int BUFFER_enlarge(BUFFER_HANDLE handle, size_t enlargeSize)
{
/* Codes_SRS_BUFFER_07_018: [BUFFER_enlarge shall return a nonzero result if any error is encountered.] */
LogError("Failure: allocating temp buffer.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -384,19 +384,19 @@ int BUFFER_shrink(BUFFER_HANDLE handle, size_t decreaseSize, bool fromEnd)
{
/* Codes_SRS_BUFFER_07_036: [ if handle is NULL, BUFFER_shrink shall return a non-null value ]*/
LogError("Failure: handle is invalid.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (decreaseSize == 0)
{
/* Codes_SRS_BUFFER_07_037: [ If decreaseSize is equal zero, BUFFER_shrink shall return a non-null value ] */
LogError("Failure: decrease size is 0.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (decreaseSize > handle->size)
{
/* Codes_SRS_BUFFER_07_038: [ If decreaseSize is less than the size of the buffer, BUFFER_shrink shall return a non-null value ] */
LogError("Failure: decrease size is less than buffer size.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -417,7 +417,7 @@ int BUFFER_shrink(BUFFER_HANDLE handle, size_t decreaseSize, bool fromEnd)
{
/* Codes_SRS_BUFFER_07_042: [ If a failure is encountered, BUFFER_shrink shall return a non-null value ] */
LogError("Failure: allocating temp buffer.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -452,7 +452,7 @@ int BUFFER_size(BUFFER_HANDLE handle, size_t* size)
if ((handle == NULL) || (size == NULL))
{
/* Codes_SRS_BUFFER_07_022: [BUFFER_size shall return a nonzero value for any error that is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -470,7 +470,7 @@ int BUFFER_append(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
if ( (handle1 == NULL) || (handle2 == NULL) || (handle1 == handle2) )
{
/* Codes_SRS_BUFFER_07_023: [BUFFER_append shall return a nonzero upon any error that is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -479,12 +479,12 @@ int BUFFER_append(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
if (b1->buffer == NULL)
{
/* Codes_SRS_BUFFER_07_023: [BUFFER_append shall return a nonzero upon any error that is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else if (b2->buffer == NULL)
{
/* Codes_SRS_BUFFER_07_023: [BUFFER_append shall return a nonzero upon any error that is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -501,7 +501,7 @@ int BUFFER_append(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
{
/* Codes_SRS_BUFFER_07_023: [BUFFER_append shall return a nonzero upon any error that is encountered.] */
LogError("Failure: allocating temp buffer.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -524,7 +524,7 @@ int BUFFER_prepend(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
if ((handle1 == NULL) || (handle2 == NULL) || (handle1 == handle2))
{
/* Codes_SRS_BUFFER_01_005: [ BUFFER_prepend shall return a non-zero upon value any error that is encountered. ]*/
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -533,12 +533,12 @@ int BUFFER_prepend(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
if (b1->buffer == NULL)
{
/* Codes_SRS_BUFFER_01_005: [ BUFFER_prepend shall return a non-zero upon value any error that is encountered. ]*/
result = __FAILURE__;
result = MU_FAILURE;
}
else if (b2->buffer == NULL)
{
/* Codes_SRS_BUFFER_01_005: [ BUFFER_prepend shall return a non-zero upon value any error that is encountered. ]*/
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -556,7 +556,7 @@ int BUFFER_prepend(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2)
{
/* Codes_SRS_BUFFER_01_005: [ BUFFER_prepend shall return a non-zero upon value any error that is encountered. ]*/
LogError("Failure: allocating temp buffer.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -583,7 +583,7 @@ int BUFFER_fill(BUFFER_HANDLE handle, unsigned char fill_char)
{
/* Codes_SRS_BUFFER_07_002: [ If handle is NULL BUFFER_fill shall return a non-zero value. ] */
LogError("Invalid parameter specified, handle == NULL.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -163,12 +163,12 @@ int connectionstringparser_splitHostName_from_char(const char* hostName, STRING_
if ((hostName == NULL) || ((*hostName) == '\0') || ((*hostName) == '.') || (nameString == NULL) || (suffixString == NULL))
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_026: [If the hostName is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_027: [If the hostName is an empty string, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_028: [If the nameString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_029: [If the suffixString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
result = __FAILURE__;
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_026: [If the hostName is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_027: [If the hostName is an empty string, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_028: [If the nameString is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_029: [If the suffixString is NULL, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
result = MU_FAILURE;
}
else
{
@ -186,22 +186,22 @@ int connectionstringparser_splitHostName_from_char(const char* hostName, STRING_
if ((*runHostName) == '\0')
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/
result = __FAILURE__;
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return MU_FAILURE.]*/
result = MU_FAILURE;
}
else
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_023: [connectionstringparser_splitHostName_from_char shall copy all characters, from the beginning of the hostName to the first . to the nameString.]*/
if (STRING_copy_n(nameString, hostName, runHostName - hostName - 1) != 0)
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_031: [If connectionstringparser_splitHostName_from_char get error copying the name to the nameString, it shall return __FAILURE__.]*/
result = __FAILURE__;
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_031: [If connectionstringparser_splitHostName_from_char get error copying the name to the nameString, it shall return MU_FAILURE.]*/
result = MU_FAILURE;
}
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_024: [connectionstringparser_splitHostName_from_char shall copy all characters, from the first . to the end of the hostName, to the suffixString.]*/
else if (STRING_copy(suffixString, runHostName) != 0)
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_032: [If connectionstringparser_splitHostName_from_char get error copying the suffix to the suffixString, it shall return __FAILURE__.]*/
result = __FAILURE__;
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_032: [If connectionstringparser_splitHostName_from_char get error copying the suffix to the suffixString, it shall return MU_FAILURE.]*/
result = MU_FAILURE;
}
else
{
@ -221,8 +221,8 @@ int connectionstringparser_splitHostName(STRING_HANDLE hostNameString, STRING_HA
if (hostNameString == NULL)
{
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_034: [If the hostNameString is NULL, connectionstringparser_splitHostName shall return __FAILURE__.]*/
result = __FAILURE__;
/* Codes_SRS_CONNECTIONSTRINGPARSER_21_034: [If the hostNameString is NULL, connectionstringparser_splitHostName shall return MU_FAILURE.]*/
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -14,7 +14,7 @@
CONSTBUFFER_TYPE_MEMORY_MOVED, \
CONSTBUFFER_TYPE_WITH_CUSTOM_FREE
DEFINE_ENUM(CONSTBUFFER_TYPE, CONSTBUFFER_TYPE_VALUES)
MU_DEFINE_ENUM(CONSTBUFFER_TYPE, CONSTBUFFER_TYPE_VALUES)
typedef struct CONSTBUFFER_HANDLE_DATA_TAG
{

Просмотреть файл

@ -301,7 +301,7 @@ int constbuffer_array_get_buffer_count(CONSTBUFFER_ARRAY_HANDLE constbuffer_arra
{
LogError("Invalid arguments: CONSTBUFFER_ARRAY_HANDLE constbuffer_array_handle=%p, uint32_t* buffer_count=%p",
constbuffer_array_handle, buffer_count);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -419,7 +419,7 @@ int constbuffer_array_get_all_buffers_size(CONSTBUFFER_ARRAY_HANDLE constbuffer_
{
LogError("CONSTBUFFER_ARRAY_HANDLE constbuffer_array_handle=%p, uint32_t* all_buffers_size=%p",
constbuffer_array_handle, all_buffers_size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -447,7 +447,7 @@ int constbuffer_array_get_all_buffers_size(CONSTBUFFER_ARRAY_HANDLE constbuffer_
{
/* Codes_SRS_CONSTBUFFER_ARRAY_01_021: [ If summing up the sizes results in an uint32_t overflow, shall fail and return a non-zero value. ]*/
LogError("Overflow in computing all buffers size");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -464,7 +464,7 @@ const CONSTBUFFER_HANDLE* constbuffer_array_get_const_buffer_handle_array(CONSTB
{
const CONSTBUFFER_HANDLE* result;
/* Codes_SRS_CONSTBUFFER_ARRAY_01_026: [ If `constbuffer_array_handle` is NULL, `constbuffer_array_get_const_buffer_handle_array` shall fail and return NULL. ]*/
/* Codes_SRS_CONSTBUFFER_ARRAY_01_026: [ If constbuffer_array_handle is NULL, constbuffer_array_get_const_buffer_handle_array shall fail and return NULL. ]*/
if (constbuffer_array_handle == NULL)
{
LogError("CONSTBUFFER_ARRAY_HANDLE constbuffer_array_handle=%p", constbuffer_array_handle);
@ -472,7 +472,7 @@ const CONSTBUFFER_HANDLE* constbuffer_array_get_const_buffer_handle_array(CONSTB
}
else
{
/* Codes_SRS_CONSTBUFFER_ARRAY_01_027: [ Otherwise `constbuffer_array_get_const_buffer_handle_array` shall return the array of const buffer handles backing the const buffer array. ]*/
/* Codes_SRS_CONSTBUFFER_ARRAY_01_027: [ Otherwise constbuffer_array_get_const_buffer_handle_array shall return the array of const buffer handles backing the const buffer array. ]*/
result = constbuffer_array_handle->buffers;
}

Просмотреть файл

@ -10,7 +10,7 @@
#include "azure_c_shared_utility/xlogging.h"
#include "azure_c_shared_utility/refcount.h"
DEFINE_ENUM_STRINGS(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
typedef struct CONSTMAP_HANDLE_DATA_TAG
{
@ -19,7 +19,7 @@ typedef struct CONSTMAP_HANDLE_DATA_TAG
DEFINE_REFCOUNT_TYPE(CONSTMAP_HANDLE_DATA);
#define LOG_CONSTMAP_ERROR(result) LogError("result = %s", ENUM_TO_STRING(CONSTMAP_RESULT, (result)));
#define LOG_CONSTMAP_ERROR(result) LogError("result = %s", MU_ENUM_TO_STRING(CONSTMAP_RESULT, (result)));
CONSTMAP_HANDLE ConstMap_Create(MAP_HANDLE sourceMap)
{

Просмотреть файл

@ -471,7 +471,7 @@ static bool isNaN(const char** endptr)
FST_OVERFLOW, \
FST_ERROR
DEFINE_ENUM(FLOAT_STRING_TYPE, FLOAT_STRING_TYPE_VALUES);
MU_DEFINE_ENUM(FLOAT_STRING_TYPE, FLOAT_STRING_TYPE_VALUES);
static FLOAT_STRING_TYPE splitFloatString(const char* nptr, char** endptr, int *signal, double *fraction, int *exponential)
{
@ -751,7 +751,7 @@ int unsignedIntToString(char* destination, size_t destinationSize, unsigned int
(destinationSize < 2) /*because the smallest number is '0\0' which requires 2 characters*/
)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -780,7 +780,7 @@ int unsignedIntToString(char* destination, size_t destinationSize, unsigned int
else
{
/*Codes_SRS_CRT_ABSTRACTIONS_02_002: [If the conversion fails for any reason (for example, insufficient buffer space), a non-zero return value shall be supplied and unsignedIntToString shall fail.] */
result = __FAILURE__;
result = MU_FAILURE;
}
}
return result;
@ -802,7 +802,7 @@ int size_tToString(char* destination, size_t destinationSize, size_t value)
(destinationSize < 2) /*because the smallest number is '0\0' which requires 2 characters*/
)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -831,7 +831,7 @@ int size_tToString(char* destination, size_t destinationSize, size_t value)
else
{
/*Codes_SRS_CRT_ABSTRACTIONS_02_002: [If the conversion fails for any reason (for example, insufficient buffer space), a non-zero return value shall be supplied and unsignedIntToString shall fail.] */
result = __FAILURE__;
result = MU_FAILURE;
}
}
return result;

Просмотреть файл

@ -43,13 +43,13 @@ int gballoc_init(void)
if (gballocState != GBALLOC_STATE_NOT_INIT)
{
/* Codes_SRS_GBALLOC_01_025: [Init after Init shall fail and return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
/* Codes_SRS_GBALLOC_01_026: [gballoc_Init shall create a lock handle that will be used to make the other gballoc APIs thread-safe.] */
else if ((gballocThreadSafeLock = Lock_Init()) == NULL)
{
/* Codes_SRS_GBALLOC_01_027: [If the Lock creation fails, gballoc_init shall return a non-zero value.]*/
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -39,11 +39,11 @@ int gbnetwork_init(void)
if (gbnetworkState != GBNETWORK_STATE_NOT_INIT)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if ((gbnetworkThreadSafeLock = Lock_Init()) == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -12,7 +12,7 @@
#include "azure_c_shared_utility/socketio.h"
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/http_proxy_io.h"
#include "azure_c_shared_utility/base64.h"
#include "azure_c_shared_utility/azure_base64.h"
typedef enum HTTP_PROXY_IO_STATE_TAG
{
@ -335,7 +335,7 @@ static void on_underlying_io_open_complete(void* context, IO_OPEN_RESULT open_re
else
{
/* Codes_SRS_HTTP_PROXY_IO_01_061: [ Encoding to Base64 shall be done by calling Base64_Encode_Bytes. ]*/
encoded_auth_string = Base64_Encode_Bytes((const unsigned char*)plain_auth_string_bytes, plain_auth_string_length);
encoded_auth_string = Azure_Base64_Encode_Bytes((const unsigned char*)plain_auth_string_bytes, plain_auth_string_length);
if (encoded_auth_string == NULL)
{
/* Codes_SRS_HTTP_PROXY_IO_01_062: [ If any failure is encountered while constructing the request, the on_open_complete callback shall be triggered with IO_OPEN_ERROR, passing also the on_open_complete_context argument as context. ]*/

Просмотреть файл

@ -37,7 +37,7 @@ static int http_proxy_stub_open(CONCRETE_IO_HANDLE http_proxy_io, ON_IO_OPEN_COM
(void)on_io_error_context;
LogError("Function %s is a stub and should never be called", __FUNCTION__);
result = __FAILURE__;
result = MU_FAILURE;
return result;
}
@ -51,7 +51,7 @@ static int http_proxy_stub_close(CONCRETE_IO_HANDLE http_proxy_io, ON_IO_CLOSE_C
(void)on_io_close_complete_context;
LogError("Function %s is a stub and should never be called", __FUNCTION__);
result = __FAILURE__;
result = MU_FAILURE;
return result;
}
@ -67,7 +67,7 @@ static int http_proxy_stub_send(CONCRETE_IO_HANDLE http_proxy_io, const void* bu
(void)on_send_complete_context;
LogError("Function %s is a stub and should never be called", __FUNCTION__);
result = __FAILURE__;
result = MU_FAILURE;
return result;
}
@ -88,7 +88,7 @@ static int http_proxy_stub_set_option(CONCRETE_IO_HANDLE http_proxy_io, const ch
(void)value;
LogError("Function %s is a stub and should never be called", __FUNCTION__);
result = __FAILURE__;
result = MU_FAILURE;
return result;
}

Просмотреть файл

@ -24,9 +24,9 @@ typedef struct HTTPAPIEX_HANDLE_DATA_TAG
VECTOR_HANDLE savedOptions;
}HTTPAPIEX_HANDLE_DATA;
DEFINE_ENUM_STRINGS(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
#define LOG_HTTAPIEX_ERROR() LogError("error code = %s", ENUM_TO_STRING(HTTPAPIEX_RESULT, result))
#define LOG_HTTAPIEX_ERROR() LogError("error code = %s", MU_ENUM_TO_STRING(HTTPAPIEX_RESULT, result))
HTTPAPIEX_HANDLE HTTPAPIEX_Create(const char* hostName)
{
@ -104,7 +104,7 @@ static int buildRequestHttpHeadersHandle(HTTPAPIEX_HANDLE_DATA *handleData, BUFF
if (*toBeUsedRequestHttpHeadersHandle == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
LogError("unable to HTTPHeaders_Alloc");
}
else
@ -129,7 +129,7 @@ static int buildRequestHttpHeadersHandle(HTTPAPIEX_HANDLE_DATA *handleData, BUFF
HTTPHeaders_Free(*toBeUsedRequestHttpHeadersHandle);
}
*toBeUsedRequestHttpHeadersHandle = NULL;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -146,7 +146,7 @@ static int buildResponseHttpHeadersHandle(HTTP_HEADERS_HANDLE originalResponsetH
{
if ((*toBeUsedResponsetHttpHeadersHandle = HTTPHeaders_Alloc()) == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -172,7 +172,7 @@ static int buildBufferIfNotExist(BUFFER_HANDLE originalRequestContent, bool* isO
*toBeUsedRequestContent = BUFFER_new();
if (*toBeUsedRequestContent == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -209,7 +209,7 @@ static int buildAllRequests(HTTPAPIEX_HANDLE_DATA* handle, HTTPAPI_REQUEST_TYPE
if (buildBufferIfNotExist(requestContent, isOriginalRequestContent, toBeUsedRequestContent) != 0)
{
LogError("unable to build the request content");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -221,7 +221,7 @@ static int buildAllRequests(HTTPAPIEX_HANDLE_DATA* handle, HTTPAPI_REQUEST_TYPE
BUFFER_delete(*toBeUsedRequestContent);
}
LogError("unable to build the request http headers handle");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -260,7 +260,7 @@ static int buildAllRequests(HTTPAPIEX_HANDLE_DATA* handle, HTTPAPI_REQUEST_TYPE
HTTPHeaders_Free(*toBeUsedRequestHttpHeadersHandle);
}
LogError("unable to build response content");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -282,7 +282,7 @@ static int buildAllRequests(HTTPAPIEX_HANDLE_DATA* handle, HTTPAPI_REQUEST_TYPE
HTTPHeaders_Free(*toBeUsedResponseHttpHeadersHandle);
}
LogError("unable to build response content");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -308,7 +308,7 @@ HTTPAPIEX_RESULT HTTPAPIEX_ExecuteRequest(HTTPAPIEX_HANDLE handle, HTTPAPI_REQUE
else
{
/*Codes_SRS_HTTPAPIEX_02_007: [If parameter requestType does not indicate a valid request, HTTPAPIEX_ExecuteRequest shall fail and return HTTPAPIEX_INVALID_ARG.] */
if (requestType >= COUNT_ARG(HTTPAPI_REQUEST_TYPE_VALUES))
if (requestType >= MU_COUNT_ARG(HTTPAPI_REQUEST_TYPE_VALUES))
{
result = HTTPAPIEX_INVALID_ARG;
LOG_HTTAPIEX_ERROR();
@ -557,7 +557,7 @@ static int createOrUpdateOption(HTTPAPIEX_HANDLE_DATA* handleData, const char* o
if (mallocAndStrcpy_s((char**)&(newOption.optionName), optionName) != 0)
{
free((void*)value);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -567,7 +567,7 @@ static int createOrUpdateOption(HTTPAPIEX_HANDLE_DATA* handleData, const char* o
LogError("unable to VECTOR_push_back");
free((void*)newOption.optionName);
free((void*)value);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -9,7 +9,7 @@
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/xlogging.h"
DEFINE_ENUM_STRINGS(HTTP_HEADERS_RESULT, HTTP_HEADERS_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(HTTP_HEADERS_RESULT, HTTP_HEADERS_RESULT_VALUES);
typedef struct HTTP_HEADERS_HANDLE_DATA_TAG
{
@ -76,7 +76,7 @@ static HTTP_HEADERS_RESULT headers_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDL
)
{
result = HTTP_HEADERS_INVALID_ARG;
LogError("invalid arg (NULL) , result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("invalid arg (NULL) , result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -95,7 +95,7 @@ static HTTP_HEADERS_RESULT headers_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDL
if (i < nameLen)
{
result = HTTP_HEADERS_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -117,7 +117,7 @@ static HTTP_HEADERS_RESULT headers_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDL
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ALLOC_FAILED;
LogError("failed to malloc , result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("failed to malloc , result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -134,7 +134,7 @@ static HTTP_HEADERS_RESULT headers_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDL
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ERROR;
LogError("failed to Map_AddOrUpdate, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("failed to Map_AddOrUpdate, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -151,7 +151,7 @@ static HTTP_HEADERS_RESULT headers_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDL
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ALLOC_FAILED;
LogError("failed to Map_AddOrUpdate, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("failed to Map_AddOrUpdate, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -208,7 +208,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeaderCount(HTTP_HEADERS_HANDLE handle, size_
(headerCount == NULL))
{
result = HTTP_HEADERS_INVALID_ARG;
LogError("(result = %s)", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("(result = %s)", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -220,7 +220,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeaderCount(HTTP_HEADERS_HANDLE handle, size_
{
/*Codes_SRS_HTTP_HEADERS_99_037:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs.]*/
result = HTTP_HEADERS_ERROR;
LogError("Map_GetInternals failed, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("Map_GetInternals failed, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -245,7 +245,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeader(HTTP_HEADERS_HANDLE handle, size_t ind
)
{
result = HTTP_HEADERS_INVALID_ARG;
LogError("invalid arg (NULL), result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("invalid arg (NULL), result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
/*Codes_SRS_HTTP_HEADERS_99_029:[ The function shall return HTTP_HEADERS_INVALID_ARG if index is not valid (for example, out of range) for the currently stored headers.]*/
else
@ -258,7 +258,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeader(HTTP_HEADERS_HANDLE handle, size_t ind
{
/*Codes_SRS_HTTP_HEADERS_99_034:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs]*/
result = HTTP_HEADERS_ERROR;
LogError("Map_GetInternals failed, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("Map_GetInternals failed, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -266,7 +266,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeader(HTTP_HEADERS_HANDLE handle, size_t ind
if (index >= headerCount)
{
result = HTTP_HEADERS_INVALID_ARG;
LogError("index out of bounds, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("index out of bounds, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@ -277,7 +277,7 @@ HTTP_HEADERS_RESULT HTTPHeaders_GetHeader(HTTP_HEADERS_HANDLE handle, size_t ind
{
/*Codes_SRS_HTTP_HEADERS_99_034:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs]*/
result = HTTP_HEADERS_ERROR;
LogError("unable to malloc, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
LogError("unable to malloc, result= %s", MU_ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{

Просмотреть файл

@ -8,7 +8,7 @@
#include "azure_c_shared_utility/xlogging.h"
#include "azure_c_shared_utility/strings.h"
DEFINE_ENUM_STRINGS(MAP_RESULT, MAP_RESULT_VALUES);
MU_DEFINE_ENUM_STRINGS(MAP_RESULT, MAP_RESULT_VALUES);
typedef struct MAP_HANDLE_DATA_TAG
{
@ -18,7 +18,7 @@ typedef struct MAP_HANDLE_DATA_TAG
MAP_FILTER_CALLBACK mapFilterCallback;
}MAP_HANDLE_DATA;
#define LOG_MAP_ERROR LogError("result = %s", ENUM_TO_STRING(MAP_RESULT, result));
#define LOG_MAP_ERROR LogError("result = %s", MU_ENUM_TO_STRING(MAP_RESULT, result));
MAP_HANDLE Map_Create(MAP_FILTER_CALLBACK mapFilterFunc)
{
@ -165,7 +165,7 @@ static int Map_IncreaseStorageKeysValues(MAP_HANDLE_DATA* handleData)
if (newKeys == NULL)
{
LogError("realloc error");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -193,7 +193,7 @@ static int Map_IncreaseStorageKeysValues(MAP_HANDLE_DATA* handleData)
handleData->keys = undoneKeys;
}
}
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -296,7 +296,7 @@ static int insertNewKeyValue(MAP_HANDLE_DATA* handleData, const char* key, const
int result;
if (Map_IncreaseStorageKeysValues(handleData) != 0) /*this increases handleData->count*/
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -304,7 +304,7 @@ static int insertNewKeyValue(MAP_HANDLE_DATA* handleData, const char* key, const
{
Map_DecreaseStorageKeysValues(handleData);
LogError("unable to mallocAndStrcpy_s");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -313,7 +313,7 @@ static int insertNewKeyValue(MAP_HANDLE_DATA* handleData, const char* key, const
free(handleData->keys[handleData->count - 1]);
Map_DecreaseStorageKeysValues(handleData);
LogError("unable to mallocAndStrcpy_s");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -8,7 +8,7 @@
#include "azure_c_shared_utility/sastoken.h"
#include "azure_c_shared_utility/urlencode.h"
#include "azure_c_shared_utility/hmacsha256.h"
#include "azure_c_shared_utility/base64.h"
#include "azure_c_shared_utility/azure_base64.h"
#include "azure_c_shared_utility/agenttime.h"
#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/buffer_.h"
@ -211,7 +211,7 @@ static STRING_HANDLE construct_sas_token(const char* key, const char* scope, con
BUFFER_HANDLE decodedKey;
/*Codes_SRS_SASTOKEN_06_029: [The key parameter is decoded from base64.]*/
if ((decodedKey = Base64_Decode(key)) == NULL)
if ((decodedKey = Azure_Base64_Decode(key)) == NULL)
{
/*Codes_SRS_SASTOKEN_06_030: [If there is an error in the decoding then SASToken_Create shall return NULL.]*/
LogError("Unable to decode the key for generating the SAS.");
@ -271,7 +271,7 @@ static STRING_HANDLE construct_sas_token(const char* key, const char* scope, con
/*Codes_SRS_SASTOKEN_06_022: [If keyName is non-NULL, the string "&skn=" is appended to result.]*/
/*Codes_SRS_SASTOKEN_06_023: [If keyName is non-NULL, the argument keyName is appended to result.]*/
if ((HMACSHA256_ComputeHash(outBuf, outLen, inBuf, inLen, hash) != HMACSHA256_OK) ||
((base64Signature = Base64_Encode(hash)) == NULL) ||
((base64Signature = Azure_Base64_Encode(hash)) == NULL) ||
((urlEncodedSignature = URL_Encode(base64Signature)) == NULL) ||
(STRING_copy(result, "SharedAccessSignature sr=") != 0) ||
(STRING_concat(result, scope) != 0) ||

Просмотреть файл

@ -106,7 +106,7 @@ int singlylinkedlist_remove(SINGLYLINKEDLIST_HANDLE list, LIST_ITEM_HANDLE item)
(item == NULL))
{
LogError("Invalid argument (list=%p, item=%p)", list, item);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -144,7 +144,7 @@ int singlylinkedlist_remove(SINGLYLINKEDLIST_HANDLE list, LIST_ITEM_HANDLE item)
if (current_item == NULL)
{
/* Codes_SRS_LIST_01_025: [If the item item_handle is not found in the list, then singlylinkedlist_remove shall fail and return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -269,7 +269,7 @@ int singlylinkedlist_remove_if(SINGLYLINKEDLIST_HANDLE list, LIST_CONDITION_FUNC
(condition_function == NULL))
{
LogError("Invalid argument (list=%p, condition_function=%p)", list, condition_function);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -336,7 +336,7 @@ int singlylinkedlist_foreach(SINGLYLINKEDLIST_HANDLE list, LIST_ACTION_FUNCTION
(action_function == NULL))
{
LogError("Invalid argument (list=%p, action_function=%p)", list, action_function);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -58,7 +58,7 @@ static int get_next_token(STRING_TOKEN* token, const char** delimiters, size_t n
if (token->token_start != NULL && token->delimiter_start == NULL)
{
// The parser reached the end of the input string.
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -67,7 +67,7 @@ static int get_next_token(STRING_TOKEN* token, const char** delimiters, size_t n
if ((delimiters_lengths = get_delimiters_lengths(delimiters, n_delims)) == NULL)
{
LogError("Failed to get delimiters lengths");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -289,7 +289,7 @@ int StringToken_Split(const char* source, size_t length, const char** delimiters
if (source == NULL || delimiters == NULL || n_delims == 0 || tokens == NULL || token_count == NULL)
{
LogError("Invalid argument (source=%p, delimiters=%p, n_delims=%lu, tokens=%p, token_count=%p)", source, delimiters, (unsigned long)n_delims, tokens, token_count);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -316,7 +316,7 @@ int StringToken_Split(const char* source, size_t length, const char** delimiters
if ((tokenValue != NULL && tokenLength == 0) || (tokenValue == NULL && tokenLength > 0))
{
LogError("Unexpected token value (%p) or length (%lu)", tokenValue, (unsigned long)tokenLength);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
// Codes_SRS_STRING_TOKENIZER_09_024: [ All NULL tokens shall be ommited if include_empty is not TRUE ]
@ -331,7 +331,7 @@ int StringToken_Split(const char* source, size_t length, const char** delimiters
// Codes_SRS_STRING_TOKENIZER_09_026: [ If any failures splitting or storing the tokens occur the function shall return a non-zero value ]
LogError("Failed re-allocating the token array");
(*token_count)--;
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -346,7 +346,7 @@ int StringToken_Split(const char* source, size_t length, const char** delimiters
// Codes_SRS_STRING_TOKENIZER_09_026: [ If any failures splitting or storing the tokens occur the function shall return a non-zero value ]
LogError("Failed copying token into array");
*token_count = (*token_count) - 1;
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else

Просмотреть файл

@ -72,7 +72,7 @@ int STRING_TOKENIZER_get_next_token(STRING_TOKENIZER_HANDLE tokenizer, STRING_HA
/* Codes_SRS_STRING_04_004: [STRING_TOKENIZER_get_next_token shall return a nonzero value if any of the 3 parameters is NULL] */
if (tokenizer == NULL || output == NULL || delimiters == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -85,12 +85,12 @@ int STRING_TOKENIZER_get_next_token(STRING_TOKENIZER_HANDLE tokenizer, STRING_HA
/* Codes_SRS_STRING_TOKENIZER_04_014: [STRING_TOKENIZER_get_next_token shall return nonzero value if t contains an empty string.] */
if (remainingInputStringSize == 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else if (delimitterSize == 0)
{
LogError("Empty delimiters parameter.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -127,7 +127,7 @@ int STRING_TOKENIZER_get_next_token(STRING_TOKENIZER_HANDLE tokenizer, STRING_HA
/* Codes_SRS_STRING_04_006: [If no such character is found, then STRING_TOKENIZER_get_next_token shall return a nonzero Value (You've reach the end of the string or the string consists with only delimiters).] */
if (remainingInputStringSize == 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -162,7 +162,7 @@ int STRING_TOKENIZER_get_next_token(STRING_TOKENIZER_HANDLE tokenizer, STRING_HA
if (STRING_copy_n(output, token->currentPos, amountOfCharactersToCopy) != 0)
{
LogError("Problem copying token to output String.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -379,7 +379,7 @@ int STRING_concat(STRING_HANDLE handle, const char* s2)
if ((handle == NULL) || (s2 == NULL))
{
/* Codes_SRS_STRING_07_013: [STRING_concat shall return a nonzero number if an error is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -391,7 +391,7 @@ int STRING_concat(STRING_HANDLE handle, const char* s2)
{
/* Codes_SRS_STRING_07_013: [STRING_concat shall return a nonzero number if an error is encountered.] */
LogError("Failure reallocating value.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -414,7 +414,7 @@ int STRING_concat_with_STRING(STRING_HANDLE s1, STRING_HANDLE s2)
{
/* Codes_SRS_STRING_07_035: [String_Concat_with_STRING shall return a nonzero number if an error is encountered.] */
LogError("Invalid argument specified");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -428,7 +428,7 @@ int STRING_concat_with_STRING(STRING_HANDLE s1, STRING_HANDLE s2)
{
/* Codes_SRS_STRING_07_035: [String_Concat_with_STRING shall return a nonzero number if an error is encountered.] */
LogError("Failure reallocating value");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -451,7 +451,7 @@ int STRING_copy(STRING_HANDLE handle, const char* s2)
if ((handle == NULL) || (s2 == NULL))
{
/* Codes_SRS_STRING_07_017: [STRING_copy shall return a nonzero value if any of the supplied parameters are NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -465,7 +465,7 @@ int STRING_copy(STRING_HANDLE handle, const char* s2)
{
LogError("Failure reallocating value.");
/* Codes_SRS_STRING_07_027: [STRING_copy shall return a nonzero value if any error is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -493,7 +493,7 @@ int STRING_copy_n(STRING_HANDLE handle, const char* s2, size_t n)
if ((handle == NULL) || (s2 == NULL))
{
/* Codes_SRS_STRING_07_019: [STRING_copy_n shall return a nonzero value if STRING_HANDLE or const char* is NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -510,7 +510,7 @@ int STRING_copy_n(STRING_HANDLE handle, const char* s2, size_t n)
{
LogError("Failure reallocating value.");
/* Codes_SRS_STRING_07_028: [STRING_copy_n shall return a nonzero value if any error is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -543,7 +543,7 @@ int STRING_sprintf(STRING_HANDLE handle, const char* format, ...)
{
/* Codes_SRS_STRING_07_042: [if the parameters s1 or format are NULL then STRING_sprintf shall return non zero value.] */
LogError("Invalid arg (NULL)");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -557,7 +557,7 @@ int STRING_sprintf(STRING_HANDLE handle, const char* format, ...)
{
/* Codes_SRS_STRING_07_043: [If any error is encountered STRING_sprintf shall return a non zero value.] */
LogError("Failure vsnprintf return < 0");
result = __FAILURE__;
result = MU_FAILURE;
}
else if (s2Length == 0)
{
@ -579,7 +579,7 @@ int STRING_sprintf(STRING_HANDLE handle, const char* format, ...)
/* Codes_SRS_STRING_07_043: [If any error is encountered STRING_sprintf shall return a non zero value.] */
LogError("Failure vsnprintf formatting error");
s1->s[s1Length] = '\0';
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -592,7 +592,7 @@ int STRING_sprintf(STRING_HANDLE handle, const char* format, ...)
{
/* Codes_SRS_STRING_07_043: [If any error is encountered STRING_sprintf shall return a non zero value.] */
LogError("Failure unable to reallocate memory");
result = __FAILURE__;
result = MU_FAILURE;
}
}
}
@ -609,7 +609,7 @@ int STRING_quote(STRING_HANDLE handle)
if (handle == NULL)
{
/* Codes_SRS_STRING_07_015: [STRING_quote shall return a nonzero value if any of the supplied parameters are NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -620,7 +620,7 @@ int STRING_quote(STRING_HANDLE handle)
{
LogError("Failure reallocating value.");
/* Codes_SRS_STRING_07_029: [STRING_quote shall return a nonzero value if any error is encountered.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -643,7 +643,7 @@ int STRING_empty(STRING_HANDLE handle)
if (handle == NULL)
{
/* Codes_SRS_STRING_07_023: [STRING_empty shall return a nonzero value if the STRING_HANDLE is NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -653,7 +653,7 @@ int STRING_empty(STRING_HANDLE handle)
{
LogError("Failure reallocating value.");
/* Codes_SRS_STRING_07_030: [STRING_empty shall return a nonzero value if the STRING_HANDLE is NULL.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -831,7 +831,7 @@ int STRING_replace(STRING_HANDLE handle, char target, char replace)
if (handle == NULL)
{
/* Codes_SRS_STRING_07_046: [ If handle is NULL STRING_replace shall return a non-zero value. ] */
result = __FAILURE__;
result = MU_FAILURE;
}
else if (target == replace)
{

Просмотреть файл

@ -22,7 +22,7 @@ int UUID_from_string(const char* uuid_string, UUID_T* uuid)
if (uuid_string == NULL || uuid == NULL)
{
LogError("Invalid argument (uuid_string=%p, uuid=%p)", uuid_string, uuid);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -31,7 +31,7 @@ int UUID_from_string(const char* uuid_string, UUID_T* uuid)
if (uuid_string_length != UUID_STRING_LENGTH)
{
LogError("Unexpected size for an UUID string (%lu)", (unsigned long)uuid_string_length);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -59,7 +59,7 @@ int UUID_from_string(const char* uuid_string, UUID_T* uuid)
{
// Codes_SRS_UUID_09_009: [ If uuid fails to be generated, UUID_from_string shall return a non-zero value ]
LogError("Failed decoding UUID string (%lu)", (unsigned long)i);
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -123,7 +123,7 @@ int UUID_generate(UUID_T* uuid)
if (uuid == NULL)
{
LogError("Invalid argument (uuid is NULL)");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -133,7 +133,7 @@ int UUID_generate(UUID_T* uuid)
{
// Codes_SRS_UUID_09_003: [ If the UUID string fails to be obtained, UUID_generate shall fail and return a non-zero value ]
LogError("Failed allocating UUID string");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -144,14 +144,14 @@ int UUID_generate(UUID_T* uuid)
{
// Codes_SRS_UUID_09_003: [ If the UUID string fails to be obtained, UUID_generate shall fail and return a non-zero value ]
LogError("Failed generating UUID");
result = __FAILURE__;
result = MU_FAILURE;
}
// Codes_SRS_UUID_09_004: [ The UUID string shall be parsed into an UUID_T type (16 unsigned char array) and filled in uuid ]
else if (UUID_from_string(uuid_string, uuid) != 0)
{
// Codes_SRS_UUID_09_005: [ If uuid fails to be set, UUID_generate shall fail and return a non-zero value ]
LogError("Failed parsing UUID string");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -21,7 +21,7 @@
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/utf8_checker.h"
#include "azure_c_shared_utility/gb_rand.h"
#include "azure_c_shared_utility/base64.h"
#include "azure_c_shared_utility/azure_base64.h"
#include "azure_c_shared_utility/optionhandler.h"
#include "azure_c_shared_utility/map.h"
@ -632,7 +632,7 @@ static int send_close_frame(UWS_CLIENT_INSTANCE* uws_client, unsigned int close_
if (close_frame_buffer == NULL)
{
LogError("Encoding of CLOSE failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -643,7 +643,7 @@ static int send_close_frame(UWS_CLIENT_INSTANCE* uws_client, unsigned int close_
if (xio_send(uws_client->underlying_io, close_frame, close_frame_length, unchecked_on_send_complete, NULL) != 0)
{
LogError("Sending CLOSE frame failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -768,7 +768,7 @@ static void on_underlying_io_open_complete(void* context, IO_OPEN_RESULT open_re
}
/* Codes_SRS_UWS_CLIENT_01_497: [ The nonce needed for the upgrade request shall be Base64 encoded with Base64_Encode_Bytes. ]*/
base64_nonce = Base64_Encode_Bytes(nonce, sizeof(nonce));
base64_nonce = Azure_Base64_Encode_Bytes(nonce, sizeof(nonce));
if (base64_nonce == NULL)
{
/* Codes_SRS_UWS_CLIENT_01_498: [ If Base64 encoding the nonce for the upgrade request fails, then the uws client shall report that the open failed by calling the on_ws_open_complete callback passed to uws_client_open_async with WS_OPEN_ERROR_BASE64_ENCODE_FAILED. ]*/
@ -937,7 +937,7 @@ static int ParseStringToDecimal(const char *src, int* dst)
(*dst) = (int)strtol(src, &next, 0);
if ((src == next) || ((((*dst) == INT_MAX) || ((*dst) == INT_MIN)) && (errno != 0)))
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -958,7 +958,7 @@ static int ParseHttpResponse(const char* src, int* dst)
if ((src == NULL) || (dst == NULL))
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1004,13 +1004,13 @@ static int ParseHttpResponse(const char* src, int* dst)
if (fail)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
if (ParseStringToDecimal(src, dst) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1031,7 +1031,7 @@ static int process_frame_fragment(UWS_CLIENT_INSTANCE *uws_client, size_t length
/* Codes_SRS_UWS_CLIENT_01_379: [ If allocating memory for accumulating the bytes fails, uws shall report that the open failed by calling the on_ws_open_complete callback passed to uws_client_open_async with WS_OPEN_ERROR_NOT_ENOUGH_MEMORY. ]*/
LogError("Cannot allocate memory for received data");
indicate_ws_error(uws_client, WS_ERROR_NOT_ENOUGH_MEMORY);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1646,7 +1646,7 @@ int uws_client_open_async(UWS_CLIENT_HANDLE uws_client, ON_WS_OPEN_COMPLETE on_w
/* Codes_SRS_UWS_CLIENT_01_027: [ If uws_client, on_ws_open_complete, on_ws_frame_received, on_ws_peer_closed or on_ws_error is NULL, uws_client_open_async shall fail and return a non-zero value. ]*/
LogError("Invalid arguments: uws=%p, on_ws_open_complete=%p, on_ws_frame_received=%p, on_ws_error=%p",
uws_client, on_ws_open_complete, on_ws_frame_received, on_ws_error);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1655,7 +1655,7 @@ int uws_client_open_async(UWS_CLIENT_HANDLE uws_client, ON_WS_OPEN_COMPLETE on_w
/* Codes_SRS_UWS_CLIENT_01_400: [ uws_client_open_async while CLOSING shall fail and return a non-zero value. ]*/
/* Codes_SRS_UWS_CLIENT_01_394: [ uws_client_open_async while the uws instance is already OPEN or OPENING shall fail and return a non-zero value. ]*/
LogError("Invalid uWS state while trying to open: %d", (int)uws_client->uws_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1683,7 +1683,7 @@ int uws_client_open_async(UWS_CLIENT_HANDLE uws_client, ON_WS_OPEN_COMPLETE on_w
/* Codes_SRS_UWS_CLIENT_01_075: [ If the connection could not be opened, either because a direct connection failed or because any proxy used returned an error, then the client MUST _Fail the WebSocket Connection_ and abort the connection attempt. ]*/
LogError("Opening the underlying IO failed");
uws_client->uws_state = UWS_STATE_CLOSED;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1705,7 +1705,7 @@ static int complete_send_frame(WS_PENDING_SEND* ws_pending_send, LIST_ITEM_HANDL
if (singlylinkedlist_remove(uws_client->pending_sends, pending_send_frame_item) != 0)
{
LogError("Failed removing item from list");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1736,7 +1736,7 @@ int uws_client_close_async(UWS_CLIENT_HANDLE uws_client, ON_WS_CLOSE_COMPLETE on
{
/* Codes_SRS_UWS_CLIENT_01_030: [ if uws_client is NULL, uws_client_close_async shall return a non-zero value. ]*/
LogError("NULL uWS handle.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1747,7 +1747,7 @@ int uws_client_close_async(UWS_CLIENT_HANDLE uws_client, ON_WS_CLOSE_COMPLETE on
{
/* Codes_SRS_UWS_CLIENT_01_032: [ uws_client_close_async when no open action has been issued shall fail and return a non-zero value. ]*/
LogError("close has been called when already CLOSED");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1763,7 +1763,7 @@ int uws_client_close_async(UWS_CLIENT_HANDLE uws_client, ON_WS_CLOSE_COMPLETE on
{
/* Codes_SRS_UWS_CLIENT_01_395: [ If xio_close fails, uws_client_close_async shall fail and return a non-zero value. ]*/
LogError("Closing the underlying IO failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1797,7 +1797,7 @@ int uws_client_close_handshake_async(UWS_CLIENT_HANDLE uws_client, uint16_t clos
{
/* Codes_SRS_UWS_CLIENT_01_467: [ if uws_client is NULL, uws_client_close_handshake_async shall return a non-zero value. ]*/
LogError("NULL uws_client");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1809,7 +1809,7 @@ int uws_client_close_handshake_async(UWS_CLIENT_HANDLE uws_client, uint16_t clos
{
/* Codes_SRS_UWS_CLIENT_01_473: [ uws_client_close_handshake_async when no open action has been issued shall fail and return a non-zero value. ]*/
LogError("uws_client_close_handshake_async has been called when already CLOSED");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1828,7 +1828,7 @@ int uws_client_close_handshake_async(UWS_CLIENT_HANDLE uws_client, uint16_t clos
{
/* Codes_SRS_UWS_CLIENT_01_472: [ If xio_send fails, uws_client_close_handshake_async shall fail and return a non-zero value. ]*/
LogError("Sending CLOSE frame failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1912,14 +1912,14 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
{
/* Codes_SRS_UWS_CLIENT_01_044: [ If any the arguments uws_client is NULL, uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("NULL uws handle.");
result = __FAILURE__;
result = MU_FAILURE;
}
else if ((buffer == NULL) &&
(size > 0))
{
/* Codes_SRS_UWS_CLIENT_01_045: [ If size is non-zero and buffer is NULL then uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("NULL buffer with %u size.", (unsigned int)size);
result = __FAILURE__;
result = MU_FAILURE;
}
/* Codes_SRS_UWS_CLIENT_01_146: [ A data frame MAY be transmitted by either the client or the server at any time after opening handshake completion and before that endpoint has sent a Close frame (Section 5.5.1). ]*/
/* Codes_SRS_UWS_CLIENT_01_268: [ The endpoint MUST ensure the WebSocket connection is in the OPEN state ]*/
@ -1927,7 +1927,7 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
{
/* Codes_SRS_UWS_CLIENT_01_043: [ If the uws instance is not OPEN (open has not been called or is still in progress) then uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("uws not in OPEN state.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1936,7 +1936,7 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
{
/* Codes_SRS_UWS_CLIENT_01_047: [ If allocating memory for the newly queued item fails, uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("Cannot allocate memory for frame to be sent.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1952,7 +1952,7 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
/* Codes_SRS_UWS_CLIENT_01_426: [ If uws_frame_encoder_encode fails, uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("Failed encoding WebSocket frame");
free(ws_pending_send);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -1980,7 +1980,7 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
/* Codes_SRS_UWS_CLIENT_01_049: [ If singlylinkedlist_add fails, uws_client_send_frame_async shall fail and return a non-zero value. ]*/
LogError("Could not allocate memory for pending frames");
free(ws_pending_send);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -2004,7 +2004,7 @@ int uws_client_send_frame_async(UWS_CLIENT_HANDLE uws_client, unsigned char fram
free(ws_pending_send);
}
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -2050,7 +2050,7 @@ int uws_client_set_option(UWS_CLIENT_HANDLE uws_client, const char* option_name,
{
/* Codes_SRS_UWS_CLIENT_01_440: [ If any of the arguments uws_client or option_name is NULL uws_client_set_option shall return a non-zero value. ]*/
LogError("invalid parameter (NULL) passed to uws_client_set_option");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -2061,7 +2061,7 @@ int uws_client_set_option(UWS_CLIENT_HANDLE uws_client, const char* option_name,
{
/* Codes_SRS_UWS_CLIENT_01_511: [ If OptionHandler_FeedOptions fails, uws_client_set_option shall fail and return a non-zero value. ]*/
LogError("OptionHandler_FeedOptions failed");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -2076,7 +2076,7 @@ int uws_client_set_option(UWS_CLIENT_HANDLE uws_client, const char* option_name,
{
/* Codes_SRS_UWS_CLIENT_01_443: [ If xio_setoption fails, uws_client_set_option shall fail and return a non-zero value. ]*/
LogError("xio_setoption failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -2203,14 +2203,14 @@ int uws_client_set_request_header(UWS_CLIENT_HANDLE uws_client, const char* name
{
// Codes_SRS_UWS_CLIENT_09_002: [ If any of the arguments uws_client or name or value is NULL uws_client_set_request_header shall fail and return a non-zero value. ]
LogError("invalid parameter (uws_client=%p, name=%p, value=%p)", uws_client, name, value);
result = __FAILURE__;
result = MU_FAILURE;
}
// Codes_SRS_UWS_CLIENT_09_003: [ A copy of name and value shall be stored for later sending in the request message. ]
else if (Map_AddOrUpdate(uws_client->request_headers, name, value) != MAP_OK)
{
// Codes_SRS_UWS_CLIENT_09_004: [ If name or value fail to be stored the function shall fail and return a non-zero value. ]
LogError("Failed adding request header %s", name);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -95,7 +95,7 @@ int VECTOR_push_back(VECTOR_HANDLE handle, const void* elements, size_t numEleme
/* Codes_SRS_VECTOR_10_034: [VECTOR_push_back shall fail and return non-zero if elements is NULL.] */
/* Codes_SRS_VECTOR_10_035: [VECTOR_push_back shall fail and return non-zero if numElements is 0.] */
LogError("invalid argument - handle(%p), elements(%p), numElements(%zd).", handle, elements, numElements);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -107,7 +107,7 @@ int VECTOR_push_back(VECTOR_HANDLE handle, const void* elements, size_t numEleme
{
/* Codes_SRS_VECTOR_10_012: [VECTOR_push_back shall fail and return non-zero if memory allocation fails.] */
LogError("realloc failed.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -37,7 +37,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (url_length < MIN_URL_PARSABLE_LENGTH)
{
LogError("Invalid url (unexpected length)");
result = __FAILURE__;
result = MU_FAILURE;
}
// Codes_SRS_WS_URL_09_004: [ If url starts with "ws://" (protocol), ws_url->is_secure shall be set to false ]
if (strncmp(url, WS_PROTOCOL, 5) == 0)
@ -53,7 +53,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
{
// Codes_SRS_WS_URL_09_024: [ If protocol cannot be identified in url, the function shall fail and return NULL ]
LogError("Url protocol prefix not recognized");
result = __FAILURE__;
result = MU_FAILURE;
}
if (result == 0)
@ -91,7 +91,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (token == NULL)
{
LogError("Failed getting first url token");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -111,7 +111,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (ws_url->host == NULL || ws_url->host_length == 0)
{
LogError("Failed parsing websocket url host");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -129,7 +129,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (port == NULL || port_length == 0)
{
LogError("Failed parsing websocket url port");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -155,7 +155,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (ws_url->path == NULL || ws_url->path_length == 0)
{
LogError("Failed parsing websocket url path");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -175,7 +175,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
if (ws_url->query == NULL || ws_url->query_length == 0)
{
LogError("Failed parsing websocket url query");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
else
@ -186,7 +186,7 @@ static int parse_ws_url(const char* url, WS_URL* ws_url)
else
{
LogError("Failed parsing websocket url (format not recognized)");
result = __FAILURE__;
result = MU_FAILURE;
break;
}
@ -267,7 +267,7 @@ int ws_url_is_secure(WS_URL_HANDLE url, bool* is_secure)
if (url == NULL || is_secure == NULL)
{
LogError("Invalid argument (url=%p, is_secure=%p)", url, is_secure);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -289,7 +289,7 @@ int ws_url_get_host(WS_URL_HANDLE url, const char** host, size_t* length)
if (url == NULL || host == NULL || length == NULL)
{
LogError("Invalid argument (url=%p, host=%p, length=%p)", url, host, length);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -312,7 +312,7 @@ int ws_url_get_port(WS_URL_HANDLE url, size_t* port)
if (url == NULL || port == NULL)
{
LogError("Invalid argument (url=%p, port=%p)", url, port);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -334,7 +334,7 @@ int ws_url_get_path(WS_URL_HANDLE url, const char** path, size_t* length)
if (url == NULL || path == NULL || length == NULL)
{
LogError("Invalid argument (url=%p, path=%p, length=%p)", url, path, length);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -357,7 +357,7 @@ int ws_url_get_query(WS_URL_HANDLE url, const char** query, size_t* length)
if (url == NULL || query == NULL || length == NULL)
{
LogError("Invalid argument (url=%p, query=%p, length=%p)", url, query, length);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -148,7 +148,7 @@ static int internal_close(WSIO_INSTANCE* wsio_instance, ON_IO_CLOSE_COMPLETE on_
if (wsio_instance->io_state == IO_STATE_NOT_OPEN)
{
LogError("wsio_close when not open.");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -161,7 +161,7 @@ static int internal_close(WSIO_INSTANCE* wsio_instance, ON_IO_CLOSE_COMPLETE on_
else if (wsio_instance->io_state == IO_STATE_CLOSING)
{
LogError("Already closing");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -485,7 +485,7 @@ int wsio_open(CONCRETE_IO_HANDLE ws_io, ON_IO_OPEN_COMPLETE on_io_open_complete,
/* Codes_SRS_WSIO_01_132: [ If any of the arguments ws_io, on_io_open_complete, on_bytes_received, on_io_error is NULL, wsio_open shall fail and return a non-zero value. ]*/
LogError("Bad arguments: ws_io=%p, on_io_open_complete=%p, on_bytes_received=%p, on_io_error=%p",
ws_io, on_io_open_complete, on_bytes_received, on_io_error);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -496,7 +496,7 @@ int wsio_open(CONCRETE_IO_HANDLE ws_io, ON_IO_OPEN_COMPLETE on_io_open_complete,
/* Codes_SRS_WSIO_01_165: [ wsio_open when CLOSING shall fail and return a non-zero value. ]*/
/* Codes_SRS_WSIO_01_131: [ wsio_open when already OPEN or OPENING shall fail and return a non-zero value. ]*/
LogError("wsio has already been opened current state: %d", wsio_instance->io_state);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -515,7 +515,7 @@ int wsio_open(CONCRETE_IO_HANDLE ws_io, ON_IO_OPEN_COMPLETE on_io_open_complete,
/* Codes_SRS_WSIO_01_084: [ If opening the underlying uws instance fails then wsio_open shall fail and return a non-zero value. ]*/
LogError("Opening the uws instance failed.");
wsio_instance->io_state = IO_STATE_NOT_OPEN;
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -536,7 +536,7 @@ int wsio_close(CONCRETE_IO_HANDLE ws_io, ON_IO_CLOSE_COMPLETE on_io_close_comple
{
/* Codes_SRS_WSIO_01_086: [ if ws_io is NULL, wsio_close shall return a non-zero value. ]*/
LogError("NULL handle");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -544,7 +544,7 @@ int wsio_close(CONCRETE_IO_HANDLE ws_io, ON_IO_CLOSE_COMPLETE on_io_close_comple
if (internal_close(wsio_instance, on_io_close_complete, on_io_close_complete_context) != 0)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -567,7 +567,7 @@ int wsio_send(CONCRETE_IO_HANDLE ws_io, const void* buffer, size_t size, ON_SEND
{
LogError("Bad arguments: ws_io=%p, buffer=%p, size=%u",
ws_io, buffer, (unsigned int)size);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -577,7 +577,7 @@ int wsio_send(CONCRETE_IO_HANDLE ws_io, const void* buffer, size_t size, ON_SEND
{
/* Codes_SRS_WSIO_01_099: [ If the wsio is not OPEN (open has not been called or is still in progress) then wsio_send shall fail and return a non-zero value. ]*/
LogError("Attempting to send when not open");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -586,7 +586,7 @@ int wsio_send(CONCRETE_IO_HANDLE ws_io, const void* buffer, size_t size, ON_SEND
if (pending_socket_io == NULL)
{
/* Codes_SRS_WSIO_01_134: [ If allocating memory for the pending IO data fails, wsio_send shall fail and return a non-zero value. ]*/
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -600,7 +600,7 @@ int wsio_send(CONCRETE_IO_HANDLE ws_io, const void* buffer, size_t size, ON_SEND
{
/* Codes_SRS_WSIO_01_104: [ If singlylinkedlist_add fails, wsio_send shall fail and return a non-zero value. ]*/
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -615,7 +615,7 @@ int wsio_send(CONCRETE_IO_HANDLE ws_io, const void* buffer, size_t size, ON_SEND
}
free(pending_socket_io);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -661,7 +661,7 @@ int wsio_setoption(CONCRETE_IO_HANDLE ws_io, const char* optionName, const void*
{
LogError("Bad parameters: ws_io=%p, optionName=%p",
ws_io, optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -674,7 +674,7 @@ int wsio_setoption(CONCRETE_IO_HANDLE ws_io, const char* optionName, const void*
{
/* Codes_SRS_WSIO_01_184: [ If OptionHandler_FeedOptions fails, wsio_setoption shall fail and return a non-zero value. ]*/
LogError("unable to OptionHandler_FeedOptions");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -689,7 +689,7 @@ int wsio_setoption(CONCRETE_IO_HANDLE ws_io, const char* optionName, const void*
{
/* Codes_SRS_WSIO_01_157: [ If uws_client_set_option fails, wsio_setoption shall fail and return a non-zero value. ]*/
LogError("Setting the option %s failed", optionName);
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Просмотреть файл

@ -79,7 +79,7 @@ int xio_open(XIO_HANDLE xio, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_i
if (xio == NULL)
{
/* Codes_SRS_XIO_01_021: [If handle is NULL, xio_open shall return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -89,7 +89,7 @@ int xio_open(XIO_HANDLE xio, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_i
if (xio_instance->io_interface_description->concrete_io_open(xio_instance->concrete_xio_handle, on_io_open_complete, on_io_open_complete_context, on_bytes_received, on_bytes_received_context, on_io_error, on_io_error_context) != 0)
{
/* Codes_SRS_XIO_01_022: [If the underlying concrete_io_open fails, xio_open shall return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -108,7 +108,7 @@ int xio_close(XIO_HANDLE xio, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* c
if (xio == NULL)
{
/* Codes_SRS_XIO_01_025: [If handle is NULL, xio_close shall return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -118,7 +118,7 @@ int xio_close(XIO_HANDLE xio, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* c
if (xio_instance->io_interface_description->concrete_io_close(xio_instance->concrete_xio_handle, on_io_close_complete, callback_context) != 0)
{
/* Codes_SRS_XIO_01_026: [If the underlying concrete_io_close fails, xio_close shall return a non-zero value.] */
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -138,7 +138,7 @@ int xio_send(XIO_HANDLE xio, const void* buffer, size_t size, ON_SEND_COMPLETE o
/* Codes_SRS_XIO_01_010: [If handle is NULL, xio_send shall return a non-zero value.] */
if (xio == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -173,7 +173,7 @@ int xio_setoption(XIO_HANDLE xio, const char* optionName, const void* value)
/* Codes_SRS_XIO_03_030: [If the xio argument or the optionName argument is NULL, xio_setoption shall return a non-zero value.] */
if (xio == NULL || optionName == NULL)
{
result = __FAILURE__;
result = MU_FAILURE;
}
else
{
@ -185,7 +185,7 @@ int xio_setoption(XIO_HANDLE xio, const char* optionName, const void* value)
if (OptionHandler_FeedOptions((OPTIONHANDLER_HANDLE)value, xio_instance->concrete_xio_handle) != OPTIONHANDLER_OK)
{
LogError("unable to OptionHandler_FeedOptions");
result = __FAILURE__;
result = MU_FAILURE;
}
else
{

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше