DJGPP adjustments
authorRichard Levitte <levitte@openssl.org>
Tue, 10 May 2016 12:41:19 +0000 (14:41 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 12 May 2016 20:10:55 +0000 (22:10 +0200)
* Configure: Replaced -DTERMIO by -DTERMIOS in CFLAGS.

* crypto/bio/bss_dgram.c [WATT32]: Remove obsolete redefinition of
  function names: sock_write, sock_read and sock_puts.

* crypto/bio/bss_sock.c [WATT32]: For Watt-32 2.2.11 sock_write,
  sock_read and sock_puts are redefined to their private names so
  their names must be undefined first before they can be redefined
  again.

* crypto/bio/bss_file.c (file_fopen) [__DJGPP__]: Make a copy of the
  passed file name and replace the leading dots in the dirname part
  and the basname part of the file name, unless LFN is supported.

* e_os.h [__DJGPP__]: Undefine macro DEVRANDOM_EGD. Neither MS-DOS nor
  FreeDOS provide 'egd' sockets.
  New macro HAS_LFN_SUPPORT checks if underlying file system supports
  long file names or not.
  Include sys/un.h.
  Define WATT32_NO_OLDIES.

* INSTALL.DJGPP: Update URL of WATT-32 library.

Submitted by Juan Manuel Guerrero <juan.guerrero@gmx.de>

RT#4217

Reviewed-by: Andy Polyakov <appro@openssl.org>
INSTALL.DJGPP
crypto/bio/bss_dgram.c
crypto/bio/bss_file.c
crypto/bio/bss_sock.c
e_os.h

index e1ec6760389ec85c1880b83bc5eb661de4471e63..4fd94e44db128ee12174887cc860c3623e053f53 100644 (file)
@@ -19,7 +19,7 @@
  files to download, see the DJGPP "ZIP PICKER" page at
  "http://www.delorie.com/djgpp/zip-picker.html". You also need to have
  the WATT-32 networking package installed before you try to compile
- OpenSSL. This can be obtained from "http://www.bgnett.no/~giva/".
+ OpenSSL. This can be obtained from "http://www.watt-32.net/".
  The Makefile assumes that the WATT-32 code is in the directory
  specified by the environment variable WATT_ROOT. If you have watt-32
  in directory "watt32" under your main DJGPP directory, specify
index cf2f9f66b5346fd45dc8146f85c68cbe23051ed4..e6d74e48679098ac82ec881a88826752f749a52e 100644 (file)
          ((a)->s6_addr32[2] == htonl(0x0000ffff)))
 # endif
 
-# ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
-#  define sock_read  SockRead
-#  define sock_puts  SockPuts
-# endif
-
 static int dgram_write(BIO *h, const char *buf, int num);
 static int dgram_read(BIO *h, char *buf, int size);
 static int dgram_puts(BIO *h, const char *str);
index a37e89d935b2b281c950b0c2442fa71169cdfb7c..3c056604c8598d0109e1395f3ad7a35c951a4641 100644 (file)
@@ -154,6 +154,36 @@ static FILE *file_fopen(const char *filename, const char *mode)
     } else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) {
         file = fopen(filename, mode);
     }
+#  elif defined(__DJGPP__)
+    {
+        char *newname = NULL;
+
+        if (!HAS_LFN_SUPPORT(filename)) {
+            char *iterator;
+            char lastchar;
+
+            newname = OPENSSL_malloc(strlen(filename) + 1);
+            if (newname == NULL)
+                return NULL;
+
+            for(iterator = newname, lastchar = '\0';
+                *filename; filename++, iterator++) {
+                if (lastchar == '/' && filename[0] == '.'
+                    && filename[1] != '.' && filename[1] != '/') {
+                    /* Leading dots are not permitted in plain DOS. */
+                    *iterator = '_';
+                } else {
+                    *iterator = *filename;
+                }
+                lastchar = *filename;
+            }
+            *iterator = '\0';
+            filename = newname;
+        }
+        file = fopen(filename, mode);
+
+        OPENSSL_free(newname);
+    }
 #  else
     file = fopen(filename, mode);
 #  endif
index c1f76a24a799533fcb5711a5b1245466b25ac6ae..c4e263dabf0f4d792466ebded9439ee1d14ed399 100644 (file)
 # include <openssl/bio.h>
 
 # ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
+/* Watt-32 uses same names */
+#  undef sock_write
+#  undef sock_read
+#  undef sock_puts
+#  define sock_write SockWrite
 #  define sock_read  SockRead
 #  define sock_puts  SockPuts
 # endif
diff --git a/e_os.h b/e_os.h
index eaa9396b88eb9c27559d1abdc47d682a65d55694..0166d7907b8c03400a772d8cd686694a215784ed 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -151,6 +151,7 @@ extern "C" {
 #  define writesocket(s,b,n)      send((s),(b),(n),0)
 # elif defined(__DJGPP__)
 #  define WATT32
+#  define WATT32_NO_OLDIES
 #  define get_last_socket_error() errno
 #  define clear_socket_error()    errno=0
 #  define closesocket(s)          close_s(s)
@@ -185,11 +186,14 @@ extern "C" {
 #   include <unistd.h>
 #   include <sys/stat.h>
 #   include <sys/socket.h>
+#   include <sys/un.h>
 #   include <tcp.h>
 #   include <netdb.h>
 #   define _setmode setmode
 #   define _O_TEXT O_TEXT
 #   define _O_BINARY O_BINARY
+#   define HAS_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+#   undef DEVRANDOM_EGD  /*  Neither MS-DOS nor FreeDOS provide 'egd' sockets.  */
 #   undef DEVRANDOM
 #   define DEVRANDOM "/dev/urandom\x24"
 #  endif                        /* __DJGPP__ */