Finita la conversione dei listati in file separati. Passato anche alla nuova
[gapil.git] / listati / SetTermAttr.c
diff --git a/listati/SetTermAttr.c b/listati/SetTermAttr.c
new file mode 100644 (file)
index 0000000..41656f2
--- /dev/null
@@ -0,0 +1,21 @@
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
+int SetTermAttr(int fd, tcflag_t flag) 
+{
+    struct termios values;
+    int res;
+    res = tcgetattr (desc, &values);
+    if (res) {
+        perror("Cannot get attributes");
+        return res;
+    }
+    values.c_lflag |= flag;
+    res = tcsetattr (desc, TCSANOW, &values);
+    if (res) {
+        perror("Cannot set attributes");
+        return res;
+    }
+    return 0;
+}