Better support for MSVC
diff --git a/ChangeLog b/ChangeLog
index 8e3b0a9..81bafe9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
* Header files with 'polarssl/'
* Const correctness
* Possible naming collision in dhm_context
+ * Better support for MSVC
= PolarSSL-1.3.0 released on 2013-10-01
Features
diff --git a/include/polarssl/compat-1.2.h b/include/polarssl/compat-1.2.h
index b60c932..ce4566c 100644
--- a/include/polarssl/compat-1.2.h
+++ b/include/polarssl/compat-1.2.h
@@ -32,6 +32,11 @@
// Comment out to disable prototype change warnings
#define SHOW_PROTOTYPE_CHANGE_WARNINGS
+#if defined _MSC_VER
+// MSVC does not support #warning
+#undef SHOW_PROTOTYPE_CHANGE_WARNINGS
+#endif
+
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "You can disable these warnings by commenting SHOW_PROTOTYPE_CHANGE_WARNINGS in compat-1.2.h"
#endif
@@ -53,14 +58,14 @@
sha256_update( ctx, input, ilen );
}
inline void sha2_finish( sha256_context *ctx, unsigned char output[32] ) {
- return sha256_finish( ctx, output );
+ sha256_finish( ctx, output );
}
inline int sha2_file( const char *path, unsigned char output[32], int is224 ) {
return sha256_file( path, output, is224 );
}
inline void sha2( const unsigned char *input, size_t ilen,
unsigned char output[32], int is224 ) {
- return sha256( input, ilen, output, is224 );
+ sha256( input, ilen, output, is224 );
}
inline void sha2_hmac_starts( sha256_context *ctx, const unsigned char *key,
size_t keylen, int is224 ) {
@@ -102,14 +107,14 @@
sha512_update( ctx, input, ilen );
}
inline void sha4_finish( sha512_context *ctx, unsigned char output[64] ) {
- return sha512_finish( ctx, output );
+ sha512_finish( ctx, output );
}
inline int sha4_file( const char *path, unsigned char output[64], int is384 ) {
return sha512_file( path, output, is384 );
}
inline void sha4( const unsigned char *input, size_t ilen,
unsigned char output[32], int is384 ) {
- return sha512( input, ilen, output, is384 );
+ sha512( input, ilen, output, is384 );
}
inline void sha4_hmac_starts( sha512_context *ctx, const unsigned char *key,
size_t keylen, int is384 ) {
@@ -232,7 +237,7 @@
return x509_crt_revoked( crt, crl );
}
inline void x509_free( x509_cert *crt ) {
- return x509_crt_free( crt );
+ x509_crt_free( crt );
}
#endif /* POLARSSL_X509_CRT_PARSE_C */
@@ -354,7 +359,7 @@
int ret;
pk_context ctx;
if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
- if( ( ret = rsa_copy( ctx.pk_ctx, rsa ) ) != 0 ) return( ret );
+ if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
ret = pk_write_pubkey_der( &ctx, buf, len );
pk_free( &ctx );
return( ret );
@@ -363,7 +368,7 @@
int ret;
pk_context ctx;
if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
- if( ( ret = rsa_copy( ctx.pk_ctx, rsa ) ) != 0 ) return( ret );
+ if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
ret = pk_write_key_der( &ctx, buf, len );
pk_free( &ctx );
return( ret );
diff --git a/library/x509_crt.c b/library/x509_crt.c
index e6c840c..91d4626 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -958,7 +958,7 @@
w_ret = MultiByteToWideChar( CP_ACP, 0, path, len, szDir, MAX_PATH - 3 );
hFind = FindFirstFileW( szDir, &file_data );
- if (hFind == INVALID_HANDLE_VALUE)
+ if (hFind == INVALID_HANDLE_VALUE)
return( POLARSSL_ERR_X509_FILE_IO_ERROR );
len = MAX_PATH - len;
@@ -982,10 +982,9 @@
}
while( FindNextFileW( hFind, &file_data ) != 0 );
- if (GetLastError() != ERROR_NO_MORE_FILES)
+ if (GetLastError() != ERROR_NO_MORE_FILES)
ret = POLARSSL_ERR_X509_FILE_IO_ERROR;
-cleanup:
FindClose( hFind );
#else
int t_ret, i;