Tcl Source Code

Artifact [9f0cca60d4]
Login

Artifact 9f0cca60d4365a7dcac4cc3d67b7bf22d62cec07:

Attachment "socket.patch" to ticket [507211ffff] added by dgp 2002-01-23 05:18:24.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.809
diff -u -u -r1.809 ChangeLog
--- ChangeLog	2002/01/21 22:50:49	1.809
+++ ChangeLog	2002/01/22 22:13:04
@@ -1,3 +1,21 @@
+2002-01-22  Don Porter <[email protected]>
+
+	* doc/GetHostName.3:
+	* doc/GetOpnFl.3:
+	* doc/OpenTcp.3:
+	* tcl.decls (Tcl_GetHostName,Tcl_GetOpenFile,Tcl_OpenTcpClient,
+	  Tcl_OpenTclServer):
+	* mac/tclMacSock.c (CreateSocket,Tcl_OpenTcpClient,Tcl_OpenTcpServer,
+	  Tcl_GetHostName,GetHostFromString):
+	* unix/tclUnixChan.c (CreateSocket,CreateSocketAddress,
+	  Tcl_OpenTcpClient,Tcl_OpenTcpServer,Tcl_GetOpenFile):
+	* unix/tclUnixSock.c (Tcl_GetHostName):
+	* win/tclWinSock.c (CreateSocket,CreateSocketAddress,
+	  Tcl_OpenTcpClient,Tcl_OpenTcpServer,Tcl_GetHostName):
+	Updated socket interfaces according to TIP 27.
+	* generic/tclCmdIL.c (InfoHostnameCmd): Updated callers.
+	* generic/tclDecls.h: make genstubs
+
 2002-01-21  David Gravereaux <[email protected]>
 
 	* generic/tclLoadNone.c: TclpLoadFile() didn't match proto of
Index: doc/GetHostName.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/GetHostName.3,v
retrieving revision 1.1
diff -u -u -r1.1 GetHostName.3
--- doc/GetHostName.3	2000/01/21 18:52:07	1.1
+++ doc/GetHostName.3	2002/01/22 22:13:04
@@ -13,7 +13,7 @@
 .nf
 \fB#include <tcl.h>\fR
 .sp
-char *
+CONST char *
 \fBTcl_GetHostName\fR()
 
 .SH DESCRIPTION
Index: doc/GetOpnFl.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/GetOpnFl.3,v
retrieving revision 1.3
diff -u -u -r1.3 GetOpnFl.3
--- doc/GetOpnFl.3	2000/04/14 23:01:51	1.3
+++ doc/GetOpnFl.3	2002/01/22 22:13:04
@@ -21,7 +21,7 @@
 .AS Tcl_Interp checkUsage
 .AP Tcl_Interp *interp in
 Tcl interpreter from which file handle is to be obtained.
-.AP char *string in
+.AP "CONST char" *string in
 String identifying channel, such as \fBstdin\fR or \fBfile4\fR.
 .AP int write in
 Non-zero means the file will be used for writing, zero means it will
Index: doc/OpenTcp.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/OpenTcp.3,v
retrieving revision 1.3
diff -u -u -r1.3 OpenTcp.3
--- doc/OpenTcp.3	2000/04/14 23:01:52	1.3
+++ doc/OpenTcp.3	2002/01/22 22:13:04
@@ -31,12 +31,12 @@
 error occurs, an error message is left in the interpreter's result.
 .AP int port in
 A port number to connect to as a client or to listen on as a server.
-.AP char *host in
+.AP "CONST char" *host in
 A string specifying a host name or address for the remote end of the connection.
 .AP int myport in
 A port number for the client's end of the socket.  If 0, a port number
 is allocated at random.
-.AP char *myaddr in
+.AP "CONST char" *myaddr in
 A string specifying the host name or address for network interface to use
 for the local end of the connection.  If NULL, a default interface is
 chosen.
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.76
diff -u -u -r1.76 tcl.decls
--- generic/tcl.decls	2002/01/21 16:15:03	1.76
+++ generic/tcl.decls	2002/01/22 22:13:05
@@ -581,7 +581,7 @@
     int Tcl_GetErrno(void)
 }
 declare 162 generic {
-    char * Tcl_GetHostName(void)
+    CONST char * Tcl_GetHostName(void)
 }
 declare 163 generic {
     int Tcl_GetInterpPath(Tcl_Interp *askInterp, Tcl_Interp *slaveInterp)
@@ -600,7 +600,7 @@
 # generic interface, so we inlcude it here for compatibility reasons.
 
 declare 167 unix {
-    int Tcl_GetOpenFile(Tcl_Interp *interp, char *str, int forWriting, \
+    int Tcl_GetOpenFile(Tcl_Interp *interp, CONST char *str, int forWriting, \
 	    int checkUsage, ClientData *filePtr)
 }
 # Obsolete.  Should now use Tcl_FSGetPathType which is objectified
@@ -710,11 +710,12 @@
 }
 declare 199 generic {
     Tcl_Channel Tcl_OpenTcpClient(Tcl_Interp *interp, int port, \
-	    char *address, char *myaddr, int myport, int async)
+	    CONST char *address, CONST char *myaddr, int myport, int async)
 }
 declare 200 generic {
-    Tcl_Channel Tcl_OpenTcpServer(Tcl_Interp *interp, int port, char *host, \
-	    Tcl_TcpAcceptProc *acceptProc, ClientData callbackData)
+    Tcl_Channel Tcl_OpenTcpServer(Tcl_Interp *interp, int port, \
+	    CONST char *host, Tcl_TcpAcceptProc *acceptProc, \
+	    ClientData callbackData)
 }
 declare 201 generic {
     void Tcl_Preserve(ClientData data)
Index: generic/tclCmdIL.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdIL.c,v
retrieving revision 1.37
diff -u -u -r1.37 tclCmdIL.c
--- generic/tclCmdIL.c	2002/01/17 04:37:33	1.37
+++ generic/tclCmdIL.c	2002/01/22 22:13:08
@@ -1074,7 +1074,7 @@
     int objc;			/* Number of arguments. */
     Tcl_Obj *CONST objv[];	/* Argument objects. */
 {
-    char *name;
+    CONST char *name;
     if (objc != 2) {
         Tcl_WrongNumArgs(interp, 2, objv, NULL);
         return TCL_ERROR;
Index: generic/tclDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDecls.h,v
retrieving revision 1.76
diff -u -u -r1.76 tclDecls.h
--- generic/tclDecls.h	2002/01/21 16:15:03	1.76
+++ generic/tclDecls.h	2002/01/22 22:13:16
@@ -535,7 +535,7 @@
 /* 161 */
 EXTERN int		Tcl_GetErrno _ANSI_ARGS_((void));
 /* 162 */
-EXTERN char *		Tcl_GetHostName _ANSI_ARGS_((void));
+EXTERN CONST char *	Tcl_GetHostName _ANSI_ARGS_((void));
 /* 163 */
 EXTERN int		Tcl_GetInterpPath _ANSI_ARGS_((
 				Tcl_Interp * askInterp, 
@@ -549,8 +549,8 @@
 #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
 /* 167 */
 EXTERN int		Tcl_GetOpenFile _ANSI_ARGS_((Tcl_Interp * interp, 
-				char * str, int forWriting, int checkUsage, 
-				ClientData * filePtr));
+				CONST char * str, int forWriting, 
+				int checkUsage, ClientData * filePtr));
 #endif /* UNIX */
 /* 168 */
 EXTERN Tcl_PathType	Tcl_GetPathType _ANSI_ARGS_((CONST char * path));
@@ -647,11 +647,11 @@
 				CONST char * modeString, int permissions));
 /* 199 */
 EXTERN Tcl_Channel	Tcl_OpenTcpClient _ANSI_ARGS_((Tcl_Interp * interp, 
-				int port, char * address, char * myaddr, 
-				int myport, int async));
+				int port, CONST char * address, 
+				CONST char * myaddr, int myport, int async));
 /* 200 */
 EXTERN Tcl_Channel	Tcl_OpenTcpServer _ANSI_ARGS_((Tcl_Interp * interp, 
-				int port, char * host, 
+				int port, CONST char * host, 
 				Tcl_TcpAcceptProc * acceptProc, 
 				ClientData callbackData));
 /* 201 */
@@ -1711,13 +1711,13 @@
     int (*tcl_GetCommandInfo) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * cmdName, Tcl_CmdInfo * infoPtr)); /* 159 */
     CONST char * (*tcl_GetCommandName) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Command command)); /* 160 */
     int (*tcl_GetErrno) _ANSI_ARGS_((void)); /* 161 */
-    char * (*tcl_GetHostName) _ANSI_ARGS_((void)); /* 162 */
+    CONST char * (*tcl_GetHostName) _ANSI_ARGS_((void)); /* 162 */
     int (*tcl_GetInterpPath) _ANSI_ARGS_((Tcl_Interp * askInterp, Tcl_Interp * slaveInterp)); /* 163 */
     Tcl_Interp * (*tcl_GetMaster) _ANSI_ARGS_((Tcl_Interp * interp)); /* 164 */
     CONST char * (*tcl_GetNameOfExecutable) _ANSI_ARGS_((void)); /* 165 */
     Tcl_Obj * (*tcl_GetObjResult) _ANSI_ARGS_((Tcl_Interp * interp)); /* 166 */
 #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */
-    int (*tcl_GetOpenFile) _ANSI_ARGS_((Tcl_Interp * interp, char * str, int forWriting, int checkUsage, ClientData * filePtr)); /* 167 */
+    int (*tcl_GetOpenFile) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * str, int forWriting, int checkUsage, ClientData * filePtr)); /* 167 */
 #endif /* UNIX */
 #ifdef __WIN32__
     void *reserved167;
@@ -1764,8 +1764,8 @@
     void *reserved197;
 #endif /* MAC_TCL */
     Tcl_Channel (*tcl_OpenFileChannel) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * fileName, CONST char * modeString, int permissions)); /* 198 */
-    Tcl_Channel (*tcl_OpenTcpClient) _ANSI_ARGS_((Tcl_Interp * interp, int port, char * address, char * myaddr, int myport, int async)); /* 199 */
-    Tcl_Channel (*tcl_OpenTcpServer) _ANSI_ARGS_((Tcl_Interp * interp, int port, char * host, Tcl_TcpAcceptProc * acceptProc, ClientData callbackData)); /* 200 */
+    Tcl_Channel (*tcl_OpenTcpClient) _ANSI_ARGS_((Tcl_Interp * interp, int port, CONST char * address, CONST char * myaddr, int myport, int async)); /* 199 */
+    Tcl_Channel (*tcl_OpenTcpServer) _ANSI_ARGS_((Tcl_Interp * interp, int port, CONST char * host, Tcl_TcpAcceptProc * acceptProc, ClientData callbackData)); /* 200 */
     void (*tcl_Preserve) _ANSI_ARGS_((ClientData data)); /* 201 */
     void (*tcl_PrintDouble) _ANSI_ARGS_((Tcl_Interp * interp, double value, char * dst)); /* 202 */
     int (*tcl_PutEnv) _ANSI_ARGS_((CONST char * string)); /* 203 */
Index: mac/tclMacSock.c
===================================================================
RCS file: /cvsroot/tcl/tcl/mac/tclMacSock.c,v
retrieving revision 1.10
diff -u -u -r1.10 tclMacSock.c
--- mac/tclMacSock.c	2002/01/15 17:55:30	1.10
+++ mac/tclMacSock.c	2002/01/22 22:13:18
@@ -138,14 +138,14 @@
 static void		ClearZombieSockets _ANSI_ARGS_((void));
 static void		CloseCompletionRoutine _ANSI_ARGS_((TCPiopb *pb));
 static TcpState *	CreateSocket _ANSI_ARGS_((Tcl_Interp *interp,
-			    int port, char *host, char *myAddr,  int myPort,
-			    int server, int async));
+			    int port, CONST char *host, CONST char *myAddr,
+			    int myPort, int server, int async));
 static pascal void	DNRCompletionRoutine _ANSI_ARGS_((
 			    struct hostInfo *hostinfoPtr,
 			    DNRState *dnrStatePtr));
 static void		FreeSocketInfo _ANSI_ARGS_((TcpState *statePtr));
 static long		GetBufferSize _ANSI_ARGS_((void));
-static OSErr		GetHostFromString _ANSI_ARGS_((char *name,
+static OSErr		GetHostFromString _ANSI_ARGS_((CONST char *name,
 			    ip_addr *address));
 static OSErr		GetLocalAddress _ANSI_ARGS_((unsigned long *addr));
 static void		IOCompletionRoutine _ANSI_ARGS_((TCPiopb *pb));
@@ -1654,8 +1654,8 @@
 CreateSocket(
     Tcl_Interp *interp,		/* For error reporting; can be NULL. */
     int port,			/* Port number to open. */
-    char *host,			/* Name of host on which to open port. */
-    char *myaddr,		/* Optional client-side address */
+    CONST char *host,		/* Name of host on which to open port. */
+    CONST char *myaddr,		/* Optional client-side address */
     int myport,			/* Optional client-side port */
     int server,			/* 1 if socket should be a server socket,
 				 * else 0 for a client socket. */
@@ -1844,8 +1844,8 @@
 Tcl_OpenTcpClient(
     Tcl_Interp *interp, 		/* For error reporting; can be NULL. */
     int port, 				/* Port number to open. */
-    char *host, 			/* Host on which to open port. */
-    char *myaddr, 			/* Client-side address */
+    CONST char *host, 			/* Host on which to open port. */
+    CONST char *myaddr,			/* Client-side address */
     int myport, 			/* Client-side port */
     int async)				/* If nonzero, attempt to do an
                                          * asynchronous connect. Otherwise
@@ -1898,7 +1898,7 @@
     Tcl_Interp *interp,			/* For error reporting - may be
                                          * NULL. */
     int port,				/* Port number to open. */
-    char *host,				/* Name of local host. */
+    CONST char *host,			/* Name of local host. */
     Tcl_TcpAcceptProc *acceptProc,	/* Callback for accepting connections
                                          * from new clients. */
     ClientData acceptProcData)		/* Data for the callback. */
@@ -2225,7 +2225,7 @@
  *----------------------------------------------------------------------
  */
 
-char *
+CONST char *
 Tcl_GetHostName()
 {
     static int  hostnameInited = 0;
@@ -2426,7 +2426,7 @@
 
 static OSErr
 GetHostFromString(
-    char *name, 		/* Host in string form. */
+    CONST char *name, 		/* Host in string form. */
     ip_addr *address)		/* Returned IP address. */
 {
     OSErr err;
Index: unix/tclUnixChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixChan.c,v
retrieving revision 1.26
diff -u -u -r1.26 tclUnixChan.c
--- unix/tclUnixChan.c	2002/01/17 04:37:33	1.26
+++ unix/tclUnixChan.c	2002/01/22 22:13:19
@@ -175,11 +175,11 @@
  */
 
 static TcpState *	CreateSocket _ANSI_ARGS_((Tcl_Interp *interp,
-			    int port, char *host, int server,
-			    char *myaddr, int myport, int async));
+			    int port, CONST char *host, int server,
+			    CONST char *myaddr, int myport, int async));
 static int		CreateSocketAddress _ANSI_ARGS_(
 			    (struct sockaddr_in *sockaddrPtr,
-			    char *host, int port));
+			    CONST char *host, int port));
 static int		FileBlockModeProc _ANSI_ARGS_((
     			    ClientData instanceData, int mode));
 static int		FileCloseProc _ANSI_ARGS_((ClientData instanceData,
@@ -2024,11 +2024,11 @@
 CreateSocket(interp, port, host, server, myaddr, myport, async)
     Tcl_Interp *interp;		/* For error reporting; can be NULL. */
     int port;			/* Port number to open. */
-    char *host;			/* Name of host on which to open port.
+    CONST char *host;		/* Name of host on which to open port.
 				 * NULL implies INADDR_ANY */
     int server;			/* 1 if socket should be a server socket,
 				 * else 0 for a client socket. */
-    char *myaddr;		/* Optional client-side address */
+    CONST char *myaddr;		/* Optional client-side address */
     int myport;			/* Optional client-side port */
     int async;			/* If nonzero and creating a client socket,
                                  * attempt to do an async connect. Otherwise
@@ -2205,7 +2205,7 @@
 static int
 CreateSocketAddress(sockaddrPtr, host, port)
     struct sockaddr_in *sockaddrPtr;	/* Socket address */
-    char *host;				/* Host.  NULL implies INADDR_ANY */
+    CONST char *host;			/* Host.  NULL implies INADDR_ANY */
     int port;				/* Port number */
 {
     struct hostent *hostent;		/* Host database entry */
@@ -2287,8 +2287,8 @@
 Tcl_OpenTcpClient(interp, port, host, myaddr, myport, async)
     Tcl_Interp *interp;			/* For error reporting; can be NULL. */
     int port;				/* Port number to open. */
-    char *host;				/* Host on which to open port. */
-    char *myaddr;			/* Client-side address */
+    CONST char *host;			/* Host on which to open port. */
+    CONST char *myaddr;			/* Client-side address */
     int myport;				/* Client-side port */
     int async;				/* If nonzero, attempt to do an
                                          * asynchronous connect. Otherwise
@@ -2384,7 +2384,7 @@
     Tcl_Interp *interp;			/* For error reporting - may be
                                          * NULL. */
     int port;				/* Port number to open. */
-    char *myHost;			/* Name of local host. */
+    CONST char *myHost;			/* Name of local host. */
     Tcl_TcpAcceptProc *acceptProc;	/* Callback for accepting connections
                                          * from new clients. */
     ClientData acceptProcData;		/* Data for the callback. */
@@ -2585,7 +2585,7 @@
 int
 Tcl_GetOpenFile(interp, string, forWriting, checkUsage, filePtr)
     Tcl_Interp *interp;		/* Interpreter in which to find file. */
-    char *string;		/* String that identifies file. */
+    CONST char *string;		/* String that identifies file. */
     int forWriting;		/* 1 means the file is going to be used
 				 * for writing, 0 means for reading. */
     int checkUsage;		/* 1 means verify that the file was opened
Index: unix/tclUnixSock.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixSock.c,v
retrieving revision 1.4
diff -u -u -r1.4 tclUnixSock.c
--- unix/tclUnixSock.c	1999/04/16 00:48:05	1.4
+++ unix/tclUnixSock.c	2002/01/22 22:13:19
@@ -62,7 +62,7 @@
  *----------------------------------------------------------------------
  */
 
-char *
+CONST char *
 Tcl_GetHostName()
 {
 #ifndef NO_UNAME
Index: win/tclWinSock.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinSock.c,v
retrieving revision 1.23
diff -u -u -r1.23 tclWinSock.c
--- win/tclWinSock.c	2002/01/15 17:55:31	1.23
+++ win/tclWinSock.c	2002/01/22 22:13:19
@@ -171,11 +171,11 @@
  */
 
 static SocketInfo *	CreateSocket _ANSI_ARGS_((Tcl_Interp *interp,
-			    int port, char *host, int server, char *myaddr,
-			    int myport, int async));
+			    int port, CONST char *host, int server,
+			    CONST char *myaddr, int myport, int async));
 static int		CreateSocketAddress _ANSI_ARGS_(
 			    (struct sockaddr_in *sockaddrPtr,
-			    char *host, int port));
+			    CONST char *host, int port));
 static void		InitSockets _ANSI_ARGS_((void));
 static SocketInfo *	NewSocketInfo _ANSI_ARGS_((SOCKET socket));
 static void		SocketCheckProc _ANSI_ARGS_((ClientData clientData,
@@ -1014,10 +1014,10 @@
 CreateSocket(interp, port, host, server, myaddr, myport, async)
     Tcl_Interp *interp;		/* For error reporting; can be NULL. */
     int port;			/* Port number to open. */
-    char *host;			/* Name of host on which to open port. */
+    CONST char *host;		/* Name of host on which to open port. */
     int server;			/* 1 if socket should be a server socket,
 				 * else 0 for a client socket. */
-    char *myaddr;		/* Optional client-side address */
+    CONST char *myaddr;		/* Optional client-side address */
     int myport;			/* Optional client-side port */
     int async;			/* If nonzero, connect client socket
                                  * asynchronously. */
@@ -1211,7 +1211,7 @@
 static int
 CreateSocketAddress(sockaddrPtr, host, port)
     struct sockaddr_in *sockaddrPtr;	/* Socket address */
-    char *host;				/* Host.  NULL implies INADDR_ANY */
+    CONST char *host;			/* Host.  NULL implies INADDR_ANY */
     int port;				/* Port number */
 {
     struct hostent *hostent;		/* Host database entry */
@@ -1355,8 +1355,8 @@
 Tcl_OpenTcpClient(interp, port, host, myaddr, myport, async)
     Tcl_Interp *interp;			/* For error reporting; can be NULL. */
     int port;				/* Port number to open. */
-    char *host;				/* Host on which to open port. */
-    char *myaddr;			/* Client-side address */
+    CONST char *host;			/* Host on which to open port. */
+    CONST char *myaddr;			/* Client-side address */
     int myport;				/* Client-side port */
     int async;				/* If nonzero, should connect
                                          * client socket asynchronously. */
@@ -1471,7 +1471,7 @@
     Tcl_Interp *interp;			/* For error reporting - may be
                                          * NULL. */
     int port;				/* Port number to open. */
-    char *host;				/* Name of local host. */
+    COSNT char *host;			/* Name of local host. */
     Tcl_TcpAcceptProc *acceptProc;	/* Callback for accepting connections
                                          * from new clients. */
     ClientData acceptProcData;		/* Data for the callback. */
@@ -2327,7 +2327,7 @@
  *----------------------------------------------------------------------
  */
 
-char *
+CONST char *
 Tcl_GetHostName()
 {
     DWORD length;