diff options
Diffstat (limited to 'win')
-rwxr-xr-x | win/configure | 4 | ||||
-rw-r--r-- | win/makefile.vc | 4 | ||||
-rw-r--r-- | win/rules.vc | 6 | ||||
-rw-r--r-- | win/tcl.dsp | 4 | ||||
-rw-r--r-- | win/tcl.m4 | 4 | ||||
-rw-r--r-- | win/tclWin32Dll.c | 22 | ||||
-rw-r--r-- | win/tclWinDde.c | 66 | ||||
-rw-r--r-- | win/tclWinFCmd.c | 153 | ||||
-rw-r--r-- | win/tclWinFile.c | 317 | ||||
-rw-r--r-- | win/tclWinInt.h | 4 | ||||
-rw-r--r-- | win/tclWinPipe.c | 45 | ||||
-rw-r--r-- | win/tclWinReg.c | 227 | ||||
-rw-r--r-- | win/tclWinSock.c | 6 | ||||
-rw-r--r-- | win/tclWinTest.c | 143 | ||||
-rw-r--r-- | win/tclWinThrd.h | 21 |
15 files changed, 352 insertions, 674 deletions
diff --git a/win/configure b/win/configure index c059ce8..f6f8b81 100755 --- a/win/configure +++ b/win/configure @@ -4015,7 +4015,7 @@ echo "$as_me: WARNING: 64bit mode not supported with GCC on Windows" >&2;} fi SHLIB_LD="" SHLIB_LD_LIBS='${LIBS}' - LIBS="-lkernel32 -luser32 -ladvapi32 -lws2_32" + LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" STLIB_LD='${AR} cr' @@ -4177,7 +4177,7 @@ echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6 fi fi - LIBS="kernel32.lib user32.lib advapi32.lib ws2_32.lib" + LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib" if test "$do64bit" != "no" ; then # The space-based-path will work for the Makefile, but will # not work if AC_TRY_COMPILE is called. TEA has the diff --git a/win/makefile.vc b/win/makefile.vc index 9e36522..4586c14 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -13,7 +13,7 @@ # Copyright (c) 2003-2008 Pat Thoyts. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: makefile.vc,v 1.214.2.1 2010/09/21 19:32:26 kennykb Exp $ +# RCS: @(#) $Id: makefile.vc,v 1.214.2.2 2010/10/20 01:50:19 kennykb Exp $ #------------------------------------------------------------------------------ # Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR) @@ -523,7 +523,7 @@ dlllflags = $(lflags) -dll conlflags = $(lflags) -subsystem:console guilflags = $(lflags) -subsystem:windows -baselibs = kernel32.lib user32.lib advapi32.lib ws2_32.lib +baselibs = netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib # Avoid 'unresolved external symbol __security_cookie' errors. # c.f. http://support.microsoft.com/?id=894573 !if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" diff --git a/win/rules.vc b/win/rules.vc index f35a51f..4ec990e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -11,7 +11,7 @@ # Copyright (c) 2003-2007 Patrick Thoyts # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: rules.vc,v 1.44 2010/08/31 20:48:17 nijtmans Exp $ +# RCS: @(#) $Id: rules.vc,v 1.44.2.1 2010/10/20 01:50:19 kennykb Exp $ #------------------------------------------------------------------------------ !ifndef _RULES_VC @@ -189,7 +189,9 @@ VCVER=0 !if ![echo VCVERSION=_MSC_VER > vercl.x] \ && ![cl -nologo -TC -P vercl.x $(ERRNULL)] !include vercl.i -!if $(VCVERSION) >= 1500 +!if $(VCVERSION) >= 1600 +VCVER=10 +!elseif $(VCVERSION) >= 1500 VCVER=9 !elseif $(VCVERSION) >= 1400 VCVER=8 diff --git a/win/tcl.dsp b/win/tcl.dsp index 27b4220..57ec6bf 100644 --- a/win/tcl.dsp +++ b/win/tcl.dsp @@ -1560,10 +1560,6 @@ SOURCE=.\tclWinThrd.c # End Source File # Begin Source File -SOURCE=.\tclWinThrd.h -# End Source File -# Begin Source File - SOURCE=.\tclWinTime.c # End Source File # End Group @@ -463,7 +463,7 @@ file for information about building with Mingw.]) fi SHLIB_LD="" SHLIB_LD_LIBS='${LIBS}' - LIBS="-lkernel32 -luser32 -ladvapi32 -lws2_32" + LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" STLIB_LD='${AR} cr' @@ -615,7 +615,7 @@ file for information about building with Mingw.]) fi fi - LIBS="kernel32.lib user32.lib advapi32.lib ws2_32.lib" + LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib" if test "$do64bit" != "no" ; then # The space-based-path will work for the Makefile, but will # not work if AC_TRY_COMPILE is called. TEA has the diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index c3fb6f8..673d811 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWin32Dll.c,v 1.68 2010/09/14 08:53:49 nijtmans Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.68.2.1 2010/10/20 01:50:19 kennykb Exp $ */ #include "tclWinInt.h" @@ -146,7 +146,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, typedef struct MountPointMap { const TCHAR *volumeName; /* Native wide string volume name. */ - char driveLetter; /* Drive letter corresponding to the volume + TCHAR driveLetter; /* Drive letter corresponding to the volume * name. */ struct MountPointMap *nextPtr; /* Pointer to next structure in list, or @@ -486,11 +486,11 @@ TclWinResetInterfaces(void) char TclWinDriveLetterForVolMountPoint( - const WCHAR *mountPoint) + const TCHAR *mountPoint) { MountPointMap *dlIter, *dlPtr2; - WCHAR Target[55]; /* Target of mount at mount point */ - WCHAR drive[4] = { L'A', L':', L'\\', L'\0' }; + TCHAR Target[55]; /* Target of mount at mount point */ + TCHAR drive[4] = TEXT("A:\\"); /* * Detect the volume mounted there. Unfortunately, there is no simple way @@ -501,14 +501,14 @@ TclWinDriveLetterForVolMountPoint( Tcl_MutexLock(&mountPointMap); dlIter = driveLetterLookup; while (dlIter != NULL) { - if (wcscmp(dlIter->volumeName, mountPoint) == 0) { + if (_tcscmp(dlIter->volumeName, mountPoint) == 0) { /* * We need to check whether this information is still valid, since * either the user or various programs could have adjusted the * mount points on the fly. */ - drive[0] = L'A' + (dlIter->driveLetter - 'A'); + drive[0] = (TCHAR) dlIter->driveLetter; /* * Try to read the volume mount point and see where it points. @@ -516,7 +516,7 @@ TclWinDriveLetterForVolMountPoint( if (GetVolumeNameForVolumeMountPoint(drive, Target, 55) != 0) { - if (wcscmp(dlIter->volumeName, Target) == 0) { + if (_tcscmp(dlIter->volumeName, Target) == 0) { /* * Nothing has changed. */ @@ -579,7 +579,7 @@ TclWinDriveLetterForVolMountPoint( for (dlIter = driveLetterLookup; dlIter != NULL; dlIter = dlIter->nextPtr) { - if (wcscmp(dlIter->volumeName, Target) == 0) { + if (_tcscmp(dlIter->volumeName, Target) == 0) { alreadyStored = 1; break; } @@ -587,7 +587,7 @@ TclWinDriveLetterForVolMountPoint( if (!alreadyStored) { dlPtr2 = (MountPointMap *) ckalloc(sizeof(MountPointMap)); dlPtr2->volumeName = TclNativeDupInternalRep(Target); - dlPtr2->driveLetter = 'A' + (drive[0] - L'A'); + dlPtr2->driveLetter = (char) drive[0]; dlPtr2->nextPtr = driveLetterLookup; driveLetterLookup = dlPtr2; } @@ -600,7 +600,7 @@ TclWinDriveLetterForVolMountPoint( for (dlIter = driveLetterLookup; dlIter != NULL; dlIter = dlIter->nextPtr) { - if (wcscmp(dlIter->volumeName, mountPoint) == 0) { + if (_tcscmp(dlIter->volumeName, mountPoint) == 0) { Tcl_MutexUnlock(&mountPointMap); return dlIter->driveLetter; } diff --git a/win/tclWinDde.c b/win/tclWinDde.c index 9909d3a..c8cd8c6 100644 --- a/win/tclWinDde.c +++ b/win/tclWinDde.c @@ -9,15 +9,9 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinDde.c,v 1.44 2010/08/30 09:19:38 nijtmans Exp $ + * RCS: @(#) $Id: tclWinDde.c,v 1.44.2.1 2010/10/20 01:50:19 kennykb Exp $ */ -/* TODO: This file does not compile in UNICODE mode. - * See [Freq 2965056]: Windows build with -DUNICODE - */ -#undef UNICODE -#undef _UNICODE - #undef STATIC_BUILD #ifndef USE_TCL_STUBS # define USE_TCL_STUBS @@ -87,7 +81,7 @@ static Tcl_ThreadDataKey dataKey; static HSZ ddeServiceGlobal = 0; static DWORD ddeInstance; /* The application instance handle given to us - * by DdeInitialize. */ + * by DdeInitializeA. */ static int ddeIsServer = 0; #define TCL_DDE_VERSION "1.3.2" @@ -226,7 +220,7 @@ Initialize(void) if (ddeInstance == 0) { Tcl_MutexLock(&ddeMutex); if (ddeInstance == 0) { - if (DdeInitialize(&ddeInstance, DdeServerProc, + if (DdeInitializeA(&ddeInstance, DdeServerProc, CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS | CBF_FAIL_POKES, 0) != DMLERR_NO_ERROR) { ddeInstance = 0; @@ -239,7 +233,7 @@ Initialize(void) if ((ddeServiceGlobal == 0) && (nameFound != 0)) { ddeIsServer = 1; Tcl_CreateExitHandler(DdeExitProc, NULL); - ddeServiceGlobal = DdeCreateStringHandle(ddeInstance, + ddeServiceGlobal = DdeCreateStringHandleA(ddeInstance, TCL_DDE_SERVICE_NAME, 0); DdeNameService(ddeInstance, ddeServiceGlobal, 0L, DNS_REGISTER); } else { @@ -346,7 +340,7 @@ DdeSetServerName( &srvPtrPtr); } if (r != TCL_OK) { - OutputDebugString(Tcl_GetStringResult(interp)); + OutputDebugStringA(Tcl_GetStringResult(interp)); return NULL; } @@ -631,11 +625,11 @@ DdeServerProc( * sure we have a valid topic. */ - len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, 0); + len = DdeQueryStringA(ddeInstance, ddeTopic, NULL, 0, 0); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, len); utilString = Tcl_DStringValue(&dString); - DdeQueryString(ddeInstance, ddeTopic, utilString, (DWORD) len + 1, + DdeQueryStringA(ddeInstance, ddeTopic, utilString, (DWORD) len + 1, CP_WINANSI); for (riPtr = tsdPtr->interpListPtr; riPtr != NULL; @@ -656,11 +650,11 @@ DdeServerProc( * result to return in an XTYP_REQUEST. */ - len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, 0); + len = DdeQueryStringA(ddeInstance, ddeTopic, NULL, 0, 0); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, len); utilString = Tcl_DStringValue(&dString); - DdeQueryString(ddeInstance, ddeTopic, utilString, (DWORD) len + 1, + DdeQueryStringA(ddeInstance, ddeTopic, utilString, (DWORD) len + 1, CP_WINANSI); for (riPtr = tsdPtr->interpListPtr; riPtr != NULL; riPtr = riPtr->nextPtr) { @@ -723,11 +717,11 @@ DdeServerProc( if (convPtr != NULL) { BYTE *returnString; - len = DdeQueryString(ddeInstance, ddeItem, NULL, 0, CP_WINANSI); + len = DdeQueryStringA(ddeInstance, ddeItem, NULL, 0, CP_WINANSI); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, len); utilString = Tcl_DStringValue(&dString); - DdeQueryString(ddeInstance, ddeItem, utilString, (DWORD) len + 1, + DdeQueryStringA(ddeInstance, ddeItem, utilString, (DWORD) len + 1, CP_WINANSI); if (strcasecmp(utilString, TCL_DDE_EXECUTE_RESULT) == 0) { returnString = (BYTE *) @@ -828,9 +822,9 @@ DdeServerProc( len = dlen; for (i = 0, riPtr = tsdPtr->interpListPtr; i < numItems; i++, riPtr = riPtr->nextPtr) { - returnPtr[i].hszSvc = DdeCreateStringHandle(ddeInstance, + returnPtr[i].hszSvc = DdeCreateStringHandleA(ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINANSI); - returnPtr[i].hszTopic = DdeCreateStringHandle(ddeInstance, + returnPtr[i].hszTopic = DdeCreateStringHandleA(ddeInstance, riPtr->name, CP_WINANSI); } returnPtr[i].hszSvc = NULL; @@ -895,8 +889,8 @@ MakeDdeConnection( HSZ ddeTopic, ddeService; HCONV ddeConv; - ddeService = DdeCreateStringHandle(ddeInstance, TCL_DDE_SERVICE_NAME, 0); - ddeTopic = DdeCreateStringHandle(ddeInstance, (void *) name, 0); + ddeService = DdeCreateStringHandleA(ddeInstance, TCL_DDE_SERVICE_NAME, 0); + ddeTopic = DdeCreateStringHandleA(ddeInstance, (void *) name, 0); ddeConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); @@ -938,7 +932,7 @@ static int DdeCreateClient( struct DdeEnumServices *es) { - WNDCLASSEX wc; + WNDCLASSEXA wc; static const char *szDdeClientClassName = "TclEval client class"; static const char *szDdeClientWindowName = "TclEval client window"; @@ -952,8 +946,8 @@ DdeCreateClient( * Register and create the callback window. */ - RegisterClassEx(&wc); - es->hwnd = CreateWindowEx(0, szDdeClientClassName, szDdeClientWindowName, + RegisterClassExA(&wc); + es->hwnd = CreateWindowExA(0, szDdeClientClassName, szDdeClientWindowName, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, (LPVOID)es); return TCL_OK; } @@ -975,7 +969,7 @@ DdeClientWindowProc( #ifdef _WIN64 SetWindowLongPtr(hwnd, GWLP_USERDATA, (long)es); #else - SetWindowLong(hwnd, GWL_USERDATA, (long)es); + SetWindowLongA(hwnd, GWL_USERDATA, (long)es); #endif return (LRESULT) 0L; } @@ -983,7 +977,7 @@ DdeClientWindowProc( return DdeServicesOnAck(hwnd, wParam, lParam); break; default: - return DefWindowProc(hwnd, uMsg, wParam, lParam); + return DefWindowProcA(hwnd, uMsg, wParam, lParam); } } @@ -1002,7 +996,7 @@ DdeServicesOnAck( #ifdef _WIN64 es = (struct DdeEnumServices *) GetWindowLongPtr(hwnd, GWLP_USERDATA); #else - es = (struct DdeEnumServices *) GetWindowLong(hwnd, GWL_USERDATA); + es = (struct DdeEnumServices *) GetWindowLongA(hwnd, GWL_USERDATA); #endif if ((es->service == (ATOM)0 || es->service == service) @@ -1039,7 +1033,7 @@ DdeServicesOnAck( * Tell the server we are no longer interested. */ - PostMessage(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L); + PostMessageA(hwndRemote, WM_DDE_TERMINATE, (WPARAM)hwnd, 0L); return 0L; } @@ -1051,7 +1045,7 @@ DdeEnumWindowsCallback( DWORD dwResult = 0; struct DdeEnumServices *es = (struct DdeEnumServices *) lParam; - SendMessageTimeout(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd, + SendMessageTimeoutA(hwndTarget, WM_DDE_INITIATE, (WPARAM)es->hwnd, MAKELONG(es->service, es->topic), SMTO_ABORTIFHUNG, 1000, &dwResult); return TRUE; @@ -1068,8 +1062,8 @@ DdeGetServicesList( es.interp = interp; es.result = TCL_OK; es.service = (serviceName == NULL) - ? (ATOM)0 : GlobalAddAtom(serviceName); - es.topic = (topicName == NULL) ? (ATOM)0 : GlobalAddAtom(topicName); + ? (ATOM)0 : GlobalAddAtomA(serviceName); + es.topic = (topicName == NULL) ? (ATOM)0 : GlobalAddAtomA(topicName); Tcl_ResetResult(interp); /* our list is to be appended to result. */ DdeCreateClient(&es); @@ -1330,7 +1324,7 @@ DdeObjCmd( if (length == 0) { serviceName = NULL; } else if ((index != DDE_SERVERNAME) && (index != DDE_EVAL)) { - ddeService = DdeCreateStringHandle(ddeInstance, (void *) serviceName, + ddeService = DdeCreateStringHandleA(ddeInstance, (void *) serviceName, CP_WINANSI); } @@ -1339,7 +1333,7 @@ DdeObjCmd( if (length == 0) { topicName = NULL; } else { - ddeTopic = DdeCreateStringHandle(ddeInstance, (void *) topicName, + ddeTopic = DdeCreateStringHandleA(ddeInstance, (void *) topicName, CP_WINANSI); } } @@ -1417,7 +1411,7 @@ DdeObjCmd( result = TCL_ERROR; } else { Tcl_Obj *returnObjPtr; - ddeItem = DdeCreateStringHandle(ddeInstance, (void *) itemString, + ddeItem = DdeCreateStringHandleA(ddeInstance, (void *) itemString, CP_WINANSI); if (ddeItem != NULL) { ddeData = DdeClientTransaction(NULL, 0, hConv, ddeItem, @@ -1469,7 +1463,7 @@ DdeObjCmd( SetDdeError(interp); result = TCL_ERROR; } else { - ddeItem = DdeCreateStringHandle(ddeInstance, (void *) itemString, + ddeItem = DdeCreateStringHandleA(ddeInstance, (void *) itemString, CP_WINANSI); if (ddeItem != NULL) { ddeData = DdeClientTransaction(dataString, (DWORD) length+1, @@ -1627,7 +1621,7 @@ DdeObjCmd( 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, 30000, NULL); if (ddeData != 0) { - ddeCookie = DdeCreateStringHandle(ddeInstance, + ddeCookie = DdeCreateStringHandleA(ddeInstance, TCL_DDE_EXECUTE_RESULT, CP_WINANSI); ddeData = DdeClientTransaction(NULL, 0, hConv, ddeCookie, CF_TEXT, XTYP_REQUEST, 30000, NULL); diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 310a37f..3856ffa 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFCmd.c,v 1.67.2.1 2010/09/22 01:08:49 kennykb Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.67.2.2 2010/10/20 01:50:19 kennykb Exp $ */ #include "tclWinInt.h" @@ -277,7 +277,7 @@ DoRenameFile( [registration] "m" (registration), [nativeDst] "m" (nativeDst), [nativeSrc] "m" (nativeSrc), - [moveFile] "r" (tclWinProcs->moveFileProc) + [moveFile] "r" (MoveFile) : "%eax", "%ebx", "%ecx", "%edx", "memory" ); @@ -288,7 +288,7 @@ DoRenameFile( #ifndef HAVE_NO_SEH __try { #endif - if ((*tclWinProcs->moveFileProc)(nativeSrc, nativeDst) != FALSE) { + if ((*MoveFile)(nativeSrc, nativeDst) != FALSE) { retval = TCL_OK; } #ifndef HAVE_NO_SEH @@ -302,10 +302,10 @@ DoRenameFile( TclWinConvertError(GetLastError()); - srcAttr = tclWinProcs->getFileAttributesProc(nativeSrc); - dstAttr = tclWinProcs->getFileAttributesProc(nativeDst); + srcAttr = GetFileAttributes(nativeSrc); + dstAttr = GetFileAttributes(nativeDst); if (srcAttr == 0xffffffff) { - if (tclWinProcs->getFullPathNameProc(nativeSrc, 0, NULL, + if (GetFullPathName(nativeSrc, 0, NULL, NULL) >= MAX_PATH) { errno = ENAMETOOLONG; return TCL_ERROR; @@ -313,7 +313,7 @@ DoRenameFile( srcAttr = 0; } if (dstAttr == 0xffffffff) { - if (tclWinProcs->getFullPathNameProc(nativeDst, 0, NULL, + if (GetFullPathName(nativeDst, 0, NULL, NULL) >= MAX_PATH) { errno = ENAMETOOLONG; return TCL_ERROR; @@ -336,21 +336,21 @@ DoRenameFile( Tcl_DString srcString, dstString; const char *src, *dst; - size = tclWinProcs->getFullPathNameProc(nativeSrc, MAX_PATH, + size = GetFullPathName(nativeSrc, MAX_PATH, nativeSrcPath, &nativeSrcRest); if ((size == 0) || (size > MAX_PATH)) { return TCL_ERROR; } - size = tclWinProcs->getFullPathNameProc(nativeDst, MAX_PATH, + size = GetFullPathName(nativeDst, MAX_PATH, nativeDstPath, &nativeDstRest); if ((size == 0) || (size > MAX_PATH)) { return TCL_ERROR; } - tclWinProcs->charLowerProc(nativeSrcPath); - tclWinProcs->charLowerProc(nativeDstPath); + CharLower(nativeSrcPath); + CharLower(nativeDstPath); - src = tclWinProcs->tchar2utf(nativeSrcPath, -1, &srcString); - dst = tclWinProcs->tchar2utf(nativeDstPath, -1, &dstString); + src = Tcl_WinTCharToUtf(nativeSrcPath, -1, &srcString); + dst = Tcl_WinTCharToUtf(nativeDstPath, -1, &dstString); /* * Check whether the destination path is actually inside the @@ -429,7 +429,7 @@ DoRenameFile( * directory back, for completeness. */ - if (tclWinProcs->moveFileProc(nativeSrc, + if (MoveFile(nativeSrc, nativeDst) != FALSE) { return TCL_OK; } @@ -440,8 +440,8 @@ DoRenameFile( */ TclWinConvertError(GetLastError()); - tclWinProcs->createDirectoryProc(nativeDst, NULL); - tclWinProcs->setFileAttributesProc(nativeDst, dstAttr); + CreateDirectory(nativeDst, NULL); + SetFileAttributes(nativeDst, dstAttr); if (Tcl_GetErrno() == EACCES) { /* * Decode the EACCES to a more meaningful error. @@ -470,7 +470,7 @@ DoRenameFile( int result, size; TCHAR tempBuf[MAX_PATH]; - size = tclWinProcs->getFullPathNameProc(nativeDst, MAX_PATH, + size = GetFullPathName(nativeDst, MAX_PATH, tempBuf, &nativeRest); if ((size == 0) || (size > MAX_PATH) || (nativeRest == NULL)) { return TCL_ERROR; @@ -480,7 +480,7 @@ DoRenameFile( result = TCL_ERROR; nativePrefix = (TCHAR *) L"tclr"; - if (tclWinProcs->getTempFileNameProc(nativeTmp, nativePrefix, + if (GetTempFileName(nativeTmp, nativePrefix, 0, tempBuf) != 0) { /* * Strictly speaking, need the following DeleteFile and @@ -489,19 +489,16 @@ DoRenameFile( * same temp file. */ - nativeTmp = (TCHAR *) tempBuf; - tclWinProcs->deleteFileProc(nativeTmp); - if (tclWinProcs->moveFileProc(nativeDst, - nativeTmp) != FALSE) { - if (tclWinProcs->moveFileProc(nativeSrc, - nativeDst) != FALSE) { - tclWinProcs->setFileAttributesProc(nativeTmp, - FILE_ATTRIBUTE_NORMAL); - tclWinProcs->deleteFileProc(nativeTmp); + nativeTmp = tempBuf; + DeleteFile(nativeTmp); + if (MoveFile(nativeDst, nativeTmp) != FALSE) { + if (MoveFile(nativeSrc, nativeDst) != FALSE) { + SetFileAttributes(nativeTmp, FILE_ATTRIBUTE_NORMAL); + DeleteFile(nativeTmp); return TCL_OK; } else { - tclWinProcs->deleteFileProc(nativeDst); - tclWinProcs->moveFileProc(nativeTmp, nativeDst); + DeleteFile(nativeDst); + MoveFile(nativeTmp, nativeDst); } } @@ -668,7 +665,7 @@ DoCopyFile( [registration] "m" (registration), [nativeDst] "m" (nativeDst), [nativeSrc] "m" (nativeSrc), - [copyFile] "r" (tclWinProcs->copyFileProc) + [copyFile] "r" (CopyFile) : "%eax", "%ebx", "%ecx", "%edx", "memory" ); @@ -679,7 +676,7 @@ DoCopyFile( #ifndef HAVE_NO_SEH __try { #endif - if ((*tclWinProcs->copyFileProc)(nativeSrc, nativeDst, 0) != FALSE) { + if (CopyFile(nativeSrc, nativeDst, 0) != FALSE) { retval = TCL_OK; } #ifndef HAVE_NO_SEH @@ -699,8 +696,8 @@ DoCopyFile( if (Tcl_GetErrno() == EACCES) { DWORD srcAttr, dstAttr; - srcAttr = tclWinProcs->getFileAttributesProc(nativeSrc); - dstAttr = tclWinProcs->getFileAttributesProc(nativeDst); + srcAttr = GetFileAttributes(nativeSrc); + dstAttr = GetFileAttributes(nativeDst); if (srcAttr != 0xffffffff) { if (dstAttr == 0xffffffff) { dstAttr = 0; @@ -716,9 +713,9 @@ DoCopyFile( Tcl_SetErrno(EISDIR); } if (dstAttr & FILE_ATTRIBUTE_READONLY) { - tclWinProcs->setFileAttributesProc(nativeDst, + SetFileAttributes(nativeDst, dstAttr & ~((DWORD)FILE_ATTRIBUTE_READONLY)); - if (tclWinProcs->copyFileProc(nativeSrc, nativeDst, + if (CopyFile(nativeSrc, nativeDst, 0) != FALSE) { return TCL_OK; } @@ -729,7 +726,7 @@ DoCopyFile( */ TclWinConvertError(GetLastError()); - tclWinProcs->setFileAttributesProc(nativeDst, dstAttr); + SetFileAttributes(nativeDst, dstAttr); } } } @@ -785,13 +782,13 @@ TclpDeleteFile( return TCL_ERROR; } - if (tclWinProcs->deleteFileProc(path) != FALSE) { + if (DeleteFile(path) != FALSE) { return TCL_OK; } TclWinConvertError(GetLastError()); if (Tcl_GetErrno() == EACCES) { - attr = tclWinProcs->getFileAttributesProc(path); + attr = GetFileAttributes(path); if (attr != 0xffffffff) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { @@ -812,21 +809,21 @@ TclpDeleteFile( Tcl_SetErrno(EISDIR); } else if (attr & FILE_ATTRIBUTE_READONLY) { - int res = tclWinProcs->setFileAttributesProc(path, + int res = SetFileAttributes(path, attr & ~((DWORD) FILE_ATTRIBUTE_READONLY)); if ((res != 0) && - (tclWinProcs->deleteFileProc(path) != FALSE)) { + (DeleteFile(path) != FALSE)) { return TCL_OK; } TclWinConvertError(GetLastError()); if (res != 0) { - tclWinProcs->setFileAttributesProc(path, attr); + SetFileAttributes(path, attr); } } } } else if (Tcl_GetErrno() == ENOENT) { - attr = tclWinProcs->getFileAttributesProc(path); + attr = GetFileAttributes(path); if (attr != 0xffffffff) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { /* @@ -885,7 +882,7 @@ static int DoCreateDirectory( const TCHAR *nativePath) /* Pathname of directory to create (native). */ { - if (tclWinProcs->createDirectoryProc(nativePath, NULL) == 0) { + if (CreateDirectory(nativePath, NULL) == 0) { DWORD error = GetLastError(); TclWinConvertError(error); @@ -935,8 +932,8 @@ TclpObjCopyDirectory( return TCL_ERROR; } - tclWinProcs->utf2tchar(Tcl_GetString(normSrcPtr), -1, &srcString); - tclWinProcs->utf2tchar(Tcl_GetString(normDestPtr), -1, &dstString); + Tcl_WinUtfToTChar(Tcl_GetString(normSrcPtr), -1, &srcString); + Tcl_WinUtfToTChar(Tcl_GetString(normDestPtr), -1, &dstString); ret = TraverseWinTree(TraversalCopy, &srcString, &dstString, &ds); @@ -1008,7 +1005,7 @@ TclpObjRemoveDirectory( if (normPtr == NULL) { return TCL_ERROR; } - tclWinProcs->utf2tchar(Tcl_GetString(normPtr), -1, &native); + Tcl_WinUtfToTChar(Tcl_GetString(normPtr), -1, &native); ret = DoRemoveDirectory(&native, recursive, &ds); Tcl_DStringFree(&native); } else { @@ -1054,7 +1051,7 @@ DoRemoveJustDirectory( goto end; } - attr = tclWinProcs->getFileAttributesProc(nativePath); + attr = GetFileAttributes(nativePath); if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { /* @@ -1068,7 +1065,7 @@ DoRemoveJustDirectory( * Ordinary directory. */ - if (tclWinProcs->removeDirectoryProc(nativePath) != FALSE) { + if (RemoveDirectory(nativePath) != FALSE) { return TCL_OK; } } @@ -1076,7 +1073,7 @@ DoRemoveJustDirectory( TclWinConvertError(GetLastError()); if (Tcl_GetErrno() == EACCES) { - attr = tclWinProcs->getFileAttributesProc(nativePath); + attr = GetFileAttributes(nativePath); if (attr != 0xffffffff) { if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) { /* @@ -1100,15 +1097,15 @@ DoRemoveJustDirectory( if (attr & FILE_ATTRIBUTE_READONLY) { attr &= ~FILE_ATTRIBUTE_READONLY; - if (tclWinProcs->setFileAttributesProc(nativePath, + if (SetFileAttributes(nativePath, attr) == FALSE) { goto end; } - if (tclWinProcs->removeDirectoryProc(nativePath) != FALSE) { + if (RemoveDirectory(nativePath) != FALSE) { return TCL_OK; } TclWinConvertError(GetLastError()); - tclWinProcs->setFileAttributesProc(nativePath, + SetFileAttributes(nativePath, attr | FILE_ATTRIBUTE_READONLY); } @@ -1176,7 +1173,7 @@ DoRemoveJustDirectory( end: if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativePath, -1, errorPtr); + Tcl_WinTCharToUtf(nativePath, -1, errorPtr); } return TCL_ERROR; @@ -1247,7 +1244,7 @@ TraverseWinTree( TCHAR *nativeSource, *nativeTarget, *nativeErrfile; int result, found, sourceLen, targetLen = 0, oldSourceLen, oldTargetLen; HANDLE handle; - WIN32_FIND_DATAT data; + WIN32_FIND_DATA data; nativeErrfile = NULL; result = TCL_OK; @@ -1258,7 +1255,7 @@ TraverseWinTree( (targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)); oldSourceLen = Tcl_DStringLength(sourcePtr); - sourceAttr = tclWinProcs->getFileAttributesProc(nativeSource); + sourceAttr = GetFileAttributes(nativeSource); if (sourceAttr == 0xffffffff) { nativeErrfile = nativeSource; goto end; @@ -1285,7 +1282,7 @@ TraverseWinTree( Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1); nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr); - handle = tclWinProcs->findFirstFileProc(nativeSource, &data); + handle = FindFirstFile(nativeSource, &data); if (handle == INVALID_HANDLE_VALUE) { /* * Can't read directory. @@ -1318,11 +1315,11 @@ TraverseWinTree( } found = 1; - for (; found; found = tclWinProcs->findNextFileProc(handle, &data)) { + for (; found; found = FindNextFile(handle, &data)) { TCHAR *nativeName; int len; - WCHAR *wp = data.w.cFileName; + WCHAR *wp = data.cFileName; if (*wp == '.') { wp++; if (*wp == '.') { @@ -1332,8 +1329,8 @@ TraverseWinTree( continue; } } - nativeName = (TCHAR *) data.w.cFileName; - len = wcslen(data.w.cFileName) * sizeof(WCHAR); + nativeName = (TCHAR *) data.cFileName; + len = wcslen(data.cFileName) * sizeof(WCHAR); /* * Append name after slash, and recurse on the file. @@ -1387,7 +1384,7 @@ TraverseWinTree( if (nativeErrfile != NULL) { TclWinConvertError(GetLastError()); if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeErrfile, -1, errorPtr); + Tcl_WinTCharToUtf(nativeErrfile, -1, errorPtr); } result = TCL_ERROR; } @@ -1433,9 +1430,9 @@ TraversalCopy( break; case DOTREE_PRED: if (DoCreateDirectory(nativeDst) == TCL_OK) { - DWORD attr = tclWinProcs->getFileAttributesProc(nativeSrc); + DWORD attr = GetFileAttributes(nativeSrc); - if (tclWinProcs->setFileAttributesProc(nativeDst, + if (SetFileAttributes(nativeDst, attr) != FALSE) { return TCL_OK; } @@ -1452,7 +1449,7 @@ TraversalCopy( */ if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeDst, -1, errorPtr); + Tcl_WinTCharToUtf(nativeDst, -1, errorPtr); } return TCL_ERROR; } @@ -1507,7 +1504,7 @@ TraversalDelete( } if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeSrc, -1, errorPtr); + Tcl_WinTCharToUtf(nativeSrc, -1, errorPtr); } return TCL_ERROR; } @@ -1571,7 +1568,7 @@ GetWinFileAttributes( int attr; nativeName = Tcl_FSGetNativePath(fileName); - result = tclWinProcs->getFileAttributesProc(nativeName); + result = GetFileAttributes(nativeName); if (result == 0xffffffff) { StatError(interp, fileName); @@ -1701,7 +1698,7 @@ ConvertFileNameFormat( const TCHAR *nativeName; const char *tempString; int tempLen; - WIN32_FIND_DATAT data; + WIN32_FIND_DATA data; HANDLE handle; DWORD attr; @@ -1715,9 +1712,9 @@ ConvertFileNameFormat( Tcl_DStringInit(&ds); tempString = Tcl_GetStringFromObj(tempPath,&tempLen); - nativeName = tclWinProcs->utf2tchar(tempString, tempLen, &ds); + nativeName = Tcl_WinUtfToTChar(tempString, tempLen, &ds); Tcl_DecrRefCount(tempPath); - handle = tclWinProcs->findFirstFileProc(nativeName, &data); + handle = FindFirstFile(nativeName, &data); if (handle == INVALID_HANDLE_VALUE) { /* * FindFirstFile() doesn't like root directories. We would @@ -1726,7 +1723,7 @@ ConvertFileNameFormat( * root directory */ - attr = tclWinProcs->getFileAttributesProc(nativeName); + attr = GetFileAttributes(nativeName); if ((attr!=0xFFFFFFFF) && (attr & FILE_ATTRIBUTE_DIRECTORY)) { Tcl_DStringFree(&ds); goto simple; @@ -1740,14 +1737,14 @@ ConvertFileNameFormat( } goto cleanup; } - nativeName = (TCHAR *) data.w.cAlternateFileName; + nativeName = data.cAlternateFileName; if (longShort) { - if (data.w.cFileName[0] != '\0') { - nativeName = (TCHAR *) data.w.cFileName; + if (data.cFileName[0] != TEXT('\0')) { + nativeName = data.cFileName; } } else { - if (data.w.cAlternateFileName[0] == '\0') { - nativeName = (TCHAR *) data.w.cFileName; + if (data.cAlternateFileName[0] == TEXT('\0')) { + nativeName = (TCHAR *) data.cFileName; } } @@ -1764,7 +1761,7 @@ ConvertFileNameFormat( */ Tcl_DStringInit(&dsTemp); - tclWinProcs->tchar2utf(nativeName, -1, &dsTemp); + Tcl_WinTCharToUtf(nativeName, -1, &dsTemp); /* * Deal with issues of tildes being absolute. @@ -1897,7 +1894,7 @@ SetWinFileAttributes( const TCHAR *nativeName; nativeName = Tcl_FSGetNativePath(fileName); - fileAttributes = tclWinProcs->getFileAttributesProc(nativeName); + fileAttributes = GetFileAttributes(nativeName); if (fileAttributes == 0xffffffff) { StatError(interp, fileName); @@ -1915,7 +1912,7 @@ SetWinFileAttributes( fileAttributes &= ~(attributeArray[objIndex]); } - if (!tclWinProcs->setFileAttributesProc(nativeName, fileAttributes)) { + if (!SetFileAttributes(nativeName, fileAttributes)) { StatError(interp, fileName); return TCL_ERROR; } diff --git a/win/tclWinFile.c b/win/tclWinFile.c index bd98a1a..ab4eb76 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.112.2.1 2010/09/22 01:08:49 kennykb Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.112.2.2 2010/10/20 01:50:19 kennykb Exp $ */ #include "tclWinInt.h" @@ -19,7 +19,7 @@ #include <winioctl.h> #include <sys/stat.h> #include <shlobj.h> -#include <lmaccess.h> /* For TclpGetUserHome(). */ +#include <lm.h> /* For TclpGetUserHome(). */ /* * The number of 100-ns intervals between the Windows system epoch (1601-01-01 @@ -150,14 +150,6 @@ typedef struct { static time_t ToCTime(FILETIME fileTime); static void FromCTime(time_t posixTime, FILETIME *fileTime); -typedef NET_API_STATUS NET_API_FUNCTION NETUSERGETINFOPROC( - LPWSTR servername, LPWSTR username, DWORD level, LPBYTE *bufptr); - -typedef NET_API_STATUS NET_API_FUNCTION NETAPIBUFFERFREEPROC(LPVOID Buffer); - -typedef NET_API_STATUS NET_API_FUNCTION NETGETDCNAMEPROC( - LPWSTR servername, LPWSTR domainname, LPBYTE *bufptr); - /* * Declarations for local functions defined in this file: */ @@ -208,7 +200,7 @@ WinLink( * Get the full path referenced by the target. */ - if (!tclWinProcs->getFullPathNameProc(linkTargetPath, MAX_PATH, + if (!GetFullPathName(linkTargetPath, MAX_PATH, tempFileName, &tempFilePart)) { /* * Invalid file. @@ -222,7 +214,7 @@ WinLink( * Make sure source file doesn't exist. */ - attr = tclWinProcs->getFileAttributesProc(linkSourcePath); + attr = GetFileAttributes(linkSourcePath); if (attr != INVALID_FILE_ATTRIBUTES) { Tcl_SetErrno(EEXIST); return -1; @@ -232,7 +224,7 @@ WinLink( * Get the full path referenced by the source file/directory. */ - if (!tclWinProcs->getFullPathNameProc(linkSourcePath, MAX_PATH, + if (!GetFullPathName(linkSourcePath, MAX_PATH, tempFileName, &tempFilePart)) { /* * Invalid file. @@ -246,7 +238,7 @@ WinLink( * Check the target. */ - attr = tclWinProcs->getFileAttributesProc(linkTargetPath); + attr = GetFileAttributes(linkTargetPath); if (attr == INVALID_FILE_ATTRIBUTES) { /* * The target doesn't exist. @@ -260,13 +252,13 @@ WinLink( * It is a file. */ - if (tclWinProcs->createHardLinkProc == NULL) { + if (CreateHardLink == NULL) { Tcl_SetErrno(ENOTDIR); return -1; } if (linkAction & TCL_CREATE_HARD_LINK) { - if (!tclWinProcs->createHardLinkProc(linkSourcePath, + if (!CreateHardLink(linkSourcePath, linkTargetPath, NULL)) { TclWinConvertError(GetLastError()); return -1; @@ -329,7 +321,7 @@ WinReadLink( * Get the full path referenced by the target. */ - if (!tclWinProcs->getFullPathNameProc(linkSourcePath, MAX_PATH, + if (!GetFullPathName(linkSourcePath, MAX_PATH, tempFileName, &tempFilePart)) { /* * Invalid file. @@ -343,7 +335,7 @@ WinReadLink( * Make sure source file does exist. */ - attr = tclWinProcs->getFileAttributesProc(linkSourcePath); + attr = GetFileAttributes(linkSourcePath); if (attr == INVALID_FILE_ATTRIBUTES) { /* * The source doesn't exist. @@ -500,7 +492,7 @@ TclWinSymLinkDelete( memset(reparseBuffer, 0, sizeof(DUMMY_REPARSE_BUFFER)); reparseBuffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; - hFile = tclWinProcs->createFileProc(linkOrigPath, GENERIC_WRITE, 0, NULL, + hFile = CreateFile(linkOrigPath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); @@ -516,7 +508,7 @@ TclWinSymLinkDelete( } else { CloseHandle(hFile); if (!linkOnly) { - tclWinProcs->removeDirectoryProc(linkOrigPath); + RemoveDirectory(linkOrigPath); } return 0; } @@ -556,7 +548,7 @@ WinReadLinkDirectory( Tcl_DString ds; const char *copy; - attr = tclWinProcs->getFileAttributesProc(linkDirPath); + attr = GetFileAttributes(linkDirPath); if (!(attr & FILE_ATTRIBUTE_REPARSE_POINT)) { goto invalidError; } @@ -643,7 +635,7 @@ WinReadLinkDirectory( } } - tclWinProcs->tchar2utf((const TCHAR *) + Tcl_WinTCharToUtf((const TCHAR *) reparseBuffer->MountPointReparseBuffer.PathBuffer, (int) reparseBuffer->MountPointReparseBuffer .SubstituteNameLength, &ds); @@ -684,7 +676,7 @@ NativeReadReparse( HANDLE hFile; DWORD returnedLength; - hFile = tclWinProcs->createFileProc(linkDirPath, GENERIC_READ, 0, NULL, + hFile = CreateFile(linkDirPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); @@ -744,7 +736,7 @@ NativeWriteReparse( * Create the directory - it must not already exist. */ - if (tclWinProcs->createDirectoryProc(linkDirPath, NULL) == 0) { + if (CreateDirectory(linkDirPath, NULL) == 0) { /* * Error creating directory. */ @@ -752,7 +744,7 @@ NativeWriteReparse( TclWinConvertError(GetLastError()); return -1; } - hFile = tclWinProcs->createFileProc(linkDirPath, GENERIC_WRITE, 0, NULL, + hFile = CreateFile(linkDirPath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (hFile == INVALID_HANDLE_VALUE) { @@ -777,7 +769,7 @@ NativeWriteReparse( TclWinConvertError(GetLastError()); CloseHandle(hFile); - tclWinProcs->removeDirectoryProc(linkDirPath); + RemoveDirectory(linkDirPath); return -1; } CloseHandle(hFile); @@ -819,17 +811,18 @@ TclpFindExecutable( * create this process. */ - if (GetModuleFileNameW(NULL, wName, MAX_PATH) == 0) { - GetModuleFileNameA(NULL, name, sizeof(name)); +#ifdef UNICODE + GetModuleFileNameW(NULL, wName, MAX_PATH); +#else + GetModuleFileNameA(NULL, name, sizeof(name)); - /* - * Convert to WCHAR to get out of ANSI codepage - */ - - MultiByteToWideChar(CP_ACP, 0, name, -1, wName, MAX_PATH); - } + /* + * Convert to WCHAR to get out of ANSI codepage + */ - WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL,NULL); + MultiByteToWideChar(CP_ACP, 0, name, -1, wName, MAX_PATH); +#endif + WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL); TclWinNoBackslash(name); TclSetObjNameOfExecutable(Tcl_NewStringObj(name, -1), NULL); } @@ -886,15 +879,15 @@ TclpMatchInDirectory( native = Tcl_FSGetNativePath(pathPtr); - if (tclWinProcs->getFileAttributesExProc == NULL) { - attr = tclWinProcs->getFileAttributesProc(native); + if (GetFileAttributesEx == NULL) { + attr = GetFileAttributes(native); if (attr == INVALID_FILE_ATTRIBUTES) { return TCL_OK; } } else { WIN32_FILE_ATTRIBUTE_DATA data; - if (tclWinProcs->getFileAttributesExProc(native, + if (GetFileAttributesEx(native, GetFileExInfoStandard, &data) != TRUE) { return TCL_OK; } @@ -909,7 +902,7 @@ TclpMatchInDirectory( } else { DWORD attr; HANDLE handle; - WIN32_FIND_DATAT data; + WIN32_FIND_DATA data; const char *dirName; /* UTF-8 dir name, later with pattern * appended. */ int dirLength; @@ -938,7 +931,7 @@ TclpMatchInDirectory( if (native == NULL) { return TCL_OK; } - attr = tclWinProcs->getFileAttributesProc(native); + attr = GetFileAttributes(native); if ((attr == INVALID_FILE_ATTRIBUTES) || ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) { @@ -979,16 +972,16 @@ TclpMatchInDirectory( dirName = Tcl_DStringAppend(&dsOrig, "*.*", 3); } - native = tclWinProcs->utf2tchar(dirName, -1, &ds); - if (tclWinProcs->findFirstFileExProc == NULL || (types == NULL) + native = Tcl_WinUtfToTChar(dirName, -1, &ds); + if (FindFirstFileEx == NULL || (types == NULL) || (types->type != TCL_GLOB_TYPE_DIR)) { - handle = tclWinProcs->findFirstFileProc(native, &data); + handle = FindFirstFile(native, &data); } else { /* * We can be more efficient, for pure directory requests. */ - handle = tclWinProcs->findFirstFileExProc(native, + handle = FindFirstFileEx(native, FindExInfoStandard, &data, FindExSearchLimitToDirectories, NULL, 0); } @@ -1051,9 +1044,9 @@ TclpMatchInDirectory( int checkDrive = 0, isDrive; DWORD attr; - native = (const TCHAR *) data.w.cFileName; - attr = data.w.dwFileAttributes; - utfname = tclWinProcs->tchar2utf(native, -1, &ds); + native = data.cFileName; + attr = data.dwFileAttributes; + utfname = Tcl_WinTCharToUtf(native, -1, &ds); if (!matchSpecialDots) { /* @@ -1112,7 +1105,7 @@ TclpMatchInDirectory( */ Tcl_DStringFree(&ds); - } while (tclWinProcs->findNextFileProc(handle, &data) == TRUE); + } while (FindNextFile(handle, &data) == TRUE); FindClose(handle); Tcl_DStringFree(&dsOrig); @@ -1392,75 +1385,52 @@ TclpGetUserHome( Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with * name of user's home directory. */ { - const char *result; - HINSTANCE netapiInst; + const char *result = NULL; + USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr; + Tcl_DString ds; + int nameLen = -1; + int badDomain = 0; + char *domain; + WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain; + WCHAR buf[MAX_PATH]; - result = NULL; Tcl_DStringInit(bufferPtr); + wDomain = NULL; + domain = strchr(name, '@'); + if (domain != NULL) { + Tcl_DStringInit(&ds); + wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds); + badDomain = NetGetDCName(NULL, wName, + (LPBYTE *) wDomainPtr); + Tcl_DStringFree(&ds); + nameLen = domain - name; + } + if (badDomain == 0) { + Tcl_DStringInit(&ds); + wName = Tcl_UtfToUniCharDString(name, nameLen, &ds); + if (NetUserGetInfo(wDomain, wName, 1, + (LPBYTE *) uiPtrPtr) == 0) { + wHomeDir = uiPtr->usri1_home_dir; + if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) { + Tcl_UniCharToUtfDString(wHomeDir, lstrlenW(wHomeDir), + bufferPtr); + } else { + /* + * User exists but has no home dir. Return + * "{Windows Drive}:/users/default". + */ - netapiInst = LoadLibraryA("netapi32.dll"); - if (netapiInst != NULL) { - NETAPIBUFFERFREEPROC *netApiBufferFreeProc; - NETGETDCNAMEPROC *netGetDCNameProc; - NETUSERGETINFOPROC *netUserGetInfoProc; - - netApiBufferFreeProc = (NETAPIBUFFERFREEPROC *) - GetProcAddress(netapiInst, "NetApiBufferFree"); - netGetDCNameProc = (NETGETDCNAMEPROC *) - GetProcAddress(netapiInst, "NetGetDCName"); - netUserGetInfoProc = (NETUSERGETINFOPROC *) - GetProcAddress(netapiInst, "NetUserGetInfo"); - - if ((netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL) - && (netApiBufferFreeProc != NULL)) { - USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr; - Tcl_DString ds; - int nameLen, badDomain; - char *domain; - WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain; - WCHAR buf[MAX_PATH]; - - badDomain = 0; - nameLen = -1; - wDomain = NULL; - domain = strchr(name, '@'); - if (domain != NULL) { - Tcl_DStringInit(&ds); - wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds); - badDomain = netGetDCNameProc(NULL, wName, - (LPBYTE *) wDomainPtr); - Tcl_DStringFree(&ds); - nameLen = domain - name; - } - if (badDomain == 0) { - Tcl_DStringInit(&ds); - wName = Tcl_UtfToUniCharDString(name, nameLen, &ds); - if (netUserGetInfoProc(wDomain, wName, 1, - (LPBYTE *) uiPtrPtr) == 0) { - wHomeDir = uiPtr->usri1_home_dir; - if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) { - Tcl_UniCharToUtfDString(wHomeDir, lstrlenW(wHomeDir), - bufferPtr); - } else { - /* - * User exists but has no home dir. Return - * "{Windows Drive}:/users/default". - */ - - GetWindowsDirectoryW(buf, MAX_PATH); - Tcl_UniCharToUtfDString(buf, 2, bufferPtr); - Tcl_DStringAppend(bufferPtr, "/users/default", -1); - } - result = Tcl_DStringValue(bufferPtr); - netApiBufferFreeProc((void *) uiPtr); - } - Tcl_DStringFree(&ds); - } - if (wDomain != NULL) { - netApiBufferFreeProc((void *) wDomain); + GetWindowsDirectoryW(buf, MAX_PATH); + Tcl_UniCharToUtfDString(buf, 2, bufferPtr); + Tcl_DStringAppend(bufferPtr, "/users/default", -1); } + result = Tcl_DStringValue(bufferPtr); + NetApiBufferFree((void *) uiPtr); } - FreeLibrary(netapiInst); + Tcl_DStringFree(&ds); + } + if (wDomain != NULL) { + NetApiBufferFree((void *) wDomain); } if (result == NULL) { /* @@ -1516,18 +1486,18 @@ NativeAccess( { DWORD attr; - attr = tclWinProcs->getFileAttributesProc(nativePath); + attr = GetFileAttributes(nativePath); if (attr == INVALID_FILE_ATTRIBUTES) { /* * File might not exist. */ - WIN32_FIND_DATAT ffd; + WIN32_FIND_DATA ffd; HANDLE hFind; - hFind = tclWinProcs->findFirstFileProc(nativePath, &ffd); + hFind = FindFirstFile(nativePath, &ffd); if (hFind != INVALID_HANDLE_VALUE) { - attr = ffd.w.dwFileAttributes; + attr = ffd.dwFileAttributes; FindClose(hFind); } else { TclWinConvertError(GetLastError()); @@ -1535,19 +1505,20 @@ NativeAccess( } } +#ifndef UNICODE if ((mode & W_OK) - && (tclWinProcs->getFileSecurityProc == NULL) && (attr & FILE_ATTRIBUTE_READONLY)) { /* - * We don't have the advanced 'getFileSecurityProc', and our + * We don't have the advanced 'GetFileSecurity', and our * attributes say the file is not writable. If we do have - * 'getFileSecurityProc', we'll do a more robust XP-related check + * 'GetFileSecurity', we'll do a more robust XP-related check * below. */ Tcl_SetErrno(EACCES); return -1; } +#endif /* !UNICODE */ if (mode & X_OK) { if (!(attr & FILE_ATTRIBUTE_DIRECTORY) && !NativeIsExec(nativePath)) { @@ -1572,7 +1543,7 @@ NativeAccess( * readable' is 5-6 times slower than 'file exists'). */ - if ((mode != F_OK) && (tclWinProcs->getFileSecurityProc != NULL)) { + if (mode != F_OK) { SECURITY_DESCRIPTOR *sdPtr = NULL; unsigned long size; GENERIC_MAPPING genMap; @@ -1588,7 +1559,7 @@ NativeAccess( */ size = 0; - tclWinProcs->getFileSecurityProc(nativePath, + GetFileSecurity(nativePath, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, 0, 0, &size); @@ -1621,7 +1592,7 @@ NativeAccess( * Call GetFileSecurity() for real. */ - if (!tclWinProcs->getFileSecurityProc(nativePath, + if (!GetFileSecurity(nativePath, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, sdPtr, size, &size)) { /* @@ -1636,14 +1607,14 @@ NativeAccess( * thread token. */ - if (!tclWinProcs->impersonateSelfProc(SecurityImpersonation)) { + if (!ImpersonateSelf(SecurityImpersonation)) { /* * Unable to perform security impersonation. */ goto accessError; } - if (!tclWinProcs->openThreadTokenProc(GetCurrentThread(), + if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken)) { /* * Unable to get current thread's token. @@ -1652,7 +1623,7 @@ NativeAccess( goto accessError; } - tclWinProcs->revertToSelfProc(); + RevertToSelf(); /* * Setup desiredAccess according to the access priveleges we are @@ -1679,7 +1650,7 @@ NativeAccess( * Perform access check using the token. */ - if (!tclWinProcs->accessCheckProc(sdPtr, hToken, desiredAccess, + if (!AccessCheck(sdPtr, hToken, desiredAccess, &genMap, &privSet, &privSetSize, &grantedAccess, &accessYesNo)) { /* @@ -1795,12 +1766,12 @@ TclpObjChdir( * Cygwin chdir only groks POSIX path. */ - path = tclWinProcs->tchar2utf(nativePath, -1, &ds); + path = Tcl_WinTCharToUtf(nativePath, -1, &ds); cygwin_conv_to_posix_path(path, posixPath); result = (chdir(posixPath) == 0 ? 1 : 0); Tcl_DStringFree(&ds); #else /* __CYGWIN__ */ - result = tclWinProcs->setCurrentDirectoryProc(nativePath); + result = SetCurrentDirectory(nativePath); #endif /* __CYGWIN__ */ if (result == 0) { @@ -1887,7 +1858,7 @@ TclpGetCwd( char *p; WCHAR *native; - if (tclWinProcs->getCurrentDirectoryProc(MAX_PATH, buffer) == 0) { + if (GetCurrentDirectory(MAX_PATH, buffer) == 0) { TclWinConvertError(GetLastError()); if (interp != NULL) { Tcl_AppendResult(interp, "error getting working directory name: ", @@ -1905,7 +1876,7 @@ TclpGetCwd( && (native[2] == '\\') && (native[3] == '\\')) { native += 2; } - tclWinProcs->tchar2utf((TCHAR *) native, -1, bufferPtr); + Tcl_WinTCharToUtf((TCHAR *) native, -1, bufferPtr); /* * Convert to forward slashes for easier use in scripts. @@ -1979,7 +1950,7 @@ NativeStat( * simpler routines. */ - fileHandle = tclWinProcs->createFileProc(nativePath, GENERIC_READ, + fileHandle = CreateFile(nativePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL); @@ -2018,23 +1989,23 @@ NativeStat( */ inode = data.nFileIndexHigh | data.nFileIndexLow; - } else if (tclWinProcs->getFileAttributesExProc != NULL) { + } else { /* * Fall back on the less capable routines. This means no nlink or ino. */ WIN32_FILE_ATTRIBUTE_DATA data; - if (tclWinProcs->getFileAttributesExProc(nativePath, + if (GetFileAttributesEx(nativePath, GetFileExInfoStandard, &data) != TRUE) { /* * We might have just been denied access */ - WIN32_FIND_DATAT ffd; + WIN32_FIND_DATA ffd; HANDLE hFind; - hFind = tclWinProcs->findFirstFileProc(nativePath, &ffd); + hFind = FindFirstFile(nativePath, &ffd); if (hFind != INVALID_HANDLE_VALUE) { memcpy(&data, &ffd, sizeof(data)); FindClose(hFind); @@ -2051,46 +2022,6 @@ NativeStat( statPtr->st_atime = ToCTime(data.ftLastAccessTime); statPtr->st_mtime = ToCTime(data.ftLastWriteTime); statPtr->st_ctime = ToCTime(data.ftCreationTime); - } else { - /* - * We don't have the faster attributes proc, so we're probably running - * on Win95. - */ - - WIN32_FIND_DATAT data; - HANDLE handle; - - handle = tclWinProcs->findFirstFileProc(nativePath, &data); - if (handle == INVALID_HANDLE_VALUE) { - /* - * FindFirstFile() doesn't work on root directories, so call - * GetFileAttributes() to see if the specified file exists. - */ - - attr = tclWinProcs->getFileAttributesProc(nativePath); - if (attr == INVALID_FILE_ATTRIBUTES) { - Tcl_SetErrno(ENOENT); - return -1; - } - - /* - * Make up some fake information for this file. It has the correct - * file attributes and a time of 0. - */ - - memset(&data, 0, sizeof(data)); - data.a.dwFileAttributes = attr; - } else { - FindClose(handle); - } - - attr = data.a.dwFileAttributes; - - statPtr->st_size = ((Tcl_WideInt) data.a.nFileSizeLow) | - (((Tcl_WideInt) data.a.nFileSizeHigh) << 32); - statPtr->st_atime = ToCTime(data.a.ftLastAccessTime); - statPtr->st_mtime = ToCTime(data.a.ftLastWriteTime); - statPtr->st_ctime = ToCTime(data.a.ftCreationTime); } dev = NativeDev(nativePath); @@ -2126,10 +2057,10 @@ NativeDev( TCHAR *nativePart; const char *fullPath; - tclWinProcs->getFullPathNameProc(nativePath, MAX_PATH, nativeFullPath, + GetFullPathName(nativePath, MAX_PATH, nativeFullPath, &nativePart); - fullPath = tclWinProcs->tchar2utf(nativeFullPath, -1, &ds); + fullPath = Tcl_WinTCharToUtf(nativeFullPath, -1, &ds); if ((fullPath[0] == '\\') && (fullPath[1] == '\\')) { const char *p; @@ -2150,9 +2081,9 @@ NativeDev( } else { p++; } - nativeVol = tclWinProcs->utf2tchar(fullPath, p - fullPath, &volString); + nativeVol = Tcl_WinUtfToTChar(fullPath, p - fullPath, &volString); dw = (DWORD) -1; - tclWinProcs->getVolumeInformationProc(nativeVol, NULL, 0, &dw, NULL, + GetVolumeInformation(nativeVol, NULL, 0, &dw, NULL, NULL, NULL, 0); /* @@ -2298,13 +2229,13 @@ TclpGetNativeCwd( { TCHAR buffer[MAX_PATH]; - if (tclWinProcs->getCurrentDirectoryProc(MAX_PATH, buffer) == 0) { + if (GetCurrentDirectory(MAX_PATH, buffer) == 0) { TclWinConvertError(GetLastError()); return NULL; } if (clientData != NULL) { - if (wcscmp((const WCHAR*)clientData, (const WCHAR*)buffer) == 0) { + if (_tcscmp((const TCHAR*)clientData, buffer) == 0) { return clientData; } } @@ -2415,14 +2346,14 @@ TclpFilesystemPathType( firstSeparator = strchr(path, '/'); if (firstSeparator == NULL) { - found = tclWinProcs->getVolumeInformationProc( + found = GetVolumeInformation( Tcl_FSGetNativePath(pathPtr), NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE); } else { Tcl_Obj *driveName = Tcl_NewStringObj(path, firstSeparator - path+1); Tcl_IncrRefCount(driveName); - found = tclWinProcs->getVolumeInformationProc( + found = GetVolumeInformation( Tcl_FSGetNativePath(driveName), NULL, 0, NULL, NULL, NULL, volType, VOL_BUF_SIZE); Tcl_DecrRefCount(driveName); @@ -2434,7 +2365,7 @@ TclpFilesystemPathType( Tcl_DString ds; Tcl_Obj *objPtr; - tclWinProcs->tchar2utf(volType, -1, &ds); + Tcl_WinTCharToUtf(volType, -1, &ds); objPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -2661,10 +2592,10 @@ TclpObjNormalizePath( */ WIN32_FILE_ATTRIBUTE_DATA data; - const TCHAR *nativePath = tclWinProcs->utf2tchar(path, + const TCHAR *nativePath = Tcl_WinUtfToTChar(path, currentPathEndPosition - path, &ds); - if (tclWinProcs->getFileAttributesExProc(nativePath, + if (GetFileAttributesEx(nativePath, GetFileExInfoStandard, &data) != TRUE) { /* * File doesn't exist. @@ -2856,8 +2787,8 @@ TclpObjNormalizePath( if (1) { WCHAR wpath[MAX_PATH]; const TCHAR *nativePath = - tclWinProcs->utf2tchar(path, lastValidPathEnd - path, &ds); - DWORD wpathlen = tclWinProcs->getLongPathNameProc(nativePath, + Tcl_WinUtfToTChar(path, lastValidPathEnd - path, &ds); + DWORD wpathlen = GetLongPathNameProc(nativePath, (TCHAR *) wpath, MAX_PATH); /* @@ -2887,7 +2818,7 @@ TclpObjNormalizePath( Tcl_DString dsTemp; - tclWinProcs->tchar2utf((const TCHAR *)Tcl_DStringValue(&dsNorm), + Tcl_WinTCharToUtf((const TCHAR *)Tcl_DStringValue(&dsNorm), Tcl_DStringLength(&dsNorm), &dsTemp); nextCheckpoint = Tcl_DStringLength(&dsTemp); if (*lastValidPathEnd != 0) { @@ -3065,7 +2996,7 @@ TclpNativeToNormalized( int len; char *copy, *p; - tclWinProcs->tchar2utf((const TCHAR *) clientData, -1, &ds); + Tcl_WinTCharToUtf((const TCHAR *) clientData, -1, &ds); copy = Tcl_DStringValue(&ds); len = Tcl_DStringLength(&ds); @@ -3159,7 +3090,7 @@ TclNativeCreateNativeRep( } } } - tclWinProcs->utf2tchar(str, len, &ds); + Tcl_WinUtfToTChar(str, len, &ds); len = Tcl_DStringLength(&ds) + sizeof(WCHAR); Tcl_DecrRefCount(validPathPtr); nativePathPtr = ckalloc((unsigned) len); @@ -3238,7 +3169,7 @@ TclpUtime( native = Tcl_FSGetNativePath(pathPtr); - attr = tclWinProcs->getFileAttributesProc(native); + attr = GetFileAttributes(native); if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY) { flags = FILE_FLAG_BACKUP_SEMANTICS; @@ -3249,7 +3180,7 @@ TclpUtime( * savings complications that utime gets wrong. */ - fileHandle = tclWinProcs->createFileProc(native, FILE_WRITE_ATTRIBUTES, + fileHandle = CreateFile(native, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, flags, NULL); if (fileHandle == INVALID_HANDLE_VALUE || diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 94aa045..0f6b572 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinInt.h,v 1.37 2010/09/09 14:30:20 nijtmans Exp $ + * RCS: @(#) $Id: tclWinInt.h,v 1.37.2.1 2010/10/20 01:50:19 kennykb Exp $ */ #ifndef _TCLWININT @@ -121,7 +121,7 @@ MODULE_SCOPE const TclWinProcs *const tclWinProcs; */ MODULE_SCOPE char TclWinDriveLetterForVolMountPoint( - const WCHAR *mountPoint); + const TCHAR *mountPoint); MODULE_SCOPE void TclWinEncodingsCleanup(); MODULE_SCOPE void TclWinInit(HINSTANCE hInst); MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle); diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 84b18b6..d9f56cb 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.83.2.1 2010/09/22 01:08:49 kennykb Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.83.2.2 2010/10/20 01:50:19 kennykb Exp $ */ #include "tclWinInt.h" @@ -478,14 +478,14 @@ TempFileName( * gets stored. */ { TCHAR *prefix = TEXT("TCL"); - if (tclWinProcs->getTempPathProc(MAX_PATH, name) != 0) { - if (tclWinProcs->getTempFileNameProc(name, prefix, 0, name) != 0) { + if (GetTempPath(MAX_PATH, name) != 0) { + if (GetTempFileName(name, prefix, 0, name) != 0) { return 1; } } name[0] = '.'; name[1] = '\0'; - return tclWinProcs->getTempFileNameProc(name, prefix, 0, name); + return GetTempFileName(name, prefix, 0, name); } /* @@ -589,7 +589,7 @@ TclpOpenFile( break; } - nativePath = tclWinProcs->utf2tchar(path, -1, &ds); + nativePath = Tcl_WinUtfToTChar(path, -1, &ds); /* * If the file is not being created, use the existing file attributes. @@ -597,7 +597,7 @@ TclpOpenFile( flags = 0; if (!(mode & O_CREAT)) { - flags = tclWinProcs->getFileAttributesProc(nativePath); + flags = GetFileAttributes(nativePath); if (flags == 0xFFFFFFFF) { flags = 0; } @@ -613,7 +613,7 @@ TclpOpenFile( * Now we get to create the file. */ - handle = tclWinProcs->createFileProc(nativePath, accessMode, shareMode, + handle = CreateFile(nativePath, accessMode, shareMode, NULL, createMode, flags, NULL); Tcl_DStringFree(&ds); @@ -670,7 +670,7 @@ TclpCreateTempFile( return NULL; } - handle = tclWinProcs->createFileProc((TCHAR *) name, + handle = CreateFile(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE, NULL); if (handle == INVALID_HANDLE_VALUE) { @@ -730,7 +730,7 @@ TclpCreateTempFile( TclWinConvertError(GetLastError()); CloseHandle(handle); - tclWinProcs->deleteFileProc((TCHAR *) name); + DeleteFile(name); return NULL; } @@ -1162,7 +1162,7 @@ TclpCreateProcess( BuildCommandLine(execPath, argc, argv, &cmdLine); - if (tclWinProcs->createProcessProc(NULL, + if (CreateProcess(NULL, (TCHAR *) Tcl_DStringValue(&cmdLine), NULL, NULL, TRUE, (DWORD) createFlags, NULL, NULL, &startInfo, &procInfo) == 0) { TclWinConvertError(GetLastError()); @@ -1319,9 +1319,9 @@ ApplicationType( for (i = 0; i < (int) (sizeof(extensions) / sizeof(extensions[0])); i++) { Tcl_DStringSetLength(&nameBuf, nameLen); Tcl_DStringAppend(&nameBuf, extensions[i], -1); - nativeName = tclWinProcs->utf2tchar(Tcl_DStringValue(&nameBuf), + nativeName = Tcl_WinUtfToTChar(Tcl_DStringValue(&nameBuf), Tcl_DStringLength(&nameBuf), &ds); - found = tclWinProcs->searchPathProc(NULL, nativeName, NULL, MAX_PATH, + found = SearchPath(NULL, nativeName, NULL, MAX_PATH, nativeFullPath, &rest); Tcl_DStringFree(&ds); if (found == 0) { @@ -1333,11 +1333,11 @@ ApplicationType( * known type. */ - attr = tclWinProcs->getFileAttributesProc(nativeFullPath); + attr = GetFileAttributes(nativeFullPath); if ((attr == 0xffffffff) || (attr & FILE_ATTRIBUTE_DIRECTORY)) { continue; } - strcpy(fullName, tclWinProcs->tchar2utf(nativeFullPath, -1, &ds)); + strcpy(fullName, Tcl_WinTCharToUtf(nativeFullPath, -1, &ds)); Tcl_DStringFree(&ds); ext = strrchr(fullName, '.'); @@ -1346,7 +1346,7 @@ ApplicationType( break; } - hFile = tclWinProcs->createFileProc(nativeFullPath, + hFile = CreateFile(nativeFullPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { @@ -1426,9 +1426,8 @@ ApplicationType( * application name from the arguments. */ - tclWinProcs->getShortPathNameProc(nativeFullPath, - nativeFullPath, MAX_PATH); - strcpy(fullName, tclWinProcs->tchar2utf(nativeFullPath, -1, &ds)); + GetShortPathName(nativeFullPath, nativeFullPath, MAX_PATH); + strcpy(fullName, Tcl_WinTCharToUtf(nativeFullPath, -1, &ds)); Tcl_DStringFree(&ds); } return applType; @@ -1544,7 +1543,7 @@ BuildCommandLine( } } Tcl_DStringFree(linePtr); - tclWinProcs->utf2tchar(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); + Tcl_WinUtfToTChar(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); Tcl_DStringFree(&ds); } @@ -3104,7 +3103,7 @@ TclpOpenTemporaryFile( } namePtr = (char *) name; - length = tclWinProcs->getTempPathProc(MAX_PATH, name); + length = GetTempPath(MAX_PATH, name); if (length == 0) { goto gotError; } @@ -3112,7 +3111,7 @@ TclpOpenTemporaryFile( if (basenameObj) { const char *string = Tcl_GetStringFromObj(basenameObj, &length); - tclWinProcs->utf2tchar(string, length, &buf); + Tcl_WinUtfToTChar(string, length, &buf); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)); namePtr += Tcl_DStringLength(&buf); Tcl_DStringFree(&buf); @@ -3132,12 +3131,12 @@ TclpOpenTemporaryFile( sprintf(number, "%d.TMP", counter); counter = (unsigned short) (counter + 1); - tclWinProcs->utf2tchar(number, strlen(number), &buf); + Tcl_WinUtfToTChar(number, strlen(number), &buf); Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf) + 1); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf) + 1); Tcl_DStringFree(&buf); - handle = tclWinProcs->createFileProc((TCHAR *) name, + handle = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, flags, NULL); } while (handle == INVALID_HANDLE_VALUE && --counter2 > 0 diff --git a/win/tclWinReg.c b/win/tclWinReg.c index 987099c..3bc4ae3 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.c @@ -11,15 +11,9 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinReg.c,v 1.54 2010/08/30 09:19:38 nijtmans Exp $ + * RCS: @(#) $Id: tclWinReg.c,v 1.54.2.1 2010/10/20 01:50:19 kennykb Exp $ */ -/* TODO: This file does not compile in UNICODE mode. - * See [Freq 2965056]: Windows build with -DUNICODE - */ -#undef UNICODE -#undef _UNICODE - #undef STATIC_BUILD #ifndef USE_TCL_STUBS # define USE_TCL_STUBS @@ -96,90 +90,6 @@ static const char *const typeNames[] = { static DWORD lastType = REG_RESOURCE_LIST; /* - * The following structures allow us to select between the Unicode and ASCII - * interfaces at run time based on whether Unicode APIs are available. The - * Unicode APIs are preferable because they will handle characters outside of - * the current code page. - */ - -typedef struct RegWinProcs { - int useWide; - - LONG (WINAPI *regConnectRegistryProc)(const TCHAR *, HKEY, PHKEY); - LONG (WINAPI *regCreateKeyExProc)(HKEY, const TCHAR *, DWORD, TCHAR *, - DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *, DWORD *); - LONG (WINAPI *regDeleteKeyProc)(HKEY, const TCHAR *); - LONG (WINAPI *regDeleteValueProc)(HKEY, const TCHAR *); - LONG (WINAPI *regEnumKeyProc)(HKEY, DWORD, TCHAR *, DWORD); - LONG (WINAPI *regEnumKeyExProc)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - TCHAR *, DWORD *, FILETIME *); - LONG (WINAPI *regEnumValueProc)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - DWORD *, BYTE *, DWORD *); - LONG (WINAPI *regOpenKeyExProc)(HKEY, const TCHAR *, DWORD, REGSAM, - HKEY *); - LONG (WINAPI *regQueryInfoKeyProc)(HKEY, TCHAR *, DWORD *, DWORD *, - DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, - FILETIME *); - LONG (WINAPI *regQueryValueExProc)(HKEY, const TCHAR *, DWORD *, DWORD *, - BYTE *, DWORD *); - LONG (WINAPI *regSetValueExProc)(HKEY, const TCHAR *, DWORD, DWORD, - const BYTE*, DWORD); -} RegWinProcs; - -static RegWinProcs *regWinProcs; - -static RegWinProcs asciiProcs = { - 0, - - (LONG (WINAPI *)(const TCHAR *, HKEY, PHKEY)) RegConnectRegistryA, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, TCHAR *, - DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *, - DWORD *)) RegCreateKeyExA, - (LONG (WINAPI *)(HKEY, const TCHAR *)) RegDeleteKeyA, - (LONG (WINAPI *)(HKEY, const TCHAR *)) RegDeleteValueA, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD)) RegEnumKeyA, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - TCHAR *, DWORD *, FILETIME *)) RegEnumKeyExA, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - DWORD *, BYTE *, DWORD *)) RegEnumValueA, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, REGSAM, - HKEY *)) RegOpenKeyExA, - (LONG (WINAPI *)(HKEY, TCHAR *, DWORD *, DWORD *, - DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, - FILETIME *)) RegQueryInfoKeyA, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD *, DWORD *, - BYTE *, DWORD *)) RegQueryValueExA, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, DWORD, - const BYTE*, DWORD)) RegSetValueExA, -}; - -static RegWinProcs unicodeProcs = { - 1, - - (LONG (WINAPI *)(const TCHAR *, HKEY, PHKEY)) RegConnectRegistryW, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, TCHAR *, - DWORD, REGSAM, SECURITY_ATTRIBUTES *, HKEY *, - DWORD *)) RegCreateKeyExW, - (LONG (WINAPI *)(HKEY, const TCHAR *)) RegDeleteKeyW, - (LONG (WINAPI *)(HKEY, const TCHAR *)) RegDeleteValueW, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD)) RegEnumKeyW, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - TCHAR *, DWORD *, FILETIME *)) RegEnumKeyExW, - (LONG (WINAPI *)(HKEY, DWORD, TCHAR *, DWORD *, DWORD *, - DWORD *, BYTE *, DWORD *)) RegEnumValueW, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, REGSAM, - HKEY *)) RegOpenKeyExW, - (LONG (WINAPI *)(HKEY, TCHAR *, DWORD *, DWORD *, - DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, DWORD *, - FILETIME *)) RegQueryInfoKeyW, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD *, DWORD *, - BYTE *, DWORD *)) RegQueryValueExW, - (LONG (WINAPI *)(HKEY, const TCHAR *, DWORD, DWORD, - const BYTE*, DWORD)) RegSetValueExW, -}; - - -/* * Declarations for functions defined in this file. */ @@ -240,21 +150,12 @@ int Registry_Init( Tcl_Interp *interp) { - int useWide; Tcl_Command cmd; if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { return TCL_ERROR; } - /* - * Determine if the unicode interfaces are available and select the - * appropriate registry function table. - */ - - useWide = (TclWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS); - regWinProcs = useWide ? &unicodeProcs : &asciiProcs; - cmd = Tcl_CreateObjCommand(interp, "registry", RegistryObjCmd, interp, DeleteCmd); Tcl_SetAssocData(interp, REGISTRY_ASSOC_KEY, NULL, cmd); @@ -498,7 +399,7 @@ DeleteKey( REGSAM mode) /* Mode flags to pass. */ { char *tail, *buffer, *hostName, *keyName; - const char *nativeTail; + const TCHAR *nativeTail; HKEY rootKey, subkey; DWORD result; int length; @@ -609,7 +510,7 @@ DeleteValue( valueName = Tcl_GetStringFromObj(valueNameObj, &length); Tcl_WinUtfToTChar(valueName, length, &ds); - result = regWinProcs->regDeleteValueProc(key, Tcl_DStringValue(&ds)); + result = RegDeleteValue(key, (const TCHAR *)Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); if (result != ERROR_SUCCESS) { Tcl_AppendResult(interp, "unable to delete value \"", @@ -654,7 +555,7 @@ GetKeyNames( HKEY key; /* Handle to the key being examined */ DWORD subKeyCount; /* Number of subkeys to list */ DWORD maxSubKeyLen; /* Maximum string length of any subkey */ - char *buffer; /* Buffer to hold the subkey name */ + TCHAR *buffer; /* Buffer to hold the subkey name */ DWORD bufSize; /* Size of the buffer */ DWORD index; /* Position of the current subkey */ char *name; /* Subkey name */ @@ -682,7 +583,7 @@ GetKeyNames( * many subkeys there are. */ - result = regWinProcs->regQueryInfoKeyProc(key, NULL, NULL, NULL, + result = RegQueryInfoKey(key, NULL, NULL, NULL, &subKeyCount, &maxSubKeyLen, NULL, NULL, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) { Tcl_SetObjResult(interp, Tcl_NewObj()); @@ -692,11 +593,7 @@ GetKeyNames( RegCloseKey(key); return TCL_ERROR; } - if (regWinProcs->useWide) { - buffer = ckalloc((maxSubKeyLen+1) * sizeof(WCHAR)); - } else { - buffer = ckalloc(maxSubKeyLen+1); - } + buffer = (TCHAR *) ckalloc((maxSubKeyLen+1) * sizeof(TCHAR)); /* * Enumerate the subkeys. @@ -705,7 +602,7 @@ GetKeyNames( resultPtr = Tcl_NewObj(); for (index = 0; index < subKeyCount; ++index) { bufSize = maxSubKeyLen+1; - result = regWinProcs->regEnumKeyExProc(key, index, buffer, &bufSize, + result = RegEnumKeyEx(key, index, buffer, &bufSize, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) { Tcl_SetObjResult(interp, Tcl_NewObj()); @@ -715,11 +612,7 @@ GetKeyNames( result = TCL_ERROR; break; } - if (regWinProcs->useWide) { - Tcl_WinTCharToUtf((TCHAR *) buffer, bufSize * sizeof(WCHAR), &ds); - } else { - Tcl_WinTCharToUtf((TCHAR *) buffer, bufSize, &ds); - } + Tcl_WinTCharToUtf(buffer, bufSize * sizeof(WCHAR), &ds); name = Tcl_DStringValue(&ds); if (pattern && !Tcl_StringMatch(name, pattern)) { Tcl_DStringFree(&ds); @@ -736,7 +629,7 @@ GetKeyNames( Tcl_SetObjResult(interp, resultPtr); } - ckfree(buffer); + ckfree((char *)buffer); RegCloseKey(key); return result; } @@ -768,7 +661,8 @@ GetType( HKEY key; DWORD result, type; Tcl_DString ds; - const char *valueName, *nativeValue; + const char *valueName; + const TCHAR *nativeValue; int length; /* @@ -786,7 +680,7 @@ GetType( valueName = Tcl_GetStringFromObj(valueNameObj, &length); nativeValue = Tcl_WinUtfToTChar(valueName, length, &ds); - result = regWinProcs->regQueryValueExProc(key, nativeValue, NULL, &type, + result = RegQueryValueEx(key, nativeValue, NULL, &type, NULL, NULL); Tcl_DStringFree(&ds); RegCloseKey(key); @@ -837,7 +731,8 @@ GetValue( REGSAM mode) /* Mode flags to pass. */ { HKEY key; - const char *valueName, *nativeValue; + const char *valueName; + const TCHAR *nativeValue; DWORD result, length, type; Tcl_DString data, buf; int nameLen; @@ -868,7 +763,7 @@ GetValue( valueName = Tcl_GetStringFromObj(valueNameObj, &nameLen); nativeValue = Tcl_WinUtfToTChar(valueName, nameLen, &buf); - result = regWinProcs->regQueryValueExProc(key, nativeValue, NULL, &type, + result = RegQueryValueEx(key, nativeValue, NULL, &type, (BYTE *) Tcl_DStringValue(&data), &length); while (result == ERROR_MORE_DATA) { /* @@ -879,7 +774,7 @@ GetValue( length *= 2; Tcl_DStringSetLength(&data, (int) length); - result = regWinProcs->regQueryValueExProc(key, (char *) nativeValue, + result = RegQueryValueEx(key, nativeValue, NULL, &type, (BYTE *) Tcl_DStringValue(&data), &length); } Tcl_DStringFree(&buf); @@ -915,19 +810,16 @@ GetValue( */ while ((p < end) - && (regWinProcs->useWide ? *((Tcl_UniChar *) p) : *p) != 0) { + && (*((Tcl_UniChar *) p)) != 0) { + Tcl_UniChar *up; Tcl_WinTCharToUtf((TCHAR *) p, -1, &buf); Tcl_ListObjAppendElement(interp, resultPtr, Tcl_NewStringObj(Tcl_DStringValue(&buf), Tcl_DStringLength(&buf))); - if (regWinProcs->useWide) { - Tcl_UniChar *up = (Tcl_UniChar *) p; + up = (Tcl_UniChar *) p; - while (*up++ != 0) {} - p = (char *) up; - } else { - while (*p++ != '\0') {} - } + while (*up++ != 0) {} + p = (char *) up; Tcl_DStringFree(&buf); } Tcl_SetObjResult(interp, resultPtr); @@ -992,7 +884,7 @@ GetValueNames( * largest value name plus the terminating null. */ - result = regWinProcs->regQueryInfoKeyProc(key, NULL, NULL, NULL, NULL, + result = RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL, &index, &maxSize, NULL, NULL, NULL); if (result != ERROR_SUCCESS) { Tcl_AppendResult(interp, "unable to query key \"", @@ -1007,7 +899,7 @@ GetValueNames( resultPtr = Tcl_NewObj(); Tcl_DStringInit(&buffer); Tcl_DStringSetLength(&buffer, - (int) (regWinProcs->useWide ? maxSize*2 : maxSize)); + (int) (maxSize*sizeof(WCHAR))); index = 0; result = TCL_OK; @@ -1024,11 +916,9 @@ GetValueNames( */ size = maxSize; - while (regWinProcs->regEnumValueProc(key,index, Tcl_DStringValue(&buffer), + while (RegEnumValue(key,index, (TCHAR *)Tcl_DStringValue(&buffer), &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - if (regWinProcs->useWide) { - size *= 2; - } + size *= 2; Tcl_WinTCharToUtf((TCHAR *) Tcl_DStringValue(&buffer), (int) size, &ds); @@ -1141,7 +1031,7 @@ OpenSubKey( if (hostName) { hostName = (char *) Tcl_WinUtfToTChar(hostName, -1, &buf); - result = regWinProcs->regConnectRegistryProc(hostName, rootKey, + result = RegConnectRegistry((TCHAR *)hostName, rootKey, &rootKey); Tcl_DStringFree(&buf); if (result != ERROR_SUCCESS) { @@ -1158,7 +1048,7 @@ OpenSubKey( if (flags & REG_CREATE) { DWORD create; - result = regWinProcs->regCreateKeyExProc(rootKey, keyName, 0, NULL, + result = RegCreateKeyEx(rootKey, (TCHAR *)keyName, 0, NULL, REG_OPTION_NON_VOLATILE, mode, NULL, keyPtr, &create); } else if (rootKey == HKEY_PERFORMANCE_DATA) { /* @@ -1169,7 +1059,7 @@ OpenSubKey( *keyPtr = HKEY_PERFORMANCE_DATA; result = ERROR_SUCCESS; } else { - result = regWinProcs->regOpenKeyExProc(rootKey, keyName, 0, mode, + result = RegOpenKeyEx(rootKey, (TCHAR *)keyName, 0, mode, keyPtr); } Tcl_DStringFree(&buf); @@ -1286,7 +1176,7 @@ ParseKeyName( static DWORD RecursiveDeleteKey( HKEY startKey, /* Parent of key to be deleted. */ - const char *keyName, /* Name of key to be deleted in external + const TCHAR *keyName, /* Name of key to be deleted in external * encoding, not UTF. */ REGSAM mode) /* Mode flags to pass. */ { @@ -1306,11 +1196,11 @@ RecursiveDeleteKey( } mode |= KEY_ENUMERATE_SUB_KEYS | DELETE | KEY_QUERY_VALUE; - result = regWinProcs->regOpenKeyExProc(startKey, keyName, 0, mode, &hKey); + result = RegOpenKeyEx(startKey, keyName, 0, mode, &hKey); if (result != ERROR_SUCCESS) { return result; } - result = regWinProcs->regQueryInfoKeyProc(hKey, NULL, NULL, NULL, NULL, + result = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, &maxSize, NULL, NULL, NULL, NULL, NULL, NULL); maxSize++; if (result != ERROR_SUCCESS) { @@ -1319,7 +1209,7 @@ RecursiveDeleteKey( Tcl_DStringInit(&subkey); Tcl_DStringSetLength(&subkey, - (int) ((regWinProcs->useWide) ? maxSize * 2 : maxSize)); + (int) (maxSize * sizeof(WCHAR))); mode = saveMode; while (result == ERROR_SUCCESS) { @@ -1328,8 +1218,8 @@ RecursiveDeleteKey( */ size = maxSize; - result = regWinProcs->regEnumKeyExProc(hKey, 0, - Tcl_DStringValue(&subkey), &size, NULL, NULL, NULL, NULL); + result = RegEnumKeyEx(hKey, 0, (TCHAR *)Tcl_DStringValue(&subkey), + &size, NULL, NULL, NULL, NULL); if (result == ERROR_NO_MORE_ITEMS) { /* * RegDeleteKeyEx doesn't exist on non-64bit XP platforms, so we @@ -1341,25 +1231,20 @@ RecursiveDeleteKey( HINSTANCE dllH; checkExProc = 1; - dllH = LoadLibrary("advapi32.dll"); + dllH = LoadLibrary(TEXT("advapi32.dll")); if (dllH) { - if (regWinProcs->useWide) { - regDeleteKeyExProc = (FARPROC) - GetProcAddress(dllH, "RegDeleteKeyExW"); - } else { - regDeleteKeyExProc = (FARPROC) - GetProcAddress(dllH, "RegDeleteKeyExA"); - } + regDeleteKeyExProc = (FARPROC) + GetProcAddress(dllH, "RegDeleteKeyExW"); } } if (mode && regDeleteKeyExProc) { result = regDeleteKeyExProc(startKey, keyName, mode, 0); } else { - result = regWinProcs->regDeleteKeyProc(startKey, keyName); + result = RegDeleteKey(startKey, keyName); } break; } else if (result == ERROR_SUCCESS) { - result = RecursiveDeleteKey(hKey, Tcl_DStringValue(&subkey), + result = RecursiveDeleteKey(hKey, (const TCHAR *) Tcl_DStringValue(&subkey), mode); } } @@ -1416,7 +1301,7 @@ SetValue( } valueName = Tcl_GetStringFromObj(valueNameObj, &length); - valueName = Tcl_WinUtfToTChar(valueName, length, &nameBuf); + valueName = (char *) Tcl_WinUtfToTChar(valueName, length, &nameBuf); if (type == REG_DWORD || type == REG_DWORD_BIG_ENDIAN) { int value; @@ -1428,7 +1313,7 @@ SetValue( } value = ConvertDWORD((DWORD)type, (DWORD)value); - result = regWinProcs->regSetValueExProc(key, valueName, 0, + result = RegSetValueEx(key, (TCHAR *)valueName, 0, (DWORD) type, (BYTE *) &value, sizeof(DWORD)); } else if (type == REG_MULTI_SZ) { Tcl_DString data, buf; @@ -1463,7 +1348,7 @@ SetValue( Tcl_WinUtfToTChar(Tcl_DStringValue(&data), Tcl_DStringLength(&data)+1, &buf); - result = regWinProcs->regSetValueExProc(key, valueName, 0, + result = RegSetValueEx(key, (TCHAR *)valueName, 0, (DWORD) type, (BYTE *) Tcl_DStringValue(&buf), (DWORD) Tcl_DStringLength(&buf)); Tcl_DStringFree(&data); @@ -1472,18 +1357,16 @@ SetValue( Tcl_DString buf; const char *data = Tcl_GetStringFromObj(dataObj, &length); - data = Tcl_WinUtfToTChar(data, length, &buf); + data = (char *)Tcl_WinUtfToTChar(data, length, &buf); /* * Include the null in the length, padding if needed for Unicode. */ - if (regWinProcs->useWide) { - Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf)+1); - } + Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf)+1); length = Tcl_DStringLength(&buf) + 1; - result = regWinProcs->regSetValueExProc(key, valueName, 0, + result = RegSetValueEx(key, (TCHAR *)valueName, 0, (DWORD) type, (BYTE *) data, (DWORD) length); Tcl_DStringFree(&buf); } else { @@ -1494,7 +1377,7 @@ SetValue( */ data = (BYTE *) Tcl_GetByteArrayFromObj(dataObj, &length); - result = regWinProcs->regSetValueExProc(key, valueName, 0, + result = RegSetValueEx(key, (TCHAR *)valueName, 0, (DWORD) type, data, (DWORD) length); } @@ -1560,7 +1443,7 @@ BroadcastValue( * Use the ignore the result. */ - result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, + result = SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM) 0, (LPARAM) str, SMTO_ABORTIFHUNG, timeout, &sendResult); objPtr = Tcl_NewObj(); @@ -1594,7 +1477,7 @@ AppendSystemError( DWORD error) /* Result code from error. */ { int length; - WCHAR *wMsgPtr, **wMsgPtrPtr = &wMsgPtr; + TCHAR *tMsgPtr, **tMsgPtrPtr = &tMsgPtr; const char *msg; char id[TCL_INTEGER_SPACE], msgBuf[24 + TCL_INTEGER_SPACE]; Tcl_DString ds; @@ -1603,9 +1486,9 @@ AppendSystemError( if (Tcl_IsShared(resultPtr)) { resultPtr = Tcl_DuplicateObj(resultPtr); } - length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM + length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) wMsgPtrPtr, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (TCHAR *) tMsgPtrPtr, 0, NULL); if (length == 0) { char *msgPtr; @@ -1615,9 +1498,9 @@ AppendSystemError( MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char *) &msgPtr, 0, NULL); if (length > 0) { - wMsgPtr = (WCHAR *) - LocalAlloc(LPTR, (length + 1) * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, msgPtr, length + 1, wMsgPtr, + tMsgPtr = (TCHAR *) + LocalAlloc(LPTR, (length + 1) * sizeof(TCHAR)); + MultiByteToWideChar(CP_ACP, 0, msgPtr, length + 1, tMsgPtr, length + 1); LocalFree(msgPtr); } @@ -1634,9 +1517,9 @@ AppendSystemError( char *msgPtr; encoding = Tcl_GetEncoding(NULL, "unicode"); - Tcl_ExternalToUtfDString(encoding, (char *) wMsgPtr, -1, &ds); + Tcl_ExternalToUtfDString(encoding, (char *) tMsgPtr, -1, &ds); Tcl_FreeEncoding(encoding); - LocalFree(wMsgPtr); + LocalFree(tMsgPtr); msgPtr = Tcl_DStringValue(&ds); length = Tcl_DStringLength(&ds); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 66354c5..4f50a91 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSock.c,v 1.74.2.2 2010/09/28 15:43:01 kennykb Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.74.2.3 2010/10/20 01:50:19 kennykb Exp $ * * ----------------------------------------------------------------------- * @@ -118,7 +118,7 @@ typedef struct SocketInfo SocketInfo; typedef struct TcpFdList { SocketInfo *infoPtr; - int fd; + SOCKET fd; struct TcpFdList *next; } TcpFdList; @@ -1016,7 +1016,7 @@ CreateSocket( u_long flag = 1; /* Indicates nonblocking mode. */ int asyncConnect = 0; /* Will be 1 if async connect is in * progress. */ - int chosenport = 0; + unsigned short chosenport = 0; struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */ struct addrinfo *myaddrlist = NULL, *myaddrPtr; /* Socket address for client */ const char *errorMsg = NULL; diff --git a/win/tclWinTest.c b/win/tclWinTest.c index 1a1c9d2..73aaaae 100644 --- a/win/tclWinTest.c +++ b/win/tclWinTest.c @@ -8,15 +8,9 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinTest.c,v 1.27 2010/08/30 09:19:38 nijtmans Exp $ + * RCS: @(#) $Id: tclWinTest.c,v 1.27.2.1 2010/10/20 01:50:19 kennykb Exp $ */ -/* TODO: This file does not compile in UNICODE mode. - * See [Freq 2965056]: Windows build with -DUNICODE - */ -#undef UNICODE -#undef _UNICODE - #ifndef USE_TCL_STUBS # define USE_TCL_STUBS #endif @@ -486,28 +480,6 @@ TestplatformChmod( const char *nativePath, int pmode) { - typedef DWORD (WINAPI *getSidLengthRequiredDef)(UCHAR); - typedef BOOL (WINAPI *initializeSidDef)(PSID, PSID_IDENTIFIER_AUTHORITY, - BYTE); - typedef PDWORD (WINAPI *getSidSubAuthorityDef)(PSID, DWORD); - typedef DWORD (WINAPI *setNamedSecurityInfoADef)(IN LPSTR, - IN SE_OBJECT_TYPE, IN SECURITY_INFORMATION, IN PSID, IN PSID, - IN PACL, IN PACL); - typedef BOOL (WINAPI *getAceDef)(PACL, DWORD, LPVOID *); - typedef BOOL (WINAPI *addAceDef)(PACL, DWORD, DWORD, LPVOID, DWORD); - typedef BOOL (WINAPI *equalSidDef)(PSID, PSID); - typedef BOOL (WINAPI *addAccessDeniedAceDef)(PACL, DWORD, DWORD, PSID); - typedef BOOL (WINAPI *initializeAclDef)(PACL, DWORD, DWORD); - typedef DWORD (WINAPI *getLengthSidDef)(PSID); - typedef BOOL (WINAPI *getAclInformationDef)(PACL, LPVOID, DWORD, - ACL_INFORMATION_CLASS); - typedef BOOL (WINAPI *getSecurityDescriptorDaclDef)(PSECURITY_DESCRIPTOR, - LPBOOL, PACL *, LPBOOL); - typedef BOOL (WINAPI *lookupAccountNameADef)(LPCSTR, LPCSTR, PSID, - PDWORD, LPSTR, LPDWORD, PSID_NAME_USE); - typedef BOOL (WINAPI *getFileSecurityADef)(LPCSTR, SECURITY_INFORMATION, - PSECURITY_DESCRIPTOR, DWORD, LPDWORD); - static const SECURITY_INFORMATION infoBits = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION; static const DWORD readOnlyMask = FILE_DELETE_CHILD | FILE_ADD_FILE @@ -518,22 +490,6 @@ TestplatformChmod( * References to security functions (only available on NT and later). */ - static getSidLengthRequiredDef getSidLengthRequiredProc; - static initializeSidDef initializeSidProc; - static getSidSubAuthorityDef getSidSubAuthorityProc; - static setNamedSecurityInfoADef setNamedSecurityInfoProc; - static getAceDef getAceProc; - static addAceDef addAceProc; - static equalSidDef equalSidProc; - static addAccessDeniedAceDef addAccessDeniedAceProc; - static initializeAclDef initializeAclProc; - static getLengthSidDef getLengthSidProc; - static getAclInformationDef getAclInformationProc; - static getSecurityDescriptorDaclDef getSecurityDescriptorDaclProc; - static lookupAccountNameADef lookupAccountNameProc; - static getFileSecurityADef getFileSecurityProc; - static int initialized = 0; - const BOOL set_readOnly = !(pmode & 0222); BOOL acl_readOnly_found = FALSE, curAclPresent, curAclDefaulted; SID_IDENTIFIER_AUTHORITY userSidAuthority = { @@ -545,72 +501,14 @@ TestplatformChmod( PACL curAcl, newAcl = 0; WORD j; SID *userSid = 0; - TCHAR *userDomain = 0; + char *userDomain = 0; int res = 0; /* - * One time initialization, dynamically load Windows NT features - */ - - if (!initialized) { - TCL_DECLARE_MUTEX(initializeMutex) - Tcl_MutexLock(&initializeMutex); - if (!initialized) { - HINSTANCE hInstance = LoadLibrary("Advapi32"); - - if (hInstance != NULL) { - setNamedSecurityInfoProc = (setNamedSecurityInfoADef) - GetProcAddress(hInstance, "SetNamedSecurityInfoA"); - getFileSecurityProc = (getFileSecurityADef) - GetProcAddress(hInstance, "GetFileSecurityA"); - getAceProc = (getAceDef) - GetProcAddress(hInstance, "GetAce"); - addAceProc = (addAceDef) - GetProcAddress(hInstance, "AddAce"); - equalSidProc = (equalSidDef) - GetProcAddress(hInstance, "EqualSid"); - addAccessDeniedAceProc = (addAccessDeniedAceDef) - GetProcAddress(hInstance, "AddAccessDeniedAce"); - initializeAclProc = (initializeAclDef) - GetProcAddress(hInstance, "InitializeAcl"); - getLengthSidProc = (getLengthSidDef) - GetProcAddress(hInstance, "GetLengthSid"); - getAclInformationProc = (getAclInformationDef) - GetProcAddress(hInstance, "GetAclInformation"); - getSecurityDescriptorDaclProc = (getSecurityDescriptorDaclDef) - GetProcAddress(hInstance, "GetSecurityDescriptorDacl"); - lookupAccountNameProc = (lookupAccountNameADef) - GetProcAddress(hInstance, "LookupAccountNameA"); - getSidLengthRequiredProc = (getSidLengthRequiredDef) - GetProcAddress(hInstance, "GetSidLengthRequired"); - initializeSidProc = (initializeSidDef) - GetProcAddress(hInstance, "InitializeSid"); - getSidSubAuthorityProc = (getSidSubAuthorityDef) - GetProcAddress(hInstance, "GetSidSubAuthority"); - - if (setNamedSecurityInfoProc && getAceProc && addAceProc - && equalSidProc && addAccessDeniedAceProc - && initializeAclProc && getLengthSidProc - && getAclInformationProc - && getSecurityDescriptorDaclProc - && lookupAccountNameProc && getFileSecurityProc - && getSidLengthRequiredProc && initializeSidProc - && getSidSubAuthorityProc) { - initialized = 1; - } - } - if (!initialized) { - initialized = -1; - } - } - Tcl_MutexUnlock(&initializeMutex); - } - - /* * Process the chmod request. */ - attr = GetFileAttributes(nativePath); + attr = GetFileAttributesA(nativePath); /* * nativePath not found @@ -622,11 +520,10 @@ TestplatformChmod( } /* - * If no ACL API is present or nativePath is not a directory, there is no - * special handling. + * If nativePath is not a directory, there is no special handling. */ - if (initialized < 0 || !(attr & FILE_ATTRIBUTE_DIRECTORY)) { + if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) { goto done; } @@ -642,7 +539,7 @@ TestplatformChmod( * obtains the size of the security descriptor. */ - if (!getFileSecurityProc(nativePath, infoBits, NULL, 0, &secDescLen)) { + if (!GetFileSecurityA(nativePath, infoBits, NULL, 0, &secDescLen)) { DWORD secDescLen2 = 0; if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { @@ -650,7 +547,7 @@ TestplatformChmod( } secDesc = (BYTE *) ckalloc(secDescLen); - if (!getFileSecurityProc(nativePath, infoBits, + if (!GetFileSecurityA(nativePath, infoBits, (PSECURITY_DESCRIPTOR) secDesc, secDescLen, &secDescLen2) || (secDescLen < secDescLen2)) { goto done; @@ -661,22 +558,22 @@ TestplatformChmod( * Get the World SID. */ - userSid = (SID *) ckalloc(getSidLengthRequiredProc((UCHAR) 1)); - initializeSidProc(userSid, &userSidAuthority, (BYTE) 1); - *(getSidSubAuthorityProc(userSid, 0)) = SECURITY_WORLD_RID; + userSid = (SID *) ckalloc(GetSidLengthRequired((UCHAR) 1)); + InitializeSid(userSid, &userSidAuthority, (BYTE) 1); + *(GetSidSubAuthority(userSid, 0)) = SECURITY_WORLD_RID; /* * If curAclPresent == false then curAcl and curAclDefaulted not valid. */ - if (!getSecurityDescriptorDaclProc((PSECURITY_DESCRIPTOR) secDesc, + if (!GetSecurityDescriptorDacl((PSECURITY_DESCRIPTOR) secDesc, &curAclPresent, &curAcl, &curAclDefaulted)) { goto done; } if (!curAclPresent || !curAcl) { ACLSize.AclBytesInUse = 0; ACLSize.AceCount = 0; - } else if (!getAclInformationProc(curAcl, &ACLSize, sizeof(ACLSize), + } else if (!GetAclInformation(curAcl, &ACLSize, sizeof(ACLSize), AclSizeInformation)) { goto done; } @@ -686,14 +583,14 @@ TestplatformChmod( */ newAclSize = ACLSize.AclBytesInUse + sizeof(ACCESS_DENIED_ACE) - + getLengthSidProc(userSid) - sizeof(DWORD); + + GetLengthSid(userSid) - sizeof(DWORD); newAcl = (ACL *) ckalloc(newAclSize); /* * Initialize the new ACL. */ - if (!initializeAclProc(newAcl, newAclSize, ACL_REVISION)) { + if (!InitializeAcl(newAcl, newAclSize, ACL_REVISION)) { goto done; } @@ -701,7 +598,7 @@ TestplatformChmod( * Add denied to make readonly, this will be known as a "read-only tag". */ - if (set_readOnly && !addAccessDeniedAceProc(newAcl, ACL_REVISION, + if (set_readOnly && !AddAccessDeniedAce(newAcl, ACL_REVISION, readOnlyMask, userSid)) { goto done; } @@ -711,7 +608,7 @@ TestplatformChmod( LPVOID pACE2; ACE_HEADER *phACE2; - if (!getAceProc(curAcl, j, &pACE2)) { + if (!GetAce(curAcl, j, &pACE2)) { goto done; } @@ -734,7 +631,7 @@ TestplatformChmod( ACCESS_DENIED_ACE *pACEd = (ACCESS_DENIED_ACE *) phACE2; if (pACEd->Mask == readOnlyMask - && equalSidProc(userSid, (PSID) &pACEd->SidStart)) { + && EqualSid(userSid, (PSID) &pACEd->SidStart)) { acl_readOnly_found = TRUE; continue; } @@ -744,7 +641,7 @@ TestplatformChmod( * Copy the current ACE from the old to the new ACL. */ - if (!addAceProc(newAcl, ACL_REVISION, MAXDWORD, (PACL *) pACE2, + if (!AddAce(newAcl, ACL_REVISION, MAXDWORD, (PACL *) pACE2, ((PACE_HEADER) pACE2)->AceSize)) { goto done; } @@ -754,7 +651,7 @@ TestplatformChmod( * Apply the new ACL. */ - if (set_readOnly == acl_readOnly_found || setNamedSecurityInfoProc( + if (set_readOnly == acl_readOnly_found || SetNamedSecurityInfoA( (LPSTR) nativePath, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, newAcl, NULL) == ERROR_SUCCESS) { res = 0; @@ -771,7 +668,7 @@ TestplatformChmod( ckfree((char *) userSid); } if (userDomain) { - ckfree(userDomain); + ckfree((char *) userDomain); } if (res != 0) { diff --git a/win/tclWinThrd.h b/win/tclWinThrd.h deleted file mode 100644 index 2572d1b..0000000 --- a/win/tclWinThrd.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * tclWinThrd.h -- - * - * This header file defines things for thread support. - * - * Copyright (c) 1998 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclWinThrd.h 1.2 98/01/27 11:48:05 - */ - -#ifndef _TCLWINTHRD -#define _TCLWINTHRD - -#ifdef TCL_THREADS - -#endif /* TCL_THREADS */ - -#endif /* _TCLWINTHRD */ |