Azure IoT common library

Fork of azure_c_shared_utility by Azure IoT

Revision:
27:8656a313842b
Parent:
22:10640b226104
Child:
29:e3ed192c35fb
--- a/httpapi_compact.c	Mon May 08 10:51:21 2017 -0700
+++ b/httpapi_compact.c	Mon May 22 10:35:55 2017 -0700
@@ -16,6 +16,10 @@
 #include "azure_c_shared_utility/threadapi.h"
 #include "azure_c_shared_utility/shared_util_options.h"
 
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
 /*Codes_SRS_HTTPAPI_COMPACT_21_001: [ The httpapi_compact shall implement the methods defined by the `httpapi.h`. ]*/
 /*Codes_SRS_HTTPAPI_COMPACT_21_002: [ The httpapi_compact shall support the http requests. ]*/
 /*Codes_SRS_HTTPAPI_COMPACT_21_003: [ The httpapi_compact shall return error codes defined by HTTPAPI_RESULT. ]*/
@@ -731,10 +735,11 @@
             }
             else
             {
+				int countRetry;
                 /*Codes_SRS_HTTPAPI_COMPACT_21_033: [ If the whole process succeed, the HTTPAPI_ExecuteRequest shall retur HTTPAPI_OK. ]*/
                 result = HTTPAPI_OK;
                 /*Codes_SRS_HTTPAPI_COMPACT_21_077: [ The HTTPAPI_ExecuteRequest shall wait, at least, 10 seconds for the SSL open process. ]*/
-                int countRetry = MAX_OPEN_RETRY;
+                countRetry = MAX_OPEN_RETRY;
                 while ((http_instance->is_connected == 0) &&
                     (http_instance->is_io_error == 0))
                 {
@@ -835,9 +840,10 @@
         /*Codes_SRS_HTTPAPI_COMPACT_21_028: [ If the HTTPAPI_ExecuteRequest cannot send the request header, it shall return HTTPAPI_HTTP_HEADERS_FAILED. ]*/
     else if ((result = conn_send_all(http_instance, (const unsigned char*)buf, strlen(buf))) == HTTPAPI_OK)
     {
+		size_t i;
         //Send default headers
         /*Codes_SRS_HTTPAPI_COMPACT_21_033: [ If the whole process succeed, the HTTPAPI_ExecuteRequest shall retur HTTPAPI_OK. ]*/
-        for (size_t i = 0; ((i < headersCount) && (result == HTTPAPI_OK)); i++)
+        for (i = 0; ((i < headersCount) && (result == HTTPAPI_OK)); i++)
         {
             char* header;
             if (HTTPHeaders_GetHeader(httpHeadersHandle, i, &header) != HTTP_HEADERS_OK)
@@ -1254,12 +1260,14 @@
     }
     else if (strcmp("TrustedCerts", optionName) == 0)
     {
+		int len;
+
         if (http_instance->certificate)
         {
             free(http_instance->certificate);
         }
 
-        int len = (int)strlen((char*)value);
+        len = (int)strlen((char*)value);
         http_instance->certificate = (char*)malloc((len + 1) * sizeof(char));
         if (http_instance->certificate == NULL)
         {
@@ -1276,12 +1284,13 @@
     }
     else if (strcmp(SU_OPTION_X509_CERT, optionName) == 0)
     {
+		int len;
         if (http_instance->x509ClientCertificate)
         {
             free(http_instance->x509ClientCertificate);
         }
 
-        int len = (int)strlen((char*)value);
+        len = (int)strlen((char*)value);
         http_instance->x509ClientCertificate = (char*)malloc((len + 1) * sizeof(char));
         if (http_instance->x509ClientCertificate == NULL)
         {
@@ -1298,12 +1307,13 @@
     }
     else if (strcmp(SU_OPTION_X509_PRIVATE_KEY, optionName) == 0)
     {
+		int len;
         if (http_instance->x509ClientPrivateKey)
         {
             free(http_instance->x509ClientPrivateKey);
         }
 
-        int len = (int)strlen((char*)value);
+        len = (int)strlen((char*)value);
         http_instance->x509ClientPrivateKey = (char*)malloc((len + 1) * sizeof(char));
         if (http_instance->x509ClientPrivateKey == NULL)
         {