]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/libc_be_stdin/lib/src/stdin.cc
update
[l4.git] / l4 / pkg / libc_be_stdin / lib / src / stdin.cc
index 1b3b2eec126635afeceb9a095c04a4d2911f41a3..6ff2c74cf0700ca1727ede45f103a5a4820fc857 100644 (file)
@@ -21,13 +21,15 @@ namespace {
 
 using namespace L4Re::Vfs;
 
-class in_ops : public Be_file
+class in_ops : public Be_file_stream
 {
 private:
   Event::Event  _event;
+  L4::Cap<L4::Vcon> _s;
 
 public:
-  in_ops()  throw() : Be_file(), _event(this) {}
+  in_ops(L4::Cap<L4::Vcon> v)  throw()
+  : Be_file_stream(), _event(this), _s(v) {}
   ~in_ops() throw() {}
 
   int bind_irq(unsigned irq, L4::Cap<L4::Irq> const &irq_cap) throw()
@@ -43,7 +45,7 @@ public:
     if (len == 0)
       return -EINVAL;
 
-    int ret = L4Re::Env::env()->log()->read((char *)buf, len);
+    int ret = _s->read((char *)buf, len);
     if (ret > (int)len)
       ret = len;
 
@@ -52,7 +54,7 @@ public:
         // nothing read, read needs to block
         _event.wait();
 
-        ret = L4Re::Env::env()->log()->read((char *)buf, len);
+        ret = _s->read((char *)buf, len);
         if (ret > (int)len)
           ret = len;
       }
@@ -69,15 +71,20 @@ public:
 
          struct termios *t = va_arg(args, struct termios *);
 
-          // XXX: well, we're cheating, get this from the other side!
-
-         t->c_iflag = 0;
-         t->c_oflag = 0; // output flags
-         t->c_cflag = 0; // control flags
-
-         t->c_lflag = 0; // local flags
+          l4_vcon_attr_t l4a;
+          if (!l4_error(_s->get_attr(&l4a)))
+            {
+              t->c_iflag = l4a.i_flags;
+              t->c_oflag = l4a.o_flags; // output flags
+              t->c_cflag = 0; // control flags
+              t->c_lflag = l4a.l_flags; // local flags
+            }
+          else
+            t->c_iflag = t->c_oflag = t->c_cflag = t->c_lflag = 0;
+#if 0
          //t->c_lflag |= ECHO; // if term->echo
          t->c_lflag |= ICANON; // if term->term_mode == VT100MODE_COOKED
+#endif
 
          t->c_cc[VEOF]   = CEOF;
          t->c_cc[VEOL]   = _POSIX_VDISABLE;
@@ -97,7 +104,6 @@ public:
          t->c_cc[VTIME] = 0;
 
          //printf("TCGETS: c_lflags = %08x\n", t->c_lflag);
-
        }
 
        return 0;
@@ -107,11 +113,17 @@ public:
       case TCSETSF:
        {
           //vt100_tcsetattr(term, (struct termios *)argp);
-         //struct termios *t = va_arg(args, struct termios *);
+         struct termios *t = va_arg(args, struct termios *);
 
           //XXX: probably we need to get this over to the other side!
 
          //printf("TCSETS*: c_lflags = %08x\n", t->c_lflag);
+
+          l4_vcon_attr_t l4a;
+          l4a.i_flags = t->c_iflag;
+          l4a.o_flags = t->c_oflag; // output flags
+          l4a.l_flags = t->c_lflag; // local flags
+          _s->set_attr(&l4a);
        }
         return 0;
 
@@ -134,7 +146,7 @@ public:
 static void get_in_ops() __attribute__((constructor));
 static void get_in_ops()
 {
-  static in_ops _myops;
+  static in_ops _myops(L4Re::Env::env()->log());
   _myops.add_ref(); // prevent the static object from beeing deleted
   L4Re::Vfs::vfs_ops->set_fd(STDIN_FILENO, cxx::ref_ptr(&_myops));
 }