[50960] trunk/base/src/pextlib1.0

toby at macports.org toby at macports.org
Wed May 13 23:29:47 PDT 2009


Revision: 50960
          http://trac.macports.org/changeset/50960
Author:   toby at macports.org
Date:     2009-05-13 23:29:46 -0700 (Wed, 13 May 2009)
Log Message:
-----------
Remove unused procs unixsocketpair and mkchannelfromfd

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/Pextlib.c

Removed Paths:
-------------
    trunk/base/src/pextlib1.0/tests/socketpair.tcl

Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c	2009-05-14 05:53:26 UTC (rev 50959)
+++ trunk/base/src/pextlib1.0/Pextlib.c	2009-05-14 06:29:46 UTC (rev 50960)
@@ -728,76 +728,6 @@
 	return TCL_OK;
 }
 
-/**
- * Take a file descriptor and generate a Tcl channel out of it.
- * Syntax is:
- * mkchannelfromfd fd [r|w|rw]
- * Use r to generate a read-only channel, w for a write only channel or rw
- * for a read/write channel (the default).
- */
-int MkChannelFromFdCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-	Tcl_Channel theChannel;
-	int fd;
-	int readOrWrite = TCL_READABLE | TCL_WRITABLE;
-
-	if ((objc != 2) && (objc != 3)) {
-		Tcl_WrongNumArgs(interp, 1, objv, "fd [r|w|rw]");
-		return TCL_ERROR;
-	}
-	
-	if (objc == 3) {
-		char* readOrWrite_as_char_star;
-		readOrWrite_as_char_star = strdup(Tcl_GetString(objv[2]));
-		if (readOrWrite_as_char_star == NULL) {
-			return TCL_ERROR;
-		}
-
-		if ((readOrWrite_as_char_star[0] == 'r')
-			&& (readOrWrite_as_char_star[1] == '\0')) {
-			readOrWrite = TCL_READABLE;
-		} else if ((readOrWrite_as_char_star[0] == 'w')
-			&& (readOrWrite_as_char_star[1] == '\0')) {
-			readOrWrite = TCL_WRITABLE;
-		} else if ((readOrWrite_as_char_star[0] == 'r')
-			&& (readOrWrite_as_char_star[1] == 'w')
-			&& (readOrWrite_as_char_star[2] == '\0')) {
-			readOrWrite = TCL_READABLE | TCL_WRITABLE;
-		} else {
-			Tcl_AppendResult(interp, "Bad mode. Use r, w or rw", NULL);
-			free(readOrWrite_as_char_star);
-			return TCL_ERROR;
-		}
-
-		free(readOrWrite_as_char_star);
-	}
-
-	{
-		char* fd_as_char_star;
-		fd_as_char_star = strdup(Tcl_GetString(objv[1]));
-		if (fd_as_char_star == NULL) {
-			return TCL_ERROR;
-		}
-
-		if (Tcl_GetInt(interp, fd_as_char_star, &fd) != TCL_OK) {
-			free(fd_as_char_star);
-			return TCL_ERROR;
-		}
-		free(fd_as_char_star);
-	}
-
-	theChannel = Tcl_MakeFileChannel((ClientData)(intptr_t)fd, readOrWrite);
-	if (theChannel == NULL) {
-		return TCL_ERROR;
-	}
-	
-	/* register the channel in the current interpreter */
-	Tcl_RegisterChannel(interp, theChannel);
-	Tcl_AppendResult(interp, Tcl_GetChannelName(theChannel), (char *) NULL);
-
-	return TCL_OK;
-}
-
 int MkdtempCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	char *template, *sp;
@@ -1104,38 +1034,6 @@
 }
 
 /**
- * Call socketpair to generate a socket pair in the Unix domain.
- * Syntax is:
- * unixsocketpair
- *
- * Generate a Tcl error if something goes wrong.
- * Return a list with the file descriptors of the pair.
- */
-int UnixSocketPairCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-	Tcl_Obj* result;
-	int pair[2];
-
-	if (objc != 1) {
-		Tcl_WrongNumArgs(interp, 1, objv, NULL);
-		return TCL_ERROR;
-	}
-	
-	if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) < 0) {
-		Tcl_AppendResult(interp, "socketpair failed: ", strerror(errno), NULL);
-		return TCL_ERROR;
-	}
-	
-	/* build a list out of the pair */
-	result = Tcl_NewListObj(0, NULL);
-	Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(pair[0]));
-	Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(pair[1]));
-	Tcl_SetObjResult(interp, result);
-
-	return TCL_OK;
-}
-
-/**
  * symlink value target
  * Create a symbolic link at target pointing to value
  * See symlink(2) for possible errors
@@ -1298,8 +1196,6 @@
 	Tcl_CreateObjCommand(interp, "umask", UmaskCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "sudo", SudoCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "mkfifo", MkfifoCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "unixsocketpair", UnixSocketPairCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "mkchannelfromfd", MkChannelFromFdCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "pipe", PipeCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "curl", CurlCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "symlink", CreateSymlinkCmd, NULL, NULL);

Deleted: trunk/base/src/pextlib1.0/tests/socketpair.tcl
===================================================================
--- trunk/base/src/pextlib1.0/tests/socketpair.tcl	2009-05-14 05:53:26 UTC (rev 50959)
+++ trunk/base/src/pextlib1.0/tests/socketpair.tcl	2009-05-14 06:29:46 UTC (rev 50960)
@@ -1,51 +0,0 @@
-# Test file for Pextlib's unixsocketpair and mkchannelfromfd.
-# Syntax:
-# tclsh socketpair.tcl <Pextlib name>
-
-proc main {pextlibname} {
-	load $pextlibname
-
-	# Create a socket pair.
-	set pair [unixsocketpair]
-	
-	# Create the two channels.
-	set channel1 [mkchannelfromfd [lindex $pair 0] r]
-	set channel0 [mkchannelfromfd [lindex $pair 1] w]
-	
-	# Create a fileevent on channel 1
-	fileevent $channel1 readable [list read1 $channel1]
-	
-	# Define the list of what we are going to write in it.
-	global buffer bufferWasEmptied
-	set buffer [list hello world]
-	
-	# Write that stuff.
-	foreach word $buffer {
-		puts $channel0 $word
-		flush $channel0
-	}
-	
-	# Wait for that stuff to have been read.
-	vwait bufferWasEmptied
-}
-
-proc read1 {chan} {
-	global buffer bufferWasEmptied
-	if {![eof $chan]} {
-		set line [gets $chan]
-		set expected [lindex $buffer 0]
-		if {$line != $expected} {
-			puts {$line != $expected}
-			exit 1
-		}
-		set buffer [lreplace $buffer 0 0]
-		if {$buffer == {}} {
-			set bufferWasEmptied 1
-		}
-	} else {
-		puts "EOF!"
-		exit 1
-	}
-}
-
-main $argv
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090513/4a75b051/attachment.html>


More information about the macports-changes mailing list