#ifndef _TCLWINPORT
#define _TCLWINPORT
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <process.h>
#include <signal.h>
#include <winsock.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <float.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef _MSC_VER
#define PASCAL
#endif
#ifdef BUILD_tcl
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLEXPORT
#endif
#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef ENOTSUP
#define ENOTSUP -1030507
#endif
#ifdef __CYGWIN32__
#define TclpAlloc(size) malloc(size)
#define TclpFree(ptr) free(ptr)
#define TclpRealloc(ptr, size) realloc(ptr, size)
#else
#define TclpSysAlloc(size, isBin) ((void*)HeapAlloc(GetProcessHeap(), \
(DWORD)0, (DWORD)size))
#define TclpSysFree(ptr) (HeapFree(GetProcessHeap(), \
(DWORD)0, (HGLOBAL)ptr))
#define TclpSysRealloc(ptr, size) ((void*)HeapReAlloc(GetProcessHeap(), \
(DWORD)0, (LPVOID)ptr, (DWORD)size))
#endif
#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF
#define TCL_SHLIB_EXT ".dll"
#if TCL_UNION_WAIT
# define WAIT_STATUS_TYPE union wait
#else
# define WAIT_STATUS_TYPE int
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0)
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
#endif
#ifndef WIFSIGNALED
# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
#endif
#ifndef WTERMSIG
# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f)
#endif
#ifndef WIFSTOPPED
# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177)
#endif
#ifndef WSTOPSIG
# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff)
#endif
#ifndef WNOHANG
# define WNOHANG 1
#endif
#ifndef WUNTRACED
# define WUNTRACED 2
#endif
#ifndef MAXPATH
#define MAXPATH MAX_PATH
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN MAXPATH
#endif
#ifndef F_OK
# define F_OK 00
#endif
#ifndef X_OK
# define X_OK 01
#endif
#ifndef W_OK
# define W_OK 02
#endif
#ifndef R_OK
# define R_OK 04
#endif
#ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) 0
# endif
# endif
#ifndef S_ISDIR
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) 0
# endif
# endif
#ifndef S_ISCHR
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) 0
# endif
# endif
#ifndef S_ISBLK
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) 0
# endif
# endif
#ifndef S_ISFIFO
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) 0
# endif
# endif
#if ! TCL_PID_T
# define pid_t int
#endif
#if ! TCL_UID_T
# define uid_t int
#endif
#define TclGetUserHome(name,bufferPtr) (NULL)
#ifdef _MSC_VER
# define environ _environ
# define hypot _hypot
# define exception _exception
# undef EDEADLOCK
#endif
#ifdef __MINGW32__
extern char *** __imp__environ_dll;
# define environ (*__imp__environ_dll)
# define hypot _hypot
# define exception _exception
# undef EDEADLOCK
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
#endif
#ifndef EALREADY
#define EALREADY 149
#endif
#ifndef ENOTSOCK
#define ENOTSOCK 95
#endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ 96
#endif
#ifndef EMSGSIZE
#define EMSGSIZE 97
#endif
#ifndef EPROTOTYPE
#define EPROTOTYPE 98
#endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 99
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT 120
#endif
#ifndef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT 121
#endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP 122
#endif
#ifndef EPFNOSUPPORT
#define EPFNOSUPPORT 123
#endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT 124
#endif
#ifndef EADDRINUSE
#define EADDRINUSE 125
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL 126
#endif
#ifndef ENETDOWN
#define ENETDOWN 127
#endif
#ifndef ENETUNREACH
#define ENETUNREACH 128
#endif
#ifndef ENETRESET
#define ENETRESET 129
#endif
#ifndef ECONNABORTED
#define ECONNABORTED 130
#endif
#ifndef ECONNRESET
#define ECONNRESET 131
#endif
#ifndef ENOBUFS
#define ENOBUFS 132
#endif
#ifndef EISCONN
#define EISCONN 133
#endif
#ifndef ENOTCONN
#define ENOTCONN 134
#endif
#ifndef ESHUTDOWN
#define ESHUTDOWN 143
#endif
#ifndef ETOOMANYREFS
#define ETOOMANYREFS 144
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 145
#endif
#ifndef ECONNREFUSED
#define ECONNREFUSED 146
#endif
#ifndef ELOOP
#define ELOOP 90
#endif
#ifndef EHOSTDOWN
#define EHOSTDOWN 147
#endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH 148
#endif
#ifndef ENOTEMPTY
#define ENOTEMPTY 93
#endif
#ifndef EUSERS
#define EUSERS 94
#endif
#ifndef EDQUOT
#define EDQUOT 49
#endif
#ifndef ESTALE
#define ESTALE 151
#endif
#ifndef EREMOTE
#define EREMOTE 66
#endif
#define USE_PUTENV 1
#define getservbyname TclWinGetServByName
#define getsockopt TclWinGetSockOpt
#define ntohs TclWinNToHS
#define setsockopt TclWinSetSockOpt
#define TclPlatformExit(status) exit(status)
EXTERN struct tm * TclpGetDate _ANSI_ARGS_((const time_t *tp,
int useGMT));
EXTERN unsigned long TclpGetPid _ANSI_ARGS_((Tcl_Pid pid));
EXTERN size_t TclStrftime _ANSI_ARGS_((char *s, size_t maxsize,
const char *format, const struct tm *t));
#define lstat TclStat
EXTERN int TclpStat _ANSI_ARGS_((CONST char *path,
struct stat *buf));
EXTERN int TclpAccess _ANSI_ARGS_((CONST char *path,
int mode));
#define TclpReleaseFile(file) ckfree((char *) file)
EXTERN void TclWinConvertError _ANSI_ARGS_((DWORD errCode));
EXTERN void TclWinConvertWSAError _ANSI_ARGS_((DWORD errCode));
EXTERN struct servent * PASCAL FAR
TclWinGetServByName _ANSI_ARGS_((const char FAR *nm,
const char FAR *proto));
EXTERN int PASCAL FAR TclWinGetSockOpt _ANSI_ARGS_((SOCKET s, int level,
int optname, char FAR * optval, int FAR *optlen));
EXTERN HINSTANCE TclWinGetTclInstance _ANSI_ARGS_((void));
EXTERN HINSTANCE TclWinLoadLibrary _ANSI_ARGS_((char *name));
EXTERN u_short PASCAL FAR
TclWinNToHS _ANSI_ARGS_((u_short ns));
EXTERN int PASCAL FAR TclWinSetSockOpt _ANSI_ARGS_((SOCKET s, int level,
int optname, const char FAR * optval, int optlen));
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLIMPORT
#endif