summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-04 06:54:24 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-04 06:54:24 (GMT)
commitd409a29e57b2d4ced1bad4b0bb5bb1e2387f4120 (patch)
treeb94ae208eb9dfbc5fd5839c4a5fc7747ae5f2eb1 /unix/tclUnixSock.c
parentcc1e30158793a4c08f066242a62aeba0a777c263 (diff)
downloadtcl-d409a29e57b2d4ced1bad4b0bb5bb1e2387f4120.zip
tcl-d409a29e57b2d4ced1bad4b0bb5bb1e2387f4120.tar.gz
tcl-d409a29e57b2d4ced1bad4b0bb5bb1e2387f4120.tar.bz2
Experiment: compile Tcl with C++ compiler. WIP
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 62e4756..c061a78 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -66,7 +66,7 @@ struct TcpState {
Tcl_TcpAcceptProc *acceptProc;
/* Proc to call on accept. */
- ClientData acceptProcData; /* The data for the accept proc. */
+ void *acceptProcData; /* The data for the accept proc. */
/*
* Only needed for client sockets
@@ -130,24 +130,24 @@ struct TcpState {
*/
static int TcpConnect(Tcl_Interp *interp, TcpState *state);
-static void TcpAccept(ClientData data, int mask);
-static int TcpBlockModeProc(ClientData data, int mode);
-static int TcpCloseProc(ClientData instanceData,
+static void TcpAccept(void *data, int mask);
+static int TcpBlockModeProc(void *data, int mode);
+static int TcpCloseProc(void *instanceData,
Tcl_Interp *interp);
-static int TcpClose2Proc(ClientData instanceData,
+static int TcpClose2Proc(void *instanceData,
Tcl_Interp *interp, int flags);
-static int TcpGetHandleProc(ClientData instanceData,
- int direction, ClientData *handlePtr);
-static int TcpGetOptionProc(ClientData instanceData,
+static int TcpGetHandleProc(void *instanceData,
+ int direction, void **handlePtr);
+static int TcpGetOptionProc(void *instanceData,
Tcl_Interp *interp, const char *optionName,
Tcl_DString *dsPtr);
-static int TcpInputProc(ClientData instanceData, char *buf,
+static int TcpInputProc(void *instanceData, char *buf,
int toRead, int *errorCode);
-static int TcpOutputProc(ClientData instanceData,
+static int TcpOutputProc(void *instanceData,
const char *buf, int toWrite, int *errorCode);
-static void TcpWatchProc(ClientData instanceData, int mask);
+static void TcpWatchProc(void *instanceData, int mask);
static int WaitForConnect(TcpState *statePtr, int *errorCodePtr);
-static void WrapNotify(ClientData clientData, int mask);
+static void WrapNotify(void *clientData, int mask);
/*
* This structure describes the channel type structure for TCP socket
@@ -239,7 +239,7 @@ InitializeHostName(
char *dot = strchr(u.nodename, '.');
if (dot != NULL) {
- char *node = ckalloc(dot - u.nodename + 1);
+ char *node = (char *)ckalloc(dot - u.nodename + 1);
memcpy(node, u.nodename, dot - u.nodename);
node[dot - u.nodename] = '\0';
@@ -283,11 +283,11 @@ InitializeHostName(
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
if (native) {
*lengthPtr = strlen(native);
- *valuePtr = ckalloc(*lengthPtr + 1);
+ *valuePtr = (char *)ckalloc(*lengthPtr + 1);
memcpy(*valuePtr, native, *lengthPtr + 1);
} else {
*lengthPtr = 0;
- *valuePtr = ckalloc(1);
+ *valuePtr = (char *)ckalloc(1);
*valuePtr[0] = '\0';
}
}
@@ -381,12 +381,12 @@ TclpFinalizeSockets(void)
/* ARGSUSED */
static int
TcpBlockModeProc(
- ClientData instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
int mode) /* The mode to set. Can be one of
* TCL_MODE_BLOCKING or
* TCL_MODE_NONBLOCKING. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
if (mode == TCL_MODE_BLOCKING) {
CLEAR_BITS(statePtr->flags, TCP_NONBLOCKING);
@@ -527,13 +527,13 @@ WaitForConnect(
/* ARGSUSED */
static int
TcpInputProc(
- ClientData instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
char *buf, /* Where to store data read. */
int bufSize, /* How much space is available in the
* buffer? */
int *errorCodePtr) /* Where to store error code. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
int bytesRead;
*errorCodePtr = 0;
@@ -578,12 +578,12 @@ TcpInputProc(
static int
TcpOutputProc(
- ClientData instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCodePtr) /* Where to store error code. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
int written;
*errorCodePtr = 0;
@@ -620,10 +620,10 @@ TcpOutputProc(
/* ARGSUSED */
static int
TcpCloseProc(
- ClientData instanceData, /* The socket to close. */
+ void *instanceData, /* The socket to close. */
Tcl_Interp *interp) /* For error reporting - unused. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
int errorCode = 0;
TcpFdList *fds;
@@ -681,11 +681,11 @@ TcpCloseProc(
static int
TcpClose2Proc(
- ClientData instanceData, /* The socket to close. */
+ void *instanceData, /* The socket to close. */
Tcl_Interp *interp, /* For error reporting. */
int flags) /* Flags that indicate which side to close. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
int errorCode = 0;
int sd;
@@ -842,7 +842,7 @@ TcpHostPortList(
static int
TcpGetOptionProc(
- ClientData instanceData, /* Socket state. */
+ void *instanceData, /* Socket state. */
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Name of the option to retrieve the value
* for, or NULL to get all options and their
@@ -850,7 +850,7 @@ TcpGetOptionProc(
Tcl_DString *dsPtr) /* Where to store the computed value;
* initialized by caller. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
size_t len = 0;
WaitForConnect(statePtr, NULL);
@@ -1008,7 +1008,7 @@ TcpGetOptionProc(
static void
WrapNotify(
- ClientData clientData,
+ void *clientData,
int mask)
{
TcpState *statePtr = (TcpState *) clientData;
@@ -1037,12 +1037,12 @@ WrapNotify(
static void
TcpWatchProc(
- ClientData instanceData, /* The socket state. */
+ void *instanceData, /* The socket state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
if (statePtr->acceptProc != NULL) {
/*
@@ -1111,11 +1111,11 @@ TcpWatchProc(
/* ARGSUSED */
static int
TcpGetHandleProc(
- ClientData instanceData, /* The socket state. */
+ void *instanceData, /* The socket state. */
int direction, /* Not used. */
- ClientData *handlePtr) /* Where to store the handle. */
+ void **handlePtr) /* Where to store the handle. */
{
- TcpState *statePtr = instanceData;
+ TcpState *statePtr = (TcpState *)instanceData;
*handlePtr = INT2PTR(statePtr->fds.fd);
return TCL_OK;
@@ -1135,12 +1135,12 @@ TcpGetHandleProc(
static void
TcpAsyncCallback(
- ClientData clientData, /* The socket state. */
+ void *clientData, /* The socket state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
{
- TcpConnect(NULL, clientData);
+ TcpConnect(NULL, (TcpState *)clientData);
}
/*
@@ -1182,6 +1182,7 @@ TcpConnect(
int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING);
int ret = -1, error = EHOSTUNREACH;
int async = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
+ static const int reuseaddr = 1;
if (async_callback) {
goto reenter;
@@ -1192,7 +1193,6 @@ TcpConnect(
for (statePtr->myaddr = statePtr->myaddrlist;
statePtr->myaddr != NULL;
statePtr->myaddr = statePtr->myaddr->ai_next) {
- int reuseaddr = 1;
/*
* No need to try combinations of local and remote addresses of
@@ -1399,7 +1399,7 @@ Tcl_OpenTcpClient(
* Allocate a new TcpState for this socket.
*/
- statePtr = ckalloc(sizeof(TcpState));
+ statePtr = (TcpState *)ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->flags = async ? TCP_ASYNC_CONNECT : 0;
statePtr->cachedBlocking = TCL_MODE_BLOCKING;
@@ -1446,7 +1446,7 @@ Tcl_OpenTcpClient(
Tcl_Channel
Tcl_MakeTcpClientChannel(
- ClientData sock) /* The socket to wrap up into a channel. */
+ void *sock) /* The socket to wrap up into a channel. */
{
return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
TCL_READABLE | TCL_WRITABLE);
@@ -1478,7 +1478,7 @@ TclpMakeTcpClientChannelMode(
TcpState *statePtr;
char channelName[SOCK_CHAN_LENGTH];
- statePtr = ckalloc(sizeof(TcpState));
+ statePtr = (TcpState *)ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->fds.fd = PTR2INT(sock);
statePtr->flags = 0;
@@ -1521,7 +1521,7 @@ Tcl_OpenTcpServerEx(
Tcl_TcpAcceptProc *acceptProc,
/* Callback for accepting connections from new
* clients. */
- ClientData acceptProcData) /* Data for the callback. */
+ void *acceptProcData) /* Data for the callback. */
{
int status = 0, sock = -1, optvalue, port, chosenport;
struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */
@@ -1701,14 +1701,14 @@ Tcl_OpenTcpServerEx(
* Allocate a new TcpState for this socket.
*/
- statePtr = ckalloc(sizeof(TcpState));
+ statePtr = (TcpState *)ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
sprintf(channelName, SOCK_TEMPLATE, (long) statePtr);
newfds = &statePtr->fds;
} else {
- newfds = ckalloc(sizeof(TcpFdList));
+ newfds = (TcpFdList *)ckalloc(sizeof(TcpFdList));
memset(newfds, (int) 0, sizeof(TcpFdList));
fds->next = newfds;
}
@@ -1769,10 +1769,10 @@ Tcl_OpenTcpServerEx(
/* ARGSUSED */
static void
TcpAccept(
- ClientData data, /* Callback token. */
+ void *data, /* Callback token. */
int mask) /* Not used. */
{
- TcpFdList *fds = data; /* Client data of server socket. */
+ TcpFdList *fds = (TcpFdList *)data; /* Client data of server socket. */
int newsock; /* The new client socket */
TcpState *newSockState; /* State for new socket. */
address addr; /* The remote address */
@@ -1793,7 +1793,7 @@ TcpAccept(
(void) fcntl(newsock, F_SETFD, FD_CLOEXEC);
- newSockState = ckalloc(sizeof(TcpState));
+ newSockState = (TcpState *)ckalloc(sizeof(TcpState));
memset(newSockState, 0, sizeof(TcpState));
newSockState->flags = 0;
newSockState->fds.fd = newsock;