Backport http://cvs.openssl.org/chngview?cn=17710 from HEAD.
authorAndy Polyakov <appro@openssl.org>
Tue, 30 Dec 2008 13:30:57 +0000 (13:30 +0000)
committerAndy Polyakov <appro@openssl.org>
Tue, 30 Dec 2008 13:30:57 +0000 (13:30 +0000)
PR: 1230

crypto/bio/bss_file.c
crypto/des/enc_read.c
crypto/des/enc_writ.c
crypto/ocsp/ocsp_ht.c
crypto/rand/randfile.c
crypto/ui/ui_openssl.c
crypto/x509/by_dir.c
e_os.h
engines/e_aep.c

index 4df9927c437e0112ad0abac99113b2639fd97a2f..9ad46fa081dbedb40c7eba675eb9d53797e958e1 100644 (file)
@@ -279,7 +279,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
 #endif
                {
 #if defined(OPENSSL_SYS_WINDOWS)
-               int fd = fileno((FILE*)ptr);
+               int fd = _fileno((FILE*)ptr);
                if (num & BIO_FP_TEXT)
                        _setmode(fd,_O_TEXT);
                else
index c70fb686b8b02b26815fd950279f9b39493eae60..e7da2ec66b08eaedf92af18d43a310801f47acdc 100644 (file)
@@ -147,7 +147,11 @@ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
        /* first - get the length */
        while (net_num < HDRSIZE) 
                {
+#ifndef _WIN32
                i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
+#else
+               i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
+#endif
 #ifdef EINTR
                if ((i == -1) && (errno == EINTR)) continue;
 #endif
index af5b8c2349bba80fd02dba4d0314fb0e3d3819aa..c2f032c9a6af9f66b37badcc22fe52df13d64e34 100644 (file)
@@ -153,7 +153,11 @@ int DES_enc_write(int fd, const void *_buf, int len,
                {
                /* eay 26/08/92 I was not doing writing from where we
                 * got up to. */
+#ifndef _WIN32
                i=write(fd,(void *)&(outbuf[j]),outnum-j);
+#else
+               i=_write(fd,(void *)&(outbuf[j]),outnum-j);
+#endif
                if (i == -1)
                        {
 #ifdef EINTR
index 4a04ad9aa648f8eebce61db684f2d216e22a3677..6abb30b2c076d3f17a7fad6c1abb1757217d0c9b 100644 (file)
  *
  */
 
-#include <openssl/asn1.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+#include "e_os.h"
+#include <openssl/asn1.h>
 #include <openssl/ocsp.h>
 #include <openssl/err.h>
 #include <openssl/buffer.h>
index 61fb3e98099b21ca19e762d35e8a9195b780864c..d108353bbc26366c4740b856e885781794333893 100644 (file)
 # include <sys/stat.h>
 #endif
 
+#ifdef _WIN32
+#define stat   _stat
+#define chmod  _chmod
+#define open   _open
+#define fdopen _fdopen
+#endif
+
 #undef BUFSIZE
 #define BUFSIZE        1024
 #define RAND_DATA 1024
index 1f23a45a339bc018eb27cb501076e5440f9bb536..ef930bf2476e9c4fae856697750709add1241933 100644 (file)
@@ -677,6 +677,8 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
                size--;
 #ifdef WIN16TTY
                i=_inchar();
+#elif defined(_WIN32)
+               i=_getch();
 #else
                i=getch();
 #endif
index 37f9a48206932faf27492ea2f06a72682c049429..341e0ba6a41da3d2f85fafdc5c92e4f47dc51e5d 100644 (file)
 #include <openssl/lhash.h>
 #include <openssl/x509.h>
 
+#ifdef _WIN32
+#define stat   _stat
+#endif
+
 typedef struct lookup_dir_st
        {
        BUF_MEM *buffer;
diff --git a/e_os.h b/e_os.h
index acc6a15eb7c753885972f1b48c2812e797a99248..9c5c6fdb92f27202cbd4381ea4b847f77212f7af 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -269,6 +269,7 @@ extern "C" {
 #      define _WIN32_WINNT 0x0400
 #    endif
 #    include <windows.h>
+#    include <stdio.h>
 #    include <stddef.h>
 #    include <errno.h>
 #    include <string.h>
@@ -284,13 +285,38 @@ static unsigned int _strlen31(const char *str)
 #    endif
 #    include <malloc.h>
 #    if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
-       /* compensate for bug is VC6 ctype.h */
+       /* compensate for bug in VC6 ctype.h */
 #      undef isspace
 #      undef isdigit
 #      undef isalnum
 #      undef isupper
 #      undef isxdigit
 #    endif
+#    if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
+#      if _MSC_VER>=1300
+#        undef stdin
+#        undef stdout
+#        undef stderr
+         FILE *__iob_func();
+#        define stdin  (&__iob_func()[0])
+#        define stdout (&__iob_func()[1])
+#        define stderr (&__iob_func()[2])
+#      elif defined(I_CAN_LIVE_WITH_LNK4049)
+#        undef stdin
+#        undef stdout
+#        undef stderr
+         /* pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
+          * or in other words with /MD. Declaring implicit import, i.e.
+          * with _imp_ prefix, works correctly with all compiler options,
+          * but without /MD results in LINK warning LNK4049:
+          * 'locally defined symbol "__iob" imported'.
+          */
+         extern FILE *_imp___iob;
+#        define stdin  (&_imp___iob[0])
+#        define stdout (&_imp___iob[1])
+#        define stderr (&_imp___iob[2])
+#      endif
+#    endif
 #  endif
 #  include <io.h>
 #  include <fcntl.h>
index ffdc354cdcf99053845c4f3efa1545185ede8825..e24e4b424e40ac6ad1bc7bd0bf1d475428746b93 100644 (file)
@@ -867,10 +867,12 @@ static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
 
        CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
 
-#ifndef NETWARE_CLIB
-       curr_pid = getpid();
-#else
+#ifdef NETWARE_CLIB
        curr_pid = GetThreadID();
+#elif defined(_WIN32)
+       curr_pid = _getpid();
+#else
+       curr_pid = getpid();
 #endif
 
        /*Check if this is the first time this is being called from the current