- Lots of minimal changes to better support WINCE as a build target

diff --git a/ChangeLog b/ChangeLog
index 1355b38..3d1c577 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
      So now there is a module that is controlled with POLARSSL_ASN1_PARSE_C.
    * Changed the defined key-length of DES ciphers in cipher.h to include the
      parity bits, to prevent mistakes in copying data. (Closes ticket #33)
+   * Loads of minimal changes to better support WINCE as a build target
 
 Bugfix
    * Fixed faulty HMAC-MD2 implementation. Found by dibac. (Closes
diff --git a/include/polarssl/cipher_wrap.h b/include/polarssl/cipher_wrap.h
index 1638c24..5df8174 100644
--- a/include/polarssl/cipher_wrap.h
+++ b/include/polarssl/cipher_wrap.h
@@ -5,7 +5,7 @@
  *
  * \author Adriaan de Jong <dejong@fox-it.com>
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -26,13 +26,12 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+#ifndef POLARSSL_CIPHER_WRAP_H
+#define POLARSSL_CIPHER_WRAP_H
 
 #include "config.h"
 #include "cipher.h"
 
-#ifndef POLARSSL_CIPHER_WRAP_H
-#define POLARSSL_CIPHER_WRAP_H
-
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index 06ee291..48b2661 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -31,7 +31,7 @@
 #ifndef POLARSSL_CONFIG_H
 #define POLARSSL_CONFIG_H
 
-#ifndef _CRT_SECURE_NO_DEPRECATE
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
 #define _CRT_SECURE_NO_DEPRECATE 1
 #endif
 
diff --git a/include/polarssl/debug.h b/include/polarssl/debug.h
index 263c939..4fb3782 100644
--- a/include/polarssl/debug.h
+++ b/include/polarssl/debug.h
@@ -3,7 +3,7 @@
  *
  * \brief Debug functions
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -24,8 +24,8 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-#ifndef SSL_DEBUG_H
-#define SSL_DEBUG_H
+#ifndef POLARSSL_DEBUG_H
+#define POLARSSL_DEBUG_H
 
 #include "config.h"
 #include "ssl.h"
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index eca8646..f62ef20 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -26,7 +26,6 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-
 #ifndef POLARSSL_MD_H
 #define POLARSSL_MD_H
 
diff --git a/include/polarssl/md_wrap.h b/include/polarssl/md_wrap.h
index b6640bd..46849d0 100644
--- a/include/polarssl/md_wrap.h
+++ b/include/polarssl/md_wrap.h
@@ -5,7 +5,7 @@
  *
  * \author Adriaan de Jong <dejong@fox-it.com>
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -26,13 +26,12 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+#ifndef POLARSSL_MD_WRAP_H
+#define POLARSSL_MD_WRAP_H
 
 #include "config.h"
 #include "md.h"
 
-#ifndef POLARSSL_MD_WRAP_H
-#define POLARSSL_MD_WRAP_H
-
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/polarssl/net.h b/include/polarssl/net.h
index c02dbd2..89e3a00 100644
--- a/include/polarssl/net.h
+++ b/include/polarssl/net.h
@@ -1,9 +1,9 @@
 /**
  * \file net.h
  *
- * \brief MD5 message digest algorithm (hash function)
+ * \brief Network communication functions
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h
index 07da0de..a65a72e 100644
--- a/include/polarssl/pkcs11.h
+++ b/include/polarssl/pkcs11.h
@@ -5,7 +5,7 @@
  *
  * \author Adriaan de Jong <dejong@fox-it.com>
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -26,9 +26,8 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-
-#ifndef PKCS11_H_
-#define PKCS11_H_
+#ifndef POLARSSL_PKCS11_H
+#define POLARSSL_PKCS11_H
 
 #include "config.h"
 
@@ -124,4 +123,4 @@
 
 #endif /* POLARSSL_PKCS11_C */
 
-#endif /* PKCS11_H_ */
+#endif /* POLARSSL_PKCS11_H */
diff --git a/library/x509parse.c b/library/x509parse.c
index ceb3db2..631fe55 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -52,7 +52,11 @@
 
 #include <string.h>
 #include <stdlib.h>
+#if defined(_WIN32_WCE)
+#include <windows.h>
+#else
 #include <time.h>
+#endif
 
 #if defined(POLARSSL_FS_IO)
 #include <stdio.h>
@@ -2609,43 +2613,66 @@
  */
 int x509parse_time_expired( const x509_time *to )
 {
+    int year, mon, day;
+    int hour, min, sec;
+
+#if defined(_WIN32)
+    SYSTEMTIME st;
+
+    GetLocalTime(&st);
+
+    year = st.wYear;
+    mon = st.wMonth;
+    day = st.wDay;
+    hour = st.wHour;
+    min = st.wMinute;
+    sec = st.wSecond;
+#else
     struct tm *lt;
     time_t tt;
 
     tt = time( NULL );
     lt = localtime( &tt );
 
-    if( lt->tm_year  > to->year - 1900 )
+    year = lt->tm_year + 1900;
+    mon = lt->tm_mon + 1;
+    day = lt->tm_mday;
+    hour = lt->tm_hour;
+    min = lt->tm_min;
+    sec = lt->tm_sec;
+#endif
+
+    if( year  > to->year )
         return( 1 );
 
-    if( lt->tm_year == to->year - 1900 &&
-        lt->tm_mon   > to->mon  - 1 )
+    if( year == to->year &&
+        mon   > to->mon )
         return( 1 );
 
-    if( lt->tm_year == to->year - 1900 &&
-        lt->tm_mon  == to->mon  - 1    &&
-        lt->tm_mday  > to->day )
+    if( year == to->year &&
+        mon  == to->mon  &&
+        day   > to->day )
         return( 1 );
 
-    if( lt->tm_year == to->year - 1900 &&
-        lt->tm_mon  == to->mon  - 1    &&
-        lt->tm_mday == to->day         &&
-        lt->tm_hour  > to->hour - 1)
+    if( year == to->year &&
+        mon  == to->mon  &&
+        day  == to->day  &&
+        hour  > to->hour )
         return( 1 );
 
-    if( lt->tm_year == to->year - 1900 &&
-        lt->tm_mon  == to->mon  - 1    &&
-        lt->tm_mday == to->day         &&
-        lt->tm_hour == to->hour - 1    &&
-        lt->tm_min   > to->min  - 1 )
+    if( year == to->year &&
+        mon  == to->mon  &&
+        day  == to->day  &&
+        hour == to->hour &&
+        min   > to->min  )
         return( 1 );
 
-    if( lt->tm_year == to->year - 1900 &&
-        lt->tm_mon  == to->mon  - 1    &&
-        lt->tm_mday == to->day         &&
-        lt->tm_hour == to->hour - 1    &&
-        lt->tm_min  == to->min  - 1    &&
-        lt->tm_sec   > to->sec  - 1 )
+    if( year == to->year &&
+        mon  == to->mon  &&
+        day  == to->day  &&
+        hour == to->hour &&
+        min  == to->min  &&
+        sec   > to->sec  )
         return( 1 );
 
     return( 0 );
diff --git a/programs/aes/aescrypt2.c b/programs/aes/aescrypt2.c
index 272fd4f..1bc6574 100644
--- a/programs/aes/aescrypt2.c
+++ b/programs/aes/aescrypt2.c
@@ -1,7 +1,7 @@
 /*
  *  AES-256 file encryption program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -29,7 +29,9 @@
 
 #if defined(_WIN32)
 #include <windows.h>
+#if !defined(_WIN32_WCE)
 #include <io.h>
+#endif
 #else
 #include <sys/types.h>
 #include <unistd.h>
@@ -55,8 +57,10 @@
     "\n"
 
 #if !defined(POLARSSL_AES_C) || !defined(POLARSSL_SHA2_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
     printf("POLARSSL_AES_C and/or POLARSSL_SHA2_C not defined.\n");
     return( 0 );
 }
@@ -79,7 +83,9 @@
     aes_context aes_ctx;
     sha2_context sha_ctx;
 
-#if defined(WIN32)
+#if defined(_WIN32_WCE)
+    long filesize, offset;
+#elif defined(_WIN32)
        LARGE_INTEGER li_size;
     __int64 filesize, offset;
 #else
@@ -93,7 +99,7 @@
     {
         printf( USAGE );
 
-#if defined(WIN32)
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
@@ -162,7 +168,10 @@
 
     memset( argv[4], 0, strlen( argv[4] ) );
 
-#if defined(WIN32)
+#if defined(_WIN32_WCE)
+    filesize = fseek( fin, 0L, SEEK_END );
+#else
+#if defined(_WIN32)
     /*
      * Support large files (> 2Gb) on Win32
      */
@@ -185,6 +194,7 @@
         goto exit;
     }
 #endif
+#endif
 
     if( fseek( fin, 0, SEEK_SET ) < 0 )
     {
diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c
index 7a0e454..9fa0fb1 100644
--- a/programs/aes/crypt_and_hash.c
+++ b/programs/aes/crypt_and_hash.c
@@ -2,7 +2,7 @@
  *  \brief  Generic file encryption program using generic wrappers for configured
  *          security.
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -30,7 +30,9 @@
 
 #if defined(_WIN32)
 #include <windows.h>
+#if !defined(_WIN32_WCE)
 #include <io.h>
+#endif
 #else
 #include <sys/types.h>
 #include <unistd.h>
@@ -56,8 +58,11 @@
     "\n"
 
 #if !defined(POLARSSL_CIPHER_C) || !defined(POLARSSL_MD_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_CIPHER_C and/or POLARSSL_MD_C not defined.\n");
     return( 0 );
 }
@@ -80,7 +85,9 @@
     const md_info_t *md_info;
     cipher_context_t cipher_ctx;
     md_context_t md_ctx;
-#if defined(WIN32)
+#if defined(_WIN32_WCE)
+    long filesize, offset;
+#elif defined(_WIN32)
        LARGE_INTEGER li_size;
     __int64 filesize, offset;
 #else
@@ -117,7 +124,7 @@
             list++;
         }
 
-#if defined(WIN32)
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
@@ -205,7 +212,10 @@
 
     memset( argv[6], 0, strlen( argv[6] ) );
 
-#if defined(WIN32)
+#if defined(_WIN32_WCE)
+    filesize = fseek( fin, 0L, SEEK_END );
+#else
+#if defined(_WIN32)
     /*
      * Support large files (> 2Gb) on Win32
      */
@@ -228,6 +238,7 @@
         goto exit;
     }
 #endif
+#endif
 
     if( fseek( fin, 0, SEEK_SET ) < 0 )
     {
diff --git a/programs/hash/generic_sum.c b/programs/hash/generic_sum.c
index 04e1c04..10692a9 100644
--- a/programs/hash/generic_sum.c
+++ b/programs/hash/generic_sum.c
@@ -1,7 +1,7 @@
 /*
  *  generic message digest layer demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -35,8 +35,11 @@
 #include "polarssl/md.h"
 
 #if !defined(POLARSSL_MD_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_MD_C not defined.\n");
     return( 0 );
 }
@@ -172,7 +175,7 @@
             list++;
         }
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
diff --git a/programs/hash/hello.c b/programs/hash/hello.c
index d40c695..d4c362f 100644
--- a/programs/hash/hello.c
+++ b/programs/hash/hello.c
@@ -1,7 +1,7 @@
 /*
  *  Classic "Hello, world" demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -34,18 +34,24 @@
 #include "polarssl/md5.h"
 
 #if !defined(POLARSSL_MD5_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_MD5_C not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int i;
     unsigned char digest[16];
     char str[] = "Hello, world!";
 
+    ((void) argc);
+    ((void) argv);
+
     printf( "\n  MD5('%s') = ", str );
 
     md5( (unsigned char *) str, 13, digest );
@@ -55,7 +61,7 @@
 
     printf( "\n\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/hash/md5sum.c b/programs/hash/md5sum.c
index fb7283c..1ca7e87 100644
--- a/programs/hash/md5sum.c
+++ b/programs/hash/md5sum.c
@@ -1,7 +1,7 @@
 /*
  *  md5sum demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -35,8 +35,11 @@
 #include "polarssl/md5.h"
 
 #if !defined(POLARSSL_MD5_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_MD5_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
@@ -151,7 +154,7 @@
         printf( "print mode:  md5sum <file> <file> ...\n" );
         printf( "check mode:  md5sum -c <checksum file>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
diff --git a/programs/hash/sha1sum.c b/programs/hash/sha1sum.c
index 155bfbf..92f8406 100644
--- a/programs/hash/sha1sum.c
+++ b/programs/hash/sha1sum.c
@@ -1,7 +1,7 @@
 /*
  *  sha1sum demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -35,8 +35,11 @@
 #include "polarssl/sha1.h"
 
 #if !defined(POLARSSL_SHA1_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
@@ -151,7 +154,7 @@
         printf( "print mode:  sha1sum <file> <file> ...\n" );
         printf( "check mode:  sha1sum -c <checksum file>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
diff --git a/programs/hash/sha2sum.c b/programs/hash/sha2sum.c
index 52939e4..83124cf 100644
--- a/programs/hash/sha2sum.c
+++ b/programs/hash/sha2sum.c
@@ -1,7 +1,7 @@
 /*
  *  sha2sum demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -35,8 +35,11 @@
 #include "polarssl/sha2.h"
 
 #if !defined(POLARSSL_SHA2_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_SHA2_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
@@ -151,7 +154,7 @@
         printf( "print mode:  sha2sum <file> <file> ...\n" );
         printf( "check mode:  sha2sum -c <checksum file>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c
index f85f028..ab7b9a6 100644
--- a/programs/pkey/dh_client.c
+++ b/programs/pkey/dh_client.c
@@ -1,7 +1,7 @@
 /*
  *  Diffie-Hellman-Merkle key exchange (client side)
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -46,15 +46,18 @@
     !defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_NET_C) ||  \
     !defined(POLARSSL_RSA_C) || !defined(POLARSSL_SHA1_C) ||    \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_AES_C and/or POLARSSL_DHM_C and/or POLARSSL_HAVEGE_C "
            "and/or POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     FILE *f;
 
@@ -71,6 +74,9 @@
     dhm_context dhm;
     aes_context aes;
 
+    ((void) argc);
+    ((void) argv);
+
     memset( &rsa, 0, sizeof( rsa ) );
     memset( &dhm, 0, sizeof( dhm ) );
 
@@ -260,7 +266,7 @@
     rsa_free( &rsa );
     dhm_free( &dhm );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/dh_genprime.c b/programs/pkey/dh_genprime.c
index 410139e..f6ae03f 100644
--- a/programs/pkey/dh_genprime.c
+++ b/programs/pkey/dh_genprime.c
@@ -1,7 +1,7 @@
 /*
  *  Diffie-Hellman-Merkle key exchange (prime generation)
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -43,14 +43,17 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret = 1;
 
@@ -59,6 +62,9 @@
     havege_state hs;
     FILE *fout;
 
+    ((void) argc);
+    ((void) argv);
+
     mpi_init( &G ); mpi_init( &P ); mpi_init( &Q );
     mpi_read_string( &G, 10, GENERATOR );
 
@@ -128,7 +134,7 @@
     printf( "\n  ! Prime-number generation is not available.\n\n" );
 #endif
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c
index 2554b90..de2ce97 100644
--- a/programs/pkey/dh_server.c
+++ b/programs/pkey/dh_server.c
@@ -1,7 +1,7 @@
 /*
  *  Diffie-Hellman-Merkle key exchange (server side)
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -46,15 +46,18 @@
     !defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_NET_C) ||  \
     !defined(POLARSSL_RSA_C) || !defined(POLARSSL_SHA1_C) ||    \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_AES_C and/or POLARSSL_DHM_C and/or POLARSSL_HAVEGE_C "
            "and/or POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     FILE *f;
 
@@ -72,6 +75,9 @@
     dhm_context dhm;
     aes_context aes;
 
+    ((void) argc);
+    ((void) argv);
+
     memset( &rsa, 0, sizeof( rsa ) );
     memset( &dhm, 0, sizeof( dhm ) );
 
@@ -263,7 +269,7 @@
     rsa_free( &rsa );
     dhm_free( &dhm );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/key_app.c b/programs/pkey/key_app.c
index 00a5eff..7d4a1d9 100644
--- a/programs/pkey/key_app.c
+++ b/programs/pkey/key_app.c
@@ -1,7 +1,7 @@
 /*
  *  Key reading application
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -74,8 +74,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||         \
     !defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_X509_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -213,7 +216,7 @@
 
     rsa_free( &rsa );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/mpi_demo.c b/programs/pkey/mpi_demo.c
index 509a4c9..f393f1d 100644
--- a/programs/pkey/mpi_demo.c
+++ b/programs/pkey/mpi_demo.c
@@ -1,7 +1,7 @@
 /*
  *  Simple MPI demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -33,16 +33,22 @@
 #include "polarssl/bignum.h"
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     mpi E, P, Q, N, H, D, X, Y, Z;
 
+    ((void) argc);
+    ((void) argv);
+
     mpi_init( &E ); mpi_init( &P ); mpi_init( &Q ); mpi_init( &N );
     mpi_init( &H ); mpi_init( &D ); mpi_init( &X ); mpi_init( &Y );
     mpi_init( &Z );
@@ -85,7 +91,7 @@
     mpi_free( &H ); mpi_free( &D ); mpi_free( &X ); mpi_free( &Y );
     mpi_free( &Z );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_decrypt.c b/programs/pkey/rsa_decrypt.c
index 384ae92..9e594f8 100644
--- a/programs/pkey/rsa_decrypt.c
+++ b/programs/pkey/rsa_decrypt.c
@@ -1,7 +1,7 @@
 /*
  *  RSA simple decryption program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -36,8 +36,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -58,7 +61,7 @@
     {
         printf( "usage: rsa_decrypt\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -140,7 +143,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_encrypt.c b/programs/pkey/rsa_encrypt.c
index 97243cc..0b54a17 100644
--- a/programs/pkey/rsa_encrypt.c
+++ b/programs/pkey/rsa_encrypt.c
@@ -1,7 +1,7 @@
 /*
  *  RSA simple data encryption program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -37,8 +37,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_HAVEGE_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -62,7 +65,7 @@
     {
         printf( "usage: rsa_encrypt <string of max 100 characters>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -133,7 +136,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_genkey.c b/programs/pkey/rsa_genkey.c
index 0e90ffc..d7158b4 100644
--- a/programs/pkey/rsa_genkey.c
+++ b/programs/pkey/rsa_genkey.c
@@ -1,7 +1,7 @@
 /*
  *  Example RSA key generation program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -42,15 +42,18 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_RSA_C) || !defined(POLARSSL_GENPRIME) ||      \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_RSA_C and/or POLARSSL_GENPRIME and/or "
            "POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret;
     rsa_context rsa;
@@ -58,6 +61,9 @@
     FILE *fpub  = NULL;
     FILE *fpriv = NULL;
 
+    ((void) argc);
+    ((void) argv);
+
     printf( "\n  . Seeding the random number generator..." );
     fflush( stdout );
 
@@ -138,7 +144,7 @@
 
     rsa_free( &rsa );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_sign.c b/programs/pkey/rsa_sign.c
index 1fc13bd..76d0eff 100644
--- a/programs/pkey/rsa_sign.c
+++ b/programs/pkey/rsa_sign.c
@@ -1,7 +1,7 @@
 /*
  *  RSA/SHA-1 signature creation program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -37,8 +37,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_SHA1_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int 5ain( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -59,7 +62,7 @@
     {
         printf( "usage: rsa_sign <filename>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -138,7 +141,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_sign_pss.c b/programs/pkey/rsa_sign_pss.c
index 29de8b6..e33cead 100644
--- a/programs/pkey/rsa_sign_pss.c
+++ b/programs/pkey/rsa_sign_pss.c
@@ -1,7 +1,7 @@
 /*
  *  RSASSA-PSS/SHA-1 signature creation program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -45,8 +45,11 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_RSA_C) || !defined(POLARSSL_SHA1_C) ||        \
     !defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_RSA_C and/or POLARSSL_SHA1_C and/or "
            "POLARSSL_X509_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
@@ -69,7 +72,7 @@
     {
         printf( "usage: rsa_sign_pss <key_file> <filename>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -133,7 +136,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_verify.c b/programs/pkey/rsa_verify.c
index dbe5f84..cd29ef8 100644
--- a/programs/pkey/rsa_verify.c
+++ b/programs/pkey/rsa_verify.c
@@ -1,7 +1,7 @@
 /*
  *  RSA/SHA-1 signature verification program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -37,8 +37,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_SHA1_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -58,7 +61,7 @@
     {
         printf( "usage: rsa_verify <filename>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -141,7 +144,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/pkey/rsa_verify_pss.c b/programs/pkey/rsa_verify_pss.c
index 31cd0df..3c90877 100644
--- a/programs/pkey/rsa_verify_pss.c
+++ b/programs/pkey/rsa_verify_pss.c
@@ -1,7 +1,7 @@
 /*
  *  RSASSA-PSS/SHA-1 signature verification program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -45,8 +45,11 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||      \
     !defined(POLARSSL_SHA1_C) || !defined(POLARSSL_X509_PARSE_C) || \
     !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA1_C and/or POLARSSL_X509_PARSE_C and/or "
            "POLARSSL_FS_IO not defined.\n");
@@ -68,7 +71,7 @@
     {
         printf( "usage: rsa_verify_pss <key_file> <filename>\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "\n" );
 #endif
 
@@ -134,7 +137,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/random/gen_random.c b/programs/random/gen_random.c
index 696df3a..6a7aa3a 100644
--- a/programs/random/gen_random.c
+++ b/programs/random/gen_random.c
@@ -1,7 +1,7 @@
 /**
  *  \brief Generate random data into a file
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -31,8 +31,11 @@
 #include <stdio.h>
 
 #if !defined(POLARSSL_HAVEGE_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_HAVEGE_C not defined.\n");
     return( 0 );
 }
diff --git a/programs/ssl/ssl_client1.c b/programs/ssl/ssl_client1.c
index 2ffe30c..b57fe8d 100644
--- a/programs/ssl/ssl_client1.c
+++ b/programs/ssl/ssl_client1.c
@@ -1,7 +1,7 @@
 /*
  *  SSL client demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -54,15 +54,18 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
     !defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret, len, server_fd;
     unsigned char buf[1024];
@@ -70,6 +73,9 @@
     ssl_context ssl;
     ssl_session ssn;
 
+    ((void) argc);
+    ((void) argv);
+
     /*
      * 0. Initialize the RNG and the session data
      */
@@ -182,7 +188,7 @@
 
     memset( &ssl, 0, sizeof( ssl ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 2eb8cbc..de0af25 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -1,7 +1,7 @@
 /*
  *  SSL client with certificate authentication
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -98,8 +98,11 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
     !defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C not defined.\n");
@@ -458,7 +461,7 @@
 
     memset( &ssl, 0, sizeof( ssl ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c
index e14da8b..411eac1 100644
--- a/programs/ssl/ssl_fork_server.c
+++ b/programs/ssl/ssl_fork_server.c
@@ -1,7 +1,7 @@
 /*
  *  SSL server demonstration program using fork() for handling multiple clients
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -27,7 +27,7 @@
 #define _CRT_SECURE_NO_DEPRECATE 1
 #endif
 
-#ifdef WIN32
+#if defined(_WIN32)
 #include <windows.h>
 #endif
 
@@ -55,17 +55,23 @@
     !defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_SSL_TLS_C) ||  \
     !defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) ||     \
     !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_HAVEGE_C "
            "and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C not defined.\n");
     return( 0 );
 }
-#elif defined(WIN32)
-int main( void )
+#elif defined(_WIN32)
+int main( int argc, char *argv[] )
 {
-    printf("WIN32 defined. This application requires fork() and signals "
+    ((void) argc);
+    ((void) argv);
+
+    printf("_WIN32 defined. This application requires fork() and signals "
            "to work correctly.\n");
     return( 0 );
 }
@@ -192,7 +198,7 @@
     return( 0 );
 }
 
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret, len, cnt = 0, pid;
     int listen_fd;
@@ -205,6 +211,9 @@
     x509_cert srvcert;
     rsa_context rsa;
 
+    ((void) argc);
+    ((void) argv);
+
     signal( SIGCHLD, SIG_IGN );
 
     /*
@@ -450,7 +459,7 @@
 
     memset( &ssl, 0, sizeof( ssl_context ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c
index 2adff52..8034a24 100644
--- a/programs/ssl/ssl_mail_client.c
+++ b/programs/ssl/ssl_mail_client.c
@@ -1,7 +1,7 @@
 /*
  *  SSL client for SMTP servers
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -103,8 +103,11 @@
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_HAVEGE_C) ||   \
     !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
     !defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C not defined.\n");
@@ -789,7 +792,7 @@
 
     memset( &ssl, 0, sizeof( ssl ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c
index 6f427dd..1c6fec2 100644
--- a/programs/ssl/ssl_server.c
+++ b/programs/ssl/ssl_server.c
@@ -1,7 +1,7 @@
 /*
  *  SSL server demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -27,7 +27,7 @@
 #define _CRT_SECURE_NO_DEPRECATE 1
 #endif
 
-#ifdef WIN32
+#if defined(_WIN32)
 #include <windows.h>
 #endif
 
@@ -118,7 +118,7 @@
         prv = cur;
         cur = cur->next;
 
-        if( ssl->timeout != 0 && t - prv->start > ssl->timeout )
+        if( ssl->timeout != 0 && (int) ( t - prv->start ) > ssl->timeout )
             continue;
 
         if( ssl->session->ciphersuite != prv->ciphersuite ||
@@ -144,7 +144,7 @@
 
     while( cur != NULL )
     {
-        if( ssl->timeout != 0 && t - cur->start > ssl->timeout )
+        if( ssl->timeout != 0 && (int) ( t - cur->start ) > ssl->timeout )
             break; /* expired, reuse this slot */
 
         if( memcmp( ssl->session->id, cur->id, cur->length ) == 0 )
@@ -174,15 +174,18 @@
     !defined(POLARSSL_HAVEGE_C) || !defined(POLARSSL_SSL_TLS_C) ||  \
     !defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) ||   \
     !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_HAVEGE_C "
            "and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret, len;
     int listen_fd;
@@ -195,6 +198,9 @@
     x509_cert srvcert;
     rsa_context rsa;
 
+    ((void) argc);
+    ((void) argv);
+
     /*
      * 1. Load the certificates and private RSA key
      */
@@ -293,7 +299,24 @@
     /*
      * 3. Wait until a client connects
      */
-#ifdef WIN32
+#if defined(_WIN32_WCE)
+    {
+        SHELLEXECUTEINFO sei;
+
+        ZeroMemory( &sei, sizeof( SHELLEXECUTEINFO ) );
+
+        sei.cbSize = sizeof( SHELLEXECUTEINFO );
+        sei.fMask = 0;
+        sei.hwnd = 0;
+        sei.lpVerb = _T( "open" );
+        sei.lpFile = _T( "https://localhost:4433/" );
+        sei.lpParameters = NULL;
+        sei.lpDirectory = NULL;
+        sei.nShow = SW_SHOWNORMAL;
+
+        ShellExecuteEx( &sei );
+    }
+#elif defined(_WIN32)
     ShellExecute( NULL, "open", "https://localhost:4433/",
                   NULL, NULL, SW_SHOWNORMAL );
 #endif
@@ -419,7 +442,7 @@
 
     memset( &ssl, 0, sizeof( ssl_context ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index db4511e..091a9cf 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -1,7 +1,7 @@
 /*
  *  Benchmark demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -58,13 +58,16 @@
 unsigned char buf[BUFSIZE];
 
 #if !defined(POLARSSL_TIMING_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_TIMING_C not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int keysize;
     unsigned long i, j, tsc;
@@ -87,6 +90,9 @@
     rsa_context rsa;
 #endif
 
+    ((void) argc);
+    ((void) argv);
+
     memset( buf, 0xAA, sizeof( buf ) );
 
     printf( "\n" );
@@ -363,7 +369,7 @@
 
     printf( "\n" );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index 508d39d..c3cebeb 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -1,7 +1,7 @@
 /*
  *  Self-test demonstration program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -144,7 +144,7 @@
     if( v != 0 )
     {
         printf( "  [ All tests passed ]\n\n" );
-#ifdef WIN32
+#if defined(_WIN32)
         printf( "  Press Enter to exit this program.\n" );
         fflush( stdout ); getchar();
 #endif
diff --git a/programs/test/ssl_cert_test.c b/programs/test/ssl_cert_test.c
index 1e5126b..57ea32c 100644
--- a/programs/test/ssl_cert_test.c
+++ b/programs/test/ssl_cert_test.c
@@ -1,7 +1,7 @@
 /*
  *  SSL certificate functionality tests
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -67,20 +67,26 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_X509_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
 #else
-int main( void )
+int main( int argc, char *argv[] )
 {
     int ret, i;
     x509_cert cacert;
     x509_crl crl;
     char buf[10240];
 
+    ((void) argc);
+    ((void) argv);
+
     memset( &cacert, 0, sizeof( x509_cert ) );
     memset( &crl, 0, sizeof( x509_crl ) );
 
@@ -236,7 +242,7 @@
     x509_free( &cacert );
     x509_crl_free( &crl );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/test/ssl_test.c b/programs/test/ssl_test.c
index 643b1e1..683963c 100644
--- a/programs/test/ssl_test.c
+++ b/programs/test/ssl_test.c
@@ -1,7 +1,7 @@
 /*
  *  SSL/TLS stress testing program
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -127,8 +127,11 @@
     !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_SRV_C) || \
     !defined(POLARSSL_SSL_CLI_C) || !defined(POLARSSL_NET_C) ||     \
     !defined(POLARSSL_RSA_C)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
            "POLARSSL_SSL_CLI_C and/or POLARSSL_NET_C and/or "
@@ -584,7 +587,7 @@
 
 exit:
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/wince_main.c b/programs/wince_main.c
new file mode 100644
index 0000000..946569e
--- /dev/null
+++ b/programs/wince_main.c
@@ -0,0 +1,49 @@
+/*

+ *  Windows CE console application entry point

+ *

+ *  Copyright (C) 2006-2011, Brainspark B.V.

+ *

+ *  This file is part of PolarSSL (http://www.polarssl.org)

+ *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>

+ *

+ *  All rights reserved.

+ *

+ *  This program is free software; you can redistribute it and/or modify

+ *  it under the terms of the GNU General Public License as published by

+ *  the Free Software Foundation; either version 2 of the License, or

+ *  (at your option) any later version.

+ *

+ *  This program is distributed in the hope that it will be useful,

+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of

+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ *  GNU General Public License for more details.

+ *

+ *  You should have received a copy of the GNU General Public License along

+ *  with this program; if not, write to the Free Software Foundation, Inc.,

+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+ */

+

+#if defined(_WIN32_WCE)

+

+#include <windows.h>

+

+extern int main( int, const char ** );

+

+int _tmain( int argc, _TCHAR* targv[] )

+{

+    char **argv;

+    int i;

+

+    argv = ( char ** ) calloc( argc, sizeof( char * ) );

+

+    for ( i = 0; i < argc; i++ ) {

+        size_t len;

+        len = _tcslen( targv[i] ) + 1;

+        argv[i] = ( char * ) calloc( len, sizeof( char ) );

+        wcstombs( argv[i], targv[i], len );

+    }

+

+    return main( argc, argv );

+}

+

+#endif  /* defined(_WIN32_WCE) */

diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c
index 1ded9dd..fca8bc6 100644
--- a/programs/x509/cert_app.c
+++ b/programs/x509/cert_app.c
@@ -1,7 +1,7 @@
 /*
  *  Certificate reading application
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -83,8 +83,11 @@
     !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
     !defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C) ||         \
     !defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_HAVEGE_C and/or "
            "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
            "POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
@@ -295,7 +298,7 @@
 
     memset( &ssl, 0, sizeof( ssl ) );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif
diff --git a/programs/x509/crl_app.c b/programs/x509/crl_app.c
index b5c6c79..fae4217 100644
--- a/programs/x509/crl_app.c
+++ b/programs/x509/crl_app.c
@@ -1,7 +1,7 @@
 /*
  *  CRL reading application
  *
- *  Copyright (C) 2006-2010, Brainspark B.V.
+ *  Copyright (C) 2006-2011, Brainspark B.V.
  *
  *  This file is part of PolarSSL (http://www.polarssl.org)
  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -65,8 +65,11 @@
 
 #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) ||  \
     !defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_FS_IO)
-int main( void )
+int main( int argc, char *argv[] )
 {
+    ((void) argc);
+    ((void) argv);
+
     printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_X509_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
@@ -156,7 +159,7 @@
 exit:
     x509_crl_free( &crl );
 
-#ifdef WIN32
+#if defined(_WIN32)
     printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif