From 17f389bbbfccf057a8bc04084ed068c4b368e751 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sat, 11 Sep 1999 17:54:18 +0000 Subject: [PATCH] Initial support for MacOS. This will soon be complemented with MacOS specific source code files and INSTALL.MacOS. I (Andy) have decided to get rid of a number of #include . I've verified it's ok (both by examining /usr/include/*.h and compiling) on a number of Unix platforms. Unfortunately I don't have Windows box to verify this on. I really appreciate if somebody could try to compile it and contact me a.s.a.p. in case a problem occurs. Submitted by: Roy Wood Reviewed by: Andy Polyakov --- crypto/asn1/a_digest.c | 7 +++++-- crypto/asn1/a_sign.c | 7 +++++-- crypto/asn1/a_verify.c | 7 +++++-- crypto/bio/bss_sock.c | 3 +-- crypto/des/enc_read.c | 4 ++-- crypto/des/read_pwd.c | 13 +++++++++++-- crypto/rand/md_rand.c | 1 - crypto/rand/rand_lib.c | 1 - crypto/rand/randfile.c | 22 +++++++++++++++++----- crypto/x509/by_dir.c | 12 ++++++++++-- crypto/x509/by_file.c | 2 -- crypto/x509/x509_cmp.c | 2 -- crypto/x509/x509_d2.c | 2 -- crypto/x509/x509_def.c | 2 -- crypto/x509/x509_txt.c | 1 - crypto/x509/x509_vfy.c | 4 +--- e_os.h | 22 ++++++++++++++++++++++ ssl/ssl_cert.c | 14 ++++++++++++-- 18 files changed, 91 insertions(+), 35 deletions(-) diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 8c45add557..c838f60b46 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -58,10 +58,13 @@ #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + #include #include #include diff --git a/crypto/asn1/a_sign.c b/crypto/asn1/a_sign.c index 57595692e5..eed7faaccb 100644 --- a/crypto/asn1/a_sign.c +++ b/crypto/asn1/a_sign.c @@ -58,10 +58,13 @@ #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + #include #include #include diff --git a/crypto/asn1/a_verify.c b/crypto/asn1/a_verify.c index 6383d2c698..2f4892f669 100644 --- a/crypto/asn1/a_verify.c +++ b/crypto/asn1/a_verify.c @@ -58,10 +58,13 @@ #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + #include #include #include diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c index d336b99fe8..1b8d04002d 100644 --- a/crypto/bio/bss_sock.c +++ b/crypto/bio/bss_sock.c @@ -163,8 +163,7 @@ static int fd_free(BIO *a) if (a->init) { #ifndef BIO_FD - shutdown(a->num,2); - closesocket(a->num); + SHUTDOWN2(a->num); #else /* BIO_FD */ close(a->num); #endif diff --git a/crypto/des/enc_read.c b/crypto/des/enc_read.c index 694970ccd2..7399ff7269 100644 --- a/crypto/des/enc_read.c +++ b/crypto/des/enc_read.c @@ -147,7 +147,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched, /* first - get the length */ while (net_num < HDRSIZE) { - i=read(fd,&(net[net_num]),HDRSIZE-net_num); + i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif @@ -169,7 +169,7 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched, net_num=0; while (net_num < rnum) { - i=read(fd,&(net[net_num]),rnum-net_num); + i=read(fd,(void *)&(net[net_num]),rnum-net_num); #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif diff --git a/crypto/des/read_pwd.c b/crypto/des/read_pwd.c index fed49652c0..a262f98ed7 100644 --- a/crypto/des/read_pwd.c +++ b/crypto/des/read_pwd.c @@ -123,7 +123,7 @@ #undef SGTTY #endif -#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) +#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(MAC_OS_pre_X) #undef TERMIOS #undef TERMIO #define SGTTY @@ -153,7 +153,7 @@ #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #endif -#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) +#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X) #include #endif @@ -174,6 +174,15 @@ struct IOSB { }; #endif +#ifdef MAC_OS_pre_X +/* + * This one needs work. As a matter of fact the code is unoperational + * and this is only a trick to get it compiled. + * + */ +#define TTY_STRUCT int +#endif + #ifndef NX509_SIG #define NX509_SIG 32 #endif diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index 6bd1960e1d..72c557b19b 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -57,7 +57,6 @@ */ #include -#include #include #include diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 34c6d5b968..0f96e166e5 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -57,7 +57,6 @@ */ #include -#include #include #include diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 6829d4ec37..e1ed4e3a98 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -60,12 +60,18 @@ #include #include #include -#include -#include -#include #include "openssl/e_os.h" +#ifndef NO_SYS_TYPES_H +# include +#endif +#ifdef MAC_OS_pre_X +# include +#else +# include +#endif + #include #undef BUFSIZE @@ -116,19 +122,25 @@ int RAND_write_file(const char *file) FILE *out; int n; - /* Under VMS, fopen(file, "wb") will craete a new version of the + /* Under VMS, fopen(file, "wb") will create a new version of the same file. This is not good, so let's try updating an existing one, and create file only if it doesn't already exist. This should be completely harmless on system that have no file versions. -- Richard Levitte */ out=fopen(file,"rb+"); - if (out == NULL && errno == ENOENT) + if (out == NULL +#ifdef ENOENT + && errno == ENOENT +#endif + ) { errno = 0; out=fopen(file,"wb"); } if (out == NULL) goto err; +#ifndef NO_CHMOD chmod(file,0600); +#endif n=RAND_DATA; for (;;) { diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 734e39ac77..3e1565ea5b 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -59,10 +59,18 @@ #include #include #include -#include -#include #include "cryptlib.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif +#ifdef MAC_OS_pre_X +# include +#else +# include +#endif + #include #include diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c index 00ee5e8bbc..3c31de728c 100644 --- a/crypto/x509/by_file.c +++ b/crypto/x509/by_file.c @@ -59,8 +59,6 @@ #include #include #include -#include -#include #include "cryptlib.h" #include diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 9a93bae3ff..be29979092 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -57,8 +57,6 @@ */ #include -#include -#include #include "cryptlib.h" #include #include diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c index 3e7ec5b432..5f0da4c9f2 100644 --- a/crypto/x509/x509_d2.c +++ b/crypto/x509/x509_d2.c @@ -57,8 +57,6 @@ */ #include -#include -#include #include "cryptlib.h" #include #include diff --git a/crypto/x509/x509_def.c b/crypto/x509/x509_def.c index c4bee71569..e0ac151a76 100644 --- a/crypto/x509/x509_def.c +++ b/crypto/x509/x509_def.c @@ -57,8 +57,6 @@ */ #include -#include -#include #include "cryptlib.h" #include #include diff --git a/crypto/x509/x509_txt.c b/crypto/x509/x509_txt.c index 11a3d2012f..60c48f1248 100644 --- a/crypto/x509/x509_txt.c +++ b/crypto/x509/x509_txt.c @@ -59,7 +59,6 @@ #include #include #include -#include #include "cryptlib.h" #include diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index c72ee4a385..def60ef23e 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -59,11 +59,9 @@ #include #include #include -#include -#include -#include #include "cryptlib.h" +#include #include #include #include diff --git a/e_os.h b/e_os.h index 5eaa3cca1b..61ff56eec7 100644 --- a/e_os.h +++ b/e_os.h @@ -82,6 +82,15 @@ extern "C" { #define DEVRANDOM "/dev/urandom" #endif +#if defined(__MWERKS__) && defined(macintosh) +# if macintosh==1 +# define MAC_OS_pre_X +# define NO_SYS_TYPES_H +# define NO_CHMOD +# define NO_SYSLOG +# endif +#endif + /******************************************************************** The Microsoft section ********************************************************************/ @@ -119,6 +128,12 @@ extern "C" { #define readsocket(s,b,n) recv((s),(b),(n),0) #define writesocket(s,b,n) send((s),(b),(n),0) #define EADDRINUSE WSAEADDRINUSE +#elif MAC_OS_pre_X +#define get_last_socket_error() errno +#define clear_socket_error() errno=0 +#define closesocket(s) MacSocket_close(s) +#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true) +#define writesocket(s,b,n) MacSocket_send((s),(b),(n)) #else #define get_last_socket_error() errno #define clear_socket_error() errno=0 @@ -268,6 +283,13 @@ extern HINSTANCE _hInstance; # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); } # endif +# elif defined(MAC_OS_pre_X) + +# include "MacSocket.h" +# define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c)) +# define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true) +# define SHUTDOWN(fd) MacSocket_close(fd) +# define SHUTDOWN2(fd) MacSocket_close(fd) # else diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 6d2511f76c..a695d042cf 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -105,14 +105,22 @@ */ #include -#include -#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) + +#include "openssl/e_os.h" + +#ifndef NO_SYS_TYPES_H +# include +#endif + +#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X) #include #endif + #ifdef NeXT #include #define dirent direct #endif + #include #include #include @@ -671,6 +679,7 @@ err: #ifndef WIN32 #ifndef VMS /* XXXX This may be fixed in the future */ +#ifndef MAC_OS_pre_X int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, const char *dir) @@ -714,3 +723,4 @@ err: #endif #endif +#endif -- 2.25.1