diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-03-25 21:42:51 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-03-25 21:42:51 (GMT) |
commit | 46a9d4495a0c97352ffe46535f31617afe2e6f65 (patch) | |
tree | ae11295348d39be9cdbaade45be3babfbe49db7c /generic/tclStubInit.c | |
parent | 8a53f7ba996a8144e2beacd6fb3765c5a21f2d8b (diff) | |
parent | 2361a87fc4e600622f0aee538f97b49a0c1e4cf8 (diff) | |
download | tcl-46a9d4495a0c97352ffe46535f31617afe2e6f65.zip tcl-46a9d4495a0c97352ffe46535f31617afe2e6f65.tar.gz tcl-46a9d4495a0c97352ffe46535f31617afe2e6f65.tar.bz2 |
[Bug 3508771] load tclreg.dll in cygwin tclsh
Implement TclWinConvertError, TclWinConvertWSAError,
and various more win32-specific internal functions for
Cygwin, so win32 extensions using those can be
loaded in the cygwin version of tclsh.
Diffstat (limited to 'generic/tclStubInit.c')
-rw-r--r-- | generic/tclStubInit.c | 153 |
1 files changed, 120 insertions, 33 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index da899f4..32e9557 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -39,14 +39,21 @@ #undef Tcl_CreateHashEntry #undef Tcl_Panic #undef Tcl_FindExecutable -#define TclpLocaltime_unix TclpLocaltime -#define TclpGmtime_unix TclpGmtime #ifdef __CYGWIN__ #define TclWinGetPlatformId winGetPlatformId #define Tcl_WinUtfToTChar winUtfToTChar #define Tcl_WinTCharToUtf winTCharToUtf +#define TclWinGetTclInstance winGetTclInstance +#define TclWinNToHS winNToHS +#define TclWinSetSockOpt winSetSockOpt +#define TclWinAddProcess winAddProcess +#define TclpGetTZName pGetTZName +#define TclWinNoBackslash winNoBackslash +#define TclWinSetInterfaces (void (*) _ANSI_ARGS_((int))) doNothing +#define TclWinFlushDirtyChannels doNothing +#define TclWinResetInterfaces doNothing static Tcl_Encoding winTCharEncoding; @@ -58,6 +65,59 @@ TclWinGetPlatformId() return 2; /* VER_PLATFORM_WIN32_NT */; } +static int TclWinGetTclInstance() +{ + Tcl_Panic("TclWinGetTclInstance not yet implemented for CYGWIN"); + return 0; +} + +static unsigned short +TclWinNToHS(unsigned short ns) +{ + Tcl_Panic("TclWinNToHS not yet implemented for CYGWIN"); + return (unsigned short) -1; +} +static int +TclWinSetSockOpt(int s, int level, int optname, + const char *optval, int optlen) +{ + Tcl_Panic("TclWinSetSockOpt not yet implemented for CYGWIN"); + return -1; +} + +static void +TclWinAddProcess(void *hProcess, unsigned long id) +{ + Tcl_Panic("TclWinAddProcess not yet implemented for CYGWIN"); +} + +static char * +TclpGetTZName(int isdst) +{ + /* TODO: implementation */ + Tcl_Panic("TclpGetTZName not yet implemented for CYGWIN"); + return 0; +} + +static char * +TclWinNoBackslash(char *path) +{ + char *p; + + for (p = path; *p != '\0'; p++) { + if (*p == '\\') { + *p = '/'; + } + } + return path; +} + +static void +doNothing(void) +{ + /* dummy implementation, no need to do anything */ +} + static char * Tcl_WinUtfToTChar(string, len, dsPtr) CONST char *string; @@ -65,20 +125,20 @@ Tcl_WinUtfToTChar(string, len, dsPtr) Tcl_DString *dsPtr; { if (!winTCharEncoding) { - winTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); + winTCharEncoding = Tcl_GetEncoding(0, "unicode"); } return Tcl_UtfToExternalDString(winTCharEncoding, string, len, dsPtr); } static char * -Tcl_WinTCharToUtf(string, len, dsPtr) - CONST char *string; - int len; - Tcl_DString *dsPtr; +Tcl_WinTCharToUtf( + CONST char *string, + int len, + Tcl_DString *dsPtr) { if (!winTCharEncoding) { - winTCharEncoding = Tcl_GetEncoding(NULL, "unicode"); + winTCharEncoding = Tcl_GetEncoding(0, "unicode"); } return Tcl_ExternalToUtfDString(winTCharEncoding, string, len, dsPtr); @@ -88,13 +148,36 @@ Tcl_WinTCharToUtf(string, len, dsPtr) Tcl_Interp *, CONST char *, int, int, char *))) Tcl_WinUtfToTChar #define Tcl_MacOSXOpenVersionedBundleResources (int (*) _ANSI_ARGS_(( \ Tcl_Interp *, CONST char *, CONST char *, int, int, char *))) Tcl_WinTCharToUtf +#define TclMacOSXGetFileAttribute (int (*) _ANSI_ARGS_((Tcl_Interp *, \ + int, Tcl_Obj *, Tcl_Obj **))) TclpCreateProcess +#define TclMacOSXMatchType (int (*) _ANSI_ARGS_((Tcl_Interp *, CONST char *, \ + CONST char *, Tcl_StatBuf *, Tcl_GlobTypeData *))) TclpMakeFile +#define TclMacOSXNotifierAddRunLoopMode (void (*) _ANSI_ARGS_((CONST void *))) TclpOpenFile +#define TclpLocaltime_unix (struct tm *(*) _ANSI_ARGS_((CONST time_t *))) TclGetAndDetachPids +#define TclpGmtime_unix (struct tm *(*) _ANSI_ARGS_((CONST time_t *))) TclpCloseFile #elif !defined(__WIN32__) /* UNIX and MAC */ +# define TclWinConvertError (void (*) _ANSI_ARGS_((unsigned int))) TclGetAndDetachPids +# define TclWinConvertWSAError (void (*) _ANSI_ARGS_((unsigned int))) TclpCloseFile # define TclWinGetPlatformId (int (*)()) TclpCreateTempFile +# define TclWinGetTclInstance (int (*)()) TclpCreateProcess +# define TclWinNToHS (unsigned short (*) _ANSI_ARGS_((unsigned short ns))) TclpMakeFile +# define TclWinSetSockOpt (int (*) _ANSI_ARGS_((int, int, int, const char *, int))) TclpOpenFile +# define TclWinAddProcess 0 +# define TclpGetTZName 0 +# define TclWinNoBackslash 0 +# define TclWinSetInterfaces 0 +# define TclWinFlushDirtyChannels 0 +# define TclWinResetInterfaces 0 +# define TclMacOSXGetFileAttribute 0 /* Only implemented in Tcl >= 8.5 */ +# define TclMacOSXMatchType 0 /* Only implemented in Tcl >= 8.5 */ +# define TclMacOSXNotifierAddRunLoopMode 0 /* Only implemented in Tcl >= 8.5 */ # ifndef MAC_OSX_TCL # define Tcl_MacOSXOpenBundleResources 0 # define Tcl_MacOSXOpenVersionedBundleResources 0 # endif +# define TclpLocaltime_unix TclpLocaltime +# define TclpGmtime_unix TclpGmtime #endif /* @@ -368,14 +451,14 @@ static const TclIntPlatStubs tclIntPlatStubs = { TCL_STUB_MAGIC, 0, #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ - TclGetAndDetachPids, /* 0 */ - TclpCloseFile, /* 1 */ + TclWinConvertError, /* 0 */ + TclWinConvertWSAError, /* 1 */ TclpCreateCommandChannel, /* 2 */ TclpCreatePipe, /* 3 */ - TclpCreateProcess, /* 4 */ + TclWinGetTclInstance, /* 4 */ 0, /* 5 */ - TclpMakeFile, /* 6 */ - TclpOpenFile, /* 7 */ + TclWinNToHS, /* 6 */ + TclWinSetSockOpt, /* 7 */ TclUnixWaitForFile, /* 8 */ TclWinGetPlatformId, /* 9 */ TclpReaddir, /* 10 */ @@ -383,21 +466,23 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclpGmtime_unix, /* 12 */ TclpInetNtoa, /* 13 */ TclUnixCopyFile, /* 14 */ - 0, /* 15 */ + TclMacOSXGetFileAttribute, /* 15 */ 0, /* 16 */ 0, /* 17 */ - 0, /* 18 */ - 0, /* 19 */ - 0, /* 20 */ + TclMacOSXMatchType, /* 18 */ + TclMacOSXNotifierAddRunLoopMode, /* 19 */ + TclWinAddProcess, /* 20 */ 0, /* 21 */ TclpCreateTempFile, /* 22 */ - 0, /* 23 */ - 0, /* 24 */ + TclpGetTZName, /* 23 */ + TclWinNoBackslash, /* 24 */ 0, /* 25 */ - 0, /* 26 */ - 0, /* 27 */ - 0, /* 28 */ + TclWinSetInterfaces, /* 26 */ + TclWinFlushDirtyChannels, /* 27 */ + TclWinResetInterfaces, /* 28 */ TclWinCPUID, /* 29 */ + TclGetAndDetachPids, /* 30 */ + TclpCloseFile, /* 31 */ #endif /* UNIX */ #ifdef __WIN32__ /* WIN */ TclWinConvertError, /* 0 */ @@ -432,14 +517,14 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclWinCPUID, /* 29 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ - TclGetAndDetachPids, /* 0 */ - TclpCloseFile, /* 1 */ + TclWinConvertError, /* 0 */ + TclWinConvertWSAError, /* 1 */ TclpCreateCommandChannel, /* 2 */ TclpCreatePipe, /* 3 */ - TclpCreateProcess, /* 4 */ + TclWinGetTclInstance, /* 4 */ 0, /* 5 */ - TclpMakeFile, /* 6 */ - TclpOpenFile, /* 7 */ + TclWinNToHS, /* 6 */ + TclWinSetSockOpt, /* 7 */ TclUnixWaitForFile, /* 8 */ TclWinGetPlatformId, /* 9 */ TclpReaddir, /* 10 */ @@ -452,16 +537,18 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclMacOSXCopyFileAttributes, /* 17 */ TclMacOSXMatchType, /* 18 */ TclMacOSXNotifierAddRunLoopMode, /* 19 */ - 0, /* 20 */ + TclWinAddProcess, /* 20 */ 0, /* 21 */ TclpCreateTempFile, /* 22 */ - 0, /* 23 */ - 0, /* 24 */ + TclpGetTZName, /* 23 */ + TclWinNoBackslash, /* 24 */ 0, /* 25 */ - 0, /* 26 */ - 0, /* 27 */ - 0, /* 28 */ + TclWinSetInterfaces, /* 26 */ + TclWinFlushDirtyChannels, /* 27 */ + TclWinResetInterfaces, /* 28 */ TclWinCPUID, /* 29 */ + TclGetAndDetachPids, /* 30 */ + TclpCloseFile, /* 31 */ #endif /* MACOSX */ }; |