Initial support for MacOS.
authorAndy Polyakov <appro@openssl.org>
Sat, 11 Sep 1999 17:54:18 +0000 (17:54 +0000)
committerAndy Polyakov <appro@openssl.org>
Sat, 11 Sep 1999 17:54:18 +0000 (17:54 +0000)
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 <sys/types.h>.
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 <roy@centricsystems.ca>
Reviewed by: Andy Polyakov <appro@fy.chalmers.se>

18 files changed:
crypto/asn1/a_digest.c
crypto/asn1/a_sign.c
crypto/asn1/a_verify.c
crypto/bio/bss_sock.c
crypto/des/enc_read.c
crypto/des/read_pwd.c
crypto/rand/md_rand.c
crypto/rand/rand_lib.c
crypto/rand/randfile.c
crypto/x509/by_dir.c
crypto/x509/by_file.c
crypto/x509/x509_cmp.c
crypto/x509/x509_d2.c
crypto/x509/x509_def.c
crypto/x509/x509_txt.c
crypto/x509/x509_vfy.c
e_os.h
ssl/ssl_cert.c

index 8c45add557602d517cf8f4eaa6a29b5752212458..c838f60b46c5d1bee5ee3aca970673e77fa1d54d 100644 (file)
 
 #include <stdio.h>
 #include <time.h>
 
 #include <stdio.h>
 #include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "cryptlib.h"
 
 #include "cryptlib.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/x509.h>
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/x509.h>
index 57595692e5b965478259ae3d6aba328130423c0c..eed7faaccb12850ff8d9c1a1c94363e97338494d 100644 (file)
 
 #include <stdio.h>
 #include <time.h>
 
 #include <stdio.h>
 #include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "cryptlib.h"
 
 #include "cryptlib.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 #include <openssl/bn.h>
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 #include <openssl/bn.h>
 #include <openssl/evp.h>
 #include <openssl/x509.h>
index 6383d2c698d3adffc16d4e18ee081dd5e39ca552..2f4892f669171e1cf452b7b12e1bf78078e703b0 100644 (file)
 
 #include <stdio.h>
 #include <time.h>
 
 #include <stdio.h>
 #include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "cryptlib.h"
 
 #include "cryptlib.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 #include <openssl/bn.h>
 #include <openssl/x509.h>
 #include <openssl/objects.h>
 #include <openssl/bn.h>
 #include <openssl/x509.h>
 #include <openssl/objects.h>
index d336b99fe81af8ea15de32b53d36029edc4e9042..1b8d04002d745fc0cdcdb818f1ed008aad852f14 100644 (file)
@@ -163,8 +163,7 @@ static int fd_free(BIO *a)
                if (a->init)
                        {
 #ifndef BIO_FD
                if (a->init)
                        {
 #ifndef BIO_FD
-                       shutdown(a->num,2);
-                       closesocket(a->num);
+                       SHUTDOWN2(a->num);
 #else                  /* BIO_FD */
                        close(a->num);
 #endif
 #else                  /* BIO_FD */
                        close(a->num);
 #endif
index 694970ccd2a9f5642477659026b5e7c804de262d..7399ff7269837ebf756b0bf2dd3be1fce2203edf 100644 (file)
@@ -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) 
                {
        /* 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
 #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)
                {
        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
 #ifdef EINTR
                if ((i == -1) && (errno == EINTR)) continue;
 #endif
index fed49652c0d866c19e2dccfdf0a03362a873c238..a262f98ed763ec9eab69ee73b7bb7b51a226e431 100644 (file)
 #undef  SGTTY
 #endif
 
 #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
 #undef  TERMIOS
 #undef  TERMIO
 #define SGTTY
 #define TTY_set(tty,data)      ioctl(tty,TIOCSETP,data)
 #endif
 
 #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 <sys/ioctl.h>
 #endif
 
 #include <sys/ioctl.h>
 #endif
 
@@ -174,6 +174,15 @@ struct IOSB {
        };
 #endif
 
        };
 #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.
+ *                                     <appro@fy.chalmers.se>
+ */
+#define TTY_STRUCT int
+#endif
+
 #ifndef NX509_SIG
 #define NX509_SIG 32
 #endif
 #ifndef NX509_SIG
 #define NX509_SIG 32
 #endif
index 6bd1960e1de708564bff78560a41a668874636b7..72c557b19b8dba8b89cbf7fffcfc5e920576c3f9 100644 (file)
@@ -57,7 +57,6 @@
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
 #include <time.h>
 #include <string.h>
 
 #include <time.h>
 #include <string.h>
 
index 34c6d5b9681d38da4dfb496cb9b3759d38239c13..0f96e166e530a9fb8027a43c87a2115803df6ec7 100644 (file)
@@ -57,7 +57,6 @@
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
 #include <time.h>
 #include <openssl/rand.h>
 
 #include <time.h>
 #include <openssl/rand.h>
 
index 6829d4ec37076c13cbbeab7fed59f4a291271b17..e1ed4e3a9812afd035df76c178ecd8d8d094177c 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 
 #include "openssl/e_os.h"
 
 
 #include "openssl/e_os.h"
 
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef MAC_OS_pre_X
+# include <stat.h>
+#else
+# include <sys/stat.h>
+#endif
+
 #include <openssl/rand.h>
 
 #undef BUFSIZE
 #include <openssl/rand.h>
 
 #undef BUFSIZE
@@ -116,19 +122,25 @@ int RAND_write_file(const char *file)
        FILE *out;
        int n;
 
        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+");
           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;
                {
                errno = 0;
                out=fopen(file,"wb");
                }
        if (out == NULL) goto err;
+#ifndef NO_CHMOD
        chmod(file,0600);
        chmod(file,0600);
+#endif
        n=RAND_DATA;
        for (;;)
                {
        n=RAND_DATA;
        for (;;)
                {
index 734e39ac77378c34c1418e60ebd7a72b0bf996e3..3e1565ea5be084a51e64f9402c4297d3cb733444 100644 (file)
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "cryptlib.h"
 
 #include "cryptlib.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef MAC_OS_pre_X
+# include <stat.h>
+#else
+# include <sys/stat.h>
+#endif
+
 #include <openssl/lhash.h>
 #include <openssl/x509.h>
 
 #include <openssl/lhash.h>
 #include <openssl/x509.h>
 
index 00ee5e8bbc4dc54f8aa2bdb13ff75106d20d37f1..3c31de728cfae0c7cbe1fd92cc1dda2999110c7f 100644 (file)
@@ -59,8 +59,6 @@
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include "cryptlib.h"
 #include <openssl/lhash.h>
 
 #include "cryptlib.h"
 #include <openssl/lhash.h>
index 9a93bae3ff3ef2bf2758581e97cdd8e0dad5e508..be2997909204b316b4d25930f68217cd58f4aa0a 100644 (file)
@@ -57,8 +57,6 @@
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 #include <openssl/objects.h>
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 #include <openssl/objects.h>
index 3e7ec5b432646407683bbfef4193e20b67335c30..5f0da4c9f2fecd867d0f0e0ff0f34be935033ebc 100644 (file)
@@ -57,8 +57,6 @@
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include "cryptlib.h"
 #include <openssl/crypto.h>
 #include <openssl/x509.h>
 #include "cryptlib.h"
 #include <openssl/crypto.h>
 #include <openssl/x509.h>
index c4bee715698ea0123bd54e6add60e582a20ad76d..e0ac151a768c515b67a14e76b30a795294e7a7e2 100644 (file)
@@ -57,8 +57,6 @@
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include "cryptlib.h"
 #include <openssl/crypto.h>
 #include <openssl/x509.h>
 #include "cryptlib.h"
 #include <openssl/crypto.h>
 #include <openssl/x509.h>
index 11a3d2012fb3175956626ba2d78ec492af966957..60c48f1248f9ea54da645ea6efb4184d51df16db 100644 (file)
@@ -59,7 +59,6 @@
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
-#include <sys/types.h>
 
 #include "cryptlib.h"
 #include <openssl/lhash.h>
 
 #include "cryptlib.h"
 #include <openssl/lhash.h>
index c72ee4a3855fdfdd46341295957addaf6ca08a23..def60ef23e715f7d39a6cd6a0b9b0b8071e83280 100644 (file)
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
 #include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 
-#include <openssl/crypto.h>
 #include "cryptlib.h"
 #include "cryptlib.h"
+#include <openssl/crypto.h>
 #include <openssl/lhash.h>
 #include <openssl/buffer.h>
 #include <openssl/evp.h>
 #include <openssl/lhash.h>
 #include <openssl/buffer.h>
 #include <openssl/evp.h>
diff --git a/e_os.h b/e_os.h
index 5eaa3cca1bdfdc7f5c3b6271f8c1f7a78fd59ce2..61ff56eec7ef78595fdbb2180376aed4cf1b9773 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -82,6 +82,15 @@ extern "C" {
 #define DEVRANDOM "/dev/urandom"
 #endif
 
 #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
  ********************************************************************/
 /********************************************************************
  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
 #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
 #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
 
 #      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
 
 
 #  else
 
index 6d2511f76c27c1e0f60d1720ba6887a46be968e3..a695d042cf2e9f8e15ced5b840a4901fe69e905e 100644 (file)
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-#include <sys/types.h>
-#if !defined(WIN32) && !defined(VSM) && !defined(NeXT)
+
+#include "openssl/e_os.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X)
 #include <dirent.h>
 #endif
 #include <dirent.h>
 #endif
+
 #ifdef NeXT
 #include <sys/dir.h>
 #define dirent direct
 #endif
 #ifdef NeXT
 #include <sys/dir.h>
 #define dirent direct
 #endif
+
 #include <openssl/objects.h>
 #include <openssl/bio.h>
 #include <openssl/pem.h>
 #include <openssl/objects.h>
 #include <openssl/bio.h>
 #include <openssl/pem.h>
@@ -671,6 +679,7 @@ err:
 
 #ifndef WIN32
 #ifndef VMS                    /* XXXX This may be fixed in the future */
 
 #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)
 
 int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
                                       const char *dir)
@@ -714,3 +723,4 @@ err:
 
 #endif
 #endif
 
 #endif
 #endif
+#endif