* TCL_WRITABLE as set by an asynchronous
* event handler. */
int watchMask; /* OR'ed combination of TCL_READABLE and
- * TCL_WRITABLE as set by Tcl_WatchFile. */
+ * TCL_WRITABLE as set by TcpWatch. */
Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */
ClientData acceptProcData; /* The data for the accept proc. */
wdsEntry dataSegment[2]; /* List of buffers to be written async. */
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));
static int TcpGetHandle _ANSI_ARGS_((ClientData instanceData,
int direction, ClientData *handlePtr));
static int TcpGetOptionProc _ANSI_ARGS_((ClientData instanceData,
- Tcl_Interp *interp, char *optionName,
+ Tcl_Interp *interp, CONST char *optionName,
Tcl_DString *dsPtr));
static int TcpInput _ANSI_ARGS_((ClientData instanceData,
char *buf, int toRead, int *errorCodePtr));
static int TcpOutput _ANSI_ARGS_((ClientData instanceData,
- char *buf, int toWrite, int *errorCodePtr));
+ CONST char *buf, int toWrite, int *errorCodePtr));
static void TcpWatch _ANSI_ARGS_((ClientData instanceData,
int mask));
static int WaitForSocketEvent _ANSI_ARGS_((TcpState *infoPtr,
static Tcl_ChannelType tcpChannelType = {
"tcp", /* Type name. */
- TcpBlockMode, /* Set blocking or
+ (Tcl_ChannelTypeVersion)TcpBlockMode, /* Set blocking or
* non-blocking mode.*/
TcpClose, /* Close proc. */
TcpInput, /* Input proc. */
static int
TcpOutput(
ClientData instanceData, /* Channel state. */
- char *buf, /* The data buffer. */
+ CONST char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCodePtr) /* Where to store error code. */
{
TcpGetOptionProc(
ClientData instanceData, /* Socket state. */
Tcl_Interp *interp, /* For error reporting - can be NULL.*/
- char *optionName, /* Name of the option to
+ CONST char *optionName, /* Name of the option to
* retrieve the value for, or
* NULL to get all options and
* their values. */
* value; initialized by caller. */
{
TcpState *statePtr = (TcpState *) instanceData;
- int doPeerName = false, doSockName = false, doAll = false;
+ int doPeerName = false, doSockName = false, doError = false, doAll = false;
ip_addr tcpAddress;
char buffer[128];
OSErr err;
Tcl_DString dString;
TCPiopb statusPB;
int errorCode;
+ size_t len = 0;
/*
* If an asynchronous connect is in progress, attempt to wait for it
* if optionName is NULL.
*/
- if (optionName == (char *) NULL || optionName[0] == '\0') {
+ if (optionName == (CONST char *) NULL || optionName[0] == '\0') {
doAll = true;
} else {
- if (!strcmp(optionName, "-peername")) {
+ len = strlen(optionName);
+ if (!strncmp(optionName, "-peername", len)) {
doPeerName = true;
- } else if (!strcmp(optionName, "-sockname")) {
+ } else if (!strncmp(optionName, "-sockname", len)) {
doSockName = true;
+ } else if (!strncmp(optionName, "-error", len)) {
+ /* SF Bug #483575 */
+ doError = true;
} else {
return Tcl_BadChannelOption(interp, optionName,
- "peername sockname");
+ "error peername sockname");
+ }
+ }
+
+ /*
+ * SF Bug #483575
+ *
+ * Return error information. Currently we ignore
+ * this option. IOW, we always return the empty
+ * string, signaling 'no error'.
+ *
+ * FIXME: Get a mac/socket expert to write a correct
+ * FIXME: implementation.
+ */
+
+ if (doAll || doError) {
+ if (doAll) {
+ Tcl_DStringAppendElement(dsPtr, "-error");
+ Tcl_DStringAppendElement(dsPtr, "");
+ } else {
+ Tcl_DStringAppend (dsPtr, "", -1);
+ return TCL_OK;
}
}
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. */
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
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. */
*----------------------------------------------------------------------
*/
-char *
+CONST char *
Tcl_GetHostName()
{
static int hostnameInited = 0;
static OSErr
GetHostFromString(
- char *name, /* Host in string form. */
+ CONST char *name, /* Host in string form. */
ip_addr *address) /* Returned IP address. */
{
OSErr err;
}
dnrState.done = 0;
GetCurrentProcess(&(dnrState.psn));
- err = StrToAddr(name, &dnrState.hostInfo, resultUPP, (Ptr) &dnrState);
+ err = StrToAddr((char*)name, &dnrState.hostInfo, resultUPP, (Ptr) &dnrState);
if (err == cacheFault) {
while (!dnrState.done) {
WaitNextEvent(0, &dummy, 1, NULL);
if (dnrState.hostInfo.rtnCode == cacheFault) {
dnrState.done = 0;
- err = StrToAddr(name, &dnrState.hostInfo, resultUPP, (Ptr) &dnrState);
+ err = StrToAddr((char*)name, &dnrState.hostInfo, resultUPP, (Ptr) &dnrState);
if (err == cacheFault) {
while (!dnrState.done) {
WaitNextEvent(0, &dummy, 1, NULL);