summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tclWinChan.c33
-rw-r--r--win/tclWinConsole.c2
-rw-r--r--win/tclWinInt.h3
-rw-r--r--win/tclWinPipe.c2
-rw-r--r--win/tclWinSerial.c3
-rw-r--r--win/tclWinSock.c19
6 files changed, 44 insertions, 18 deletions
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index 8743afe..5f03138 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -145,6 +145,33 @@ static const Tcl_ChannelType fileChannelType = {
/*
*----------------------------------------------------------------------
*
+ * TclWinGenerateChannelName --
+ *
+ * This function generates names for channels.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Creates a new window and creates an exit handler.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+TclWinGenerateChannelName(
+ char channelName[], /* Buffer to accept the name. */
+ const char *channelTypeName,/* Name of type of channel. */
+ void *channelImpl) /* Pointer to channel implementation
+ * structure, used to generate a unique
+ * ID. */
+{
+ snprintf(channelName, 16 + TCL_INTEGER_SPACE, "%s%" TCL_Z_MODIFIER "x",
+ channelTypeName, (size_t) channelImpl);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* FileInit --
*
* This function creates the window used to simulate file events.
@@ -1488,7 +1515,8 @@ OpenFileChannel(
for (infoPtr = tsdPtr->firstFilePtr; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
if (infoPtr->handle == (HANDLE) handle) {
- return ((permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION))==infoPtr->validMask) ? infoPtr->channel : NULL;
+ return ((permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION))==infoPtr->validMask)
+ ? infoPtr->channel : NULL;
}
}
@@ -1506,8 +1534,7 @@ OpenFileChannel(
infoPtr->flags = appendMode;
infoPtr->handle = handle;
infoPtr->dirty = 0;
- snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
-
+ TclWinGenerateChannelName(channelName, "file", infoPtr);
infoPtr->channel = Tcl_CreateChannel(&fileChannelType, channelName,
infoPtr, permissions);
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c
index 5b30fc4..eb81370 100644
--- a/win/tclWinConsole.c
+++ b/win/tclWinConsole.c
@@ -2116,7 +2116,7 @@ TclWinOpenConsoleChannel(
* for instance).
*/
- snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) chanInfoPtr);
+ TclWinGenerateChannelName(channelName, "file", chanInfoPtr);
if (permissions & TCL_READABLE) {
/*
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index 1267f3f..6de1432 100644
--- a/win/tclWinInt.h
+++ b/win/tclWinInt.h
@@ -52,7 +52,8 @@ MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal,
MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal,
int linkOnly);
MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *);
-
+MODULE_SCOPE void TclWinGenerateChannelName(char channelName[],
+ const char *channelTypeName, void *channelImpl);
MODULE_SCOPE const char*TclpGetUserName(Tcl_DString *bufferPtr);
/* Needed by tclWinFile.c and tclWinFCmd.c */
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 5a18ee3..60764e6 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -1837,7 +1837,7 @@ TclpCreateCommandChannel(
* unique, in case channels share handles (stdin/stdout).
*/
- snprintf(channelName, sizeof(channelName), "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
+ TclWinGenerateChannelName(channelName, "file", infoPtr);
infoPtr->channel = Tcl_CreateChannel(&pipeChannelType, channelName,
infoPtr, infoPtr->validMask);
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c
index 48a0ffc..14f36fd 100644
--- a/win/tclWinSerial.c
+++ b/win/tclWinSerial.c
@@ -1476,8 +1476,7 @@ TclWinOpenSerialChannel(
* are shared between multiple channels (stdin/stdout).
*/
- snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
-
+ TclWinGenerateChannelName(channelName, "file", infoPtr);
infoPtr->channel = Tcl_CreateChannel(&serialChannelType, channelName,
infoPtr, permissions);
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index f54d8a1..3fab851 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -265,7 +265,7 @@ static Tcl_DriverGetHandleProc TcpGetHandleProc;
static const Tcl_ChannelType tcpChannelType = {
"tcp", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- NULL, /* Close proc. */
+ NULL, /* Close proc. */
TcpInputProc, /* Input proc. */
TcpOutputProc, /* Output proc. */
NULL, /* Seek proc. */
@@ -2022,8 +2022,7 @@ Tcl_OpenTcpClient(
return NULL;
}
- snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
-
+ TclWinGenerateChannelName(channelName, "sock", statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
if (TCL_ERROR == Tcl_SetChannelOption(NULL, statePtr->channel,
@@ -2056,7 +2055,7 @@ Tcl_OpenTcpClient(
Tcl_Channel
Tcl_MakeTcpClientChannel(
- void *sock) /* The socket to wrap up into a channel. */
+ void *sock) /* The socket to wrap up into a channel. */
{
TcpState *statePtr;
char channelName[SOCK_CHAN_LENGTH];
@@ -2081,7 +2080,7 @@ Tcl_MakeTcpClientChannel(
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
SendSelectMessage(tsdPtr, SELECT, statePtr);
- snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
+ TclWinGenerateChannelName(channelName, "sock", statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
Tcl_SetChannelOption(NULL, statePtr->channel, "-translation", "auto crlf");
@@ -2253,7 +2252,7 @@ Tcl_OpenTcpServerEx(
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
- snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
+ TclWinGenerateChannelName(channelName, "sock", statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, 0);
/*
@@ -2307,9 +2306,9 @@ Tcl_OpenTcpServerEx(
static void
TcpAccept(
- TcpFdList *fds, /* Server socket that accepted newSocket. */
- SOCKET newSocket, /* Newly accepted socket. */
- address addr) /* Address of new socket. */
+ TcpFdList *fds, /* Server socket that accepted newSocket. */
+ SOCKET newSocket, /* Newly accepted socket. */
+ address addr) /* Address of new socket. */
{
TcpState *newInfoPtr;
TcpState *statePtr = fds->statePtr;
@@ -2338,7 +2337,7 @@ TcpAccept(
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
SendSelectMessage(tsdPtr, SELECT, newInfoPtr);
- snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, newInfoPtr);
+ TclWinGenerateChannelName(channelName, "sock", statePtr);
newInfoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
newInfoPtr, (TCL_READABLE | TCL_WRITABLE));
if (Tcl_SetChannelOption(NULL, newInfoPtr->channel, "-translation",