summaryrefslogtreecommitdiff
path: root/win32/win32sck.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-04-15 00:00:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-04-15 00:00:00 +1200
commit137443ea0a858c43f5a720730cac6209a7d41948 (patch)
treeea114bc1f5281a6ec91ebc67e34ed7f30571daee /win32/win32sck.c
parent683d4eee6f3b749aec29cc849f45404c6acda85e (diff)
downloadperl-137443ea0a858c43f5a720730cac6209a7d41948.tar.gz
[inseparable changes from patch from perl-5.003_97d to perl-5.003_97e]perl-5.003_97e
CORE LANGUAGE CHANGES Subject: New operator: sysseek() From: Chip Salzenberg <chip@perl.com> Files: doio.c ext/Opcode/Makefile.PL ext/Opcode/Opcode.pm global.sym keywords.pl opcode.pl pod/perldelta.pod pod/perlfunc.pod pp_sys.c t/op/sysio.t toke.c Subject: Allow recursive substitution again From: Chip Salzenberg <chip@perl.com> Files: pod/perldelta.pod pod/perldiag.pod pp_hot.c CORE PORTABILITY Subject: Use size_t for socket size parameters of GNU libc From: Chip Salzenberg <chip@perl.com> Files: doio.c pp_sys.c Subject: Win32 update (four patches) From: Gurusamy Sarathy <gsar@engin.umich.edu> Files: MANIFEST README.win32 dosish.h ext/SDBM_File/Makefile.PL ext/SDBM_File/sdbm/Makefile.PL ext/SDBM_File/sdbm/sdbm.c ext/SDBM_File/sdbm/sdbm.h lib/ExtUtils/MM_Unix.pm perl.c utils/perlbug.PL utils/perldoc.PL win32/Makefile win32/TEST win32/config.H win32/config.w32 win32/config_h.PL win32/config_sh.PL win32/perllib.c win32/runperl.c win32/win32.c win32/win32io.c win32/win32sck.c DOCUMENTATION Subject: Add CGI to perldelta.pod and improve its description in MANIFEST From: Chip Salzenberg <chip@perl.com> Files: MANIFEST pod/perldelta.pod Subject: Describe probs with majordomo 1.94.1 From: Chip Salzenberg <chip@perl.com> Files: pod/perldelta.pod Subject: Fix description of /\G/g From: Chip Salzenberg <chip@perl.com> Files: pod/perlop.pod Subject: Mention '...' operator in precedence table Date: Sun, 13 Apr 1997 11:24:16 -0600 From: Tom Christiansen <tchrist@perl.com> Files: pod/perlop.pod private-msgid: 199704131724.LAA23120@jhereg.perl.com OTHER CORE CHANGES Subject: New API function: perl_eval_pv() Date: Mon, 14 Apr 1997 17:13:41 -0400 From: Doug MacEachern <dougm@opengroup.org> Files: perl.c pod/perlcall.pod pod/perldelta.pod pod/perlembed.pod pod/perlguts.pod proto.h private-msgid: 199704142113.RAA06823@postman.osf.org Subject: Fix C< s//whatever/ >, which reuses old pattern From: Chip Salzenberg <chip@perl.com> Files: pp_hot.c regexec.c
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r--win32/win32sck.c149
1 files changed, 25 insertions, 124 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c
index 7acb02871c..45f7ac1cbf 100644
--- a/win32/win32sck.c
+++ b/win32/win32sck.c
@@ -22,13 +22,8 @@
#ifdef USE_SOCKETS_AS_HANDLES
/* thanks to Beverly Brown (beverly@datacube.com) */
-# if defined(_WIN32) && !defined(WIN95_OSFHANDLE_FIXED) && defined(_M_IX86)
-/*# define OPEN_SOCKET(x) _patch_open_osfhandle(x, _O_RDWR | _O_BINARY) */
-# define OPEN_SOCKET(x) _open_osfhandle(x,_O_RDWR|_O_BINARY)
-# else
-# define OPEN_SOCKET(x) _open_osfhandle(x,_O_RDWR|_O_BINARY)
-# endif
-# define TO_SOCKET(x) _get_osfhandle(x)
+#define OPEN_SOCKET(x) _open_osfhandle(x,_O_RDWR|_O_BINARY)
+#define TO_SOCKET(x) _get_osfhandle(x)
#else
@@ -37,123 +32,9 @@
#endif /* USE_SOCKETS_AS_HANDLES */
-/*
- * This is a clone of fdopen so that we can handle the version of
- * sockets that NT gets to use.
- *
- * The problem is that sockets are not real file handles and
- * cannot be fdopen'ed. This causes problems in the do_socket
- * routine in doio.c, since it tries to create two file pointers
- * for the socket just created. We'll fake out an fdopen and see
- * if we can prevent perl from trying to do stdio on sockets.
- */
-
-#if defined(_WIN32) && !defined(WIN95_OSFHANDLE_FIXED) && defined(_M_IX86)
-
-# ifdef __cplusplus
-#define EXT_C_FUNC extern "C"
-# else
-#define EXT_C_FUNC extern
-# endif
-
-EXT_C_FUNC int __cdecl _alloc_osfhnd(void);
-EXT_C_FUNC int __cdecl _set_osfhnd(int fh, long value);
-EXT_C_FUNC void __cdecl _lock_fhandle(int);
-EXT_C_FUNC void __cdecl _unlock_fhandle(int);
-EXT_C_FUNC void __cdecl _unlock(int);
-EXT_C_FUNC struct servent* win32_savecopyservent(struct servent*d,
- struct servent*s, const char *proto);
-
-#if (_MSC_VER >= 1000)
-typedef struct {
- long osfhnd; /* underlying OS file HANDLE */
- char osfile; /* attributes of file (e.g., open in text mode?) */
- char pipech; /* one char buffer for handles opened on pipes */
-#if defined (_MT) && !defined (DLL_FOR_WIN32S)
- int lockinitflag;
- CRITICAL_SECTION lock;
-#endif /* defined (_MT) && !defined (DLL_FOR_WIN32S) */
-} ioinfo;
-
-EXT_C_FUNC ioinfo * __pioinfo[];
-
-#define IOINFO_L2E 5
-#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
-#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1)))
-#define _osfile(i) (_pioinfo(i)->osfile)
-#else /* (_MSC_VER >= 1000) */
- extern char _osfile[];
-#endif /* (_MSC_VER >= 1000) */
-
-#define FOPEN 0x01 /* file handle open */
-#define FAPPEND 0x20 /* file handle opened O_APPEND */
-#define FDEV 0x40 /* file handle refers to device */
-#define FTEXT 0x80 /* file handle is in text mode */
-
-#define _STREAM_LOCKS 26 /* Table of stream locks */
-#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_NSTREAM_-1) /* Last stream lock */
-#define _FH_LOCKS (_LAST_STREAM_LOCK+1) /* Table of fh locks */
-
-/***
-*int _patch_open_osfhandle(long osfhandle, int flags) - open C Runtime file handle
-*
-*Purpose:
-* This function allocates a free C Runtime file handle and associates
-* it with the Win32 HANDLE specified by the first parameter. This is a
-* temperary fix for WIN95's brain damage GetFileType() error on socket
-* we just bypass that call for socket
-*
-*Entry:
-* long osfhandle - Win32 HANDLE to associate with C Runtime file handle.
-* int flags - flags to associate with C Runtime file handle.
-*
-*Exit:
-* returns index of entry in fh, if successful
-* return -1, if no free entry is found
-*
-*Exceptions:
-*
-*******************************************************************************/
-
-int __cdecl
-_patch_open_osfhandle(long osfhandle, int flags)
-{
- int fh;
- char fileflags; /* _osfile flags */
-
- /* copy relevant flags from second parameter */
- fileflags = FDEV;
-
- if(flags & _O_APPEND)
- fileflags |= FAPPEND;
-
- if(flags & _O_TEXT)
- fileflags |= FTEXT;
-
- /* attempt to allocate a C Runtime file handle */
- if((fh = _alloc_osfhnd()) == -1) {
- errno = EMFILE; /* too many open files */
- _doserrno = 0L; /* not an OS error */
- return -1; /* return error to caller */
- }
-
- /* the file is open. now, set the info in _osfhnd array */
- _set_osfhnd(fh, osfhandle);
-
- fileflags |= FOPEN; /* mark as open */
-
-#if (_MSC_VER >= 1000)
- _osfile(fh) = fileflags; /* set osfile entry */
- _unlock_fhandle(fh);
-#else
- _osfile[fh] = fileflags; /* set osfile entry */
- _unlock(fh+_FH_LOCKS); /* unlock handle */
-#endif
-
- return fh; /* return handle */
-}
-#endif /* _M_IX86 */
-
+static struct servent* win32_savecopyservent(struct servent*d,
+ struct servent*s,
+ const char *proto);
#define SOCKETAPI PASCAL
typedef SOCKET (SOCKETAPI *LPSOCKACCEPT)(SOCKET, struct sockaddr *, int *);
@@ -806,4 +687,24 @@ win32_setservent(int stayopen)
CROAK("setservent not implemented!\n");
}
+#define WIN32IO_IS_STDIO
+#include <io.h>
+#include "win32iop.h"
+
+static struct servent*
+win32_savecopyservent(struct servent*d, struct servent*s, const char *proto)
+{
+ d->s_name = s->s_name;
+ d->s_aliases = s->s_aliases;
+ d->s_port = s->s_port;
+ if (!IsWin95() && s->s_proto && strlen(s->s_proto))
+ d->s_proto = s->s_proto;
+ else if (proto && strlen(proto))
+ d->s_proto = (char *)proto;
+ else
+ d->s_proto = "tcp";
+
+ return d;
+}
+