Tcl Source Code

Artifact [a611fdb5cd]
Login

Artifact a611fdb5cd9869850b9897deeae9b94b7d4b7164:

Attachment "ignoredcd.diff" to ticket [3324195fff] added by egavilan 2011-06-22 02:32:40.
--- unix/tclUnixChan.c
+++ unix/tclUnixChan.c
@@ -836,12 +836,35 @@
 	SETCONTROL(fsPtr->fd, &control);
 	ckfree(argv);
 	return TCL_OK;
     }
 
+#ifdef CLOCAL
+    /*
+     * Option -ingoredcd bool
+     */
+
+    if ((len > 2) && (strncmp(optionName, "-ignoredcd", len) == 0)) {
+        if (Tcl_GetBoolean(interp, value, &flag) == TCL_ERROR) {
+            return TCL_ERROR;
+        }
+        GETIOSTATE(fsPtr->fd, &iostate);
+        if (flag) {
+                SET_BITS(iostate.c_cflag, CLOCAL);
+        } else {
+                CLEAR_BITS(iostate.c_cflag, CLOCAL);
+        }
+        SETIOSTATE(fsPtr->fd, &iostate);
+        return TCL_OK;
+    }
+
+    return Tcl_BadChannelOption(interp, optionName,
+	    "ignoredcd mode handshake timeout ttycontrol xchar");
+#else /* !CLOCAL */
     return Tcl_BadChannelOption(interp, optionName,
 	    "mode handshake timeout ttycontrol xchar");
+#endif /* CLOCAL */
 
 #else /* !USE_TERMIOS */
     return Tcl_BadChannelOption(interp, optionName, "mode");
 #endif /* USE_TERMIOS */
 }
@@ -962,18 +985,42 @@
 
 	valid = 1;
 	GETCONTROL(fsPtr->fd, &status);
 	TtyModemStatusStr(status, dsPtr);
     }
+
+#ifdef CLOCAL
+    /*
+     * Get option -ignoredcd
+     */
+
+    if ((len > 4) && (strncmp(optionName, "-ignoredcd", len) == 0)) {
+	IOSTATE iostate;
+
+	valid = 1;
+        Tcl_DStringAppendElement(dsPtr, "-ignoredcd");
+	GETIOSTATE(fsPtr->fd, &iostate);
+        if (iostate.c_cflag & CLOCAL) {
+            Tcl_DStringAppendElement(dsPtr, "1");
+        } else {
+            Tcl_DStringAppendElement(dsPtr, "0");
+        }
+    }
+#endif /* CLOCAL */
 #endif /* USE_TERMIOS */
 
     if (valid) {
 	return TCL_OK;
     }
-    return Tcl_BadChannelOption(interp, optionName, "mode"
+    return Tcl_BadChannelOption(interp, optionName,
 #ifdef USE_TERMIOS
-	    " queue ttystatus xchar"
+#ifdef CLOCAL
+            "ignoredcd "
+#endif /* CLOCAL */
+	    "mode queue ttystatus xchar"
+#else /* !USE_TERMIOS */
+            "mode"
 #endif /* USE_TERMIOS */
 	    );
 }
 
 #ifdef DIRECT_BAUD