aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-03-19 20:55:28 -0500
committerJesse Luehrs <doy@tozt.net>2013-03-19 20:55:28 -0500
commitbe15c787b357fda85983c01be1f4350c5fddf753 (patch)
tree8d77a9ebb5d2ec05560247724953ca70d87608f4
downloadrust-term-be15c787b357fda85983c01be1f4350c5fddf753.tar.gz
rust-term-be15c787b357fda85983c01be1f4350c5fddf753.zip
project skeleton
-rw-r--r--.gitignore4
-rw-r--r--Makefile27
-rw-r--r--src/info.rs0
-rw-r--r--src/ios.rs30
-rw-r--r--src/term.rs6
-rw-r--r--src/termios_wrapper.c21
6 files changed, 88 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6f17b76
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+built
+*.so
+*.o
+*.a
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4d0ee91
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,27 @@
+RUSTC = rustc
+SRC = src
+
+MAIN_SOURCE = $(SRC)/term.rs
+OTHER_SOURCES = $(SRC)/ios.rs $(SRC)/info.rs
+
+all: build tests
+
+build: built
+
+tests: build
+
+built: $(MAIN_SOURCE) $(OTHER_SOURCES) libtermios_wrapper.a
+ $(RUSTC) --out-dir . -L . $(MAIN_SOURCE) && touch built
+
+libtermios_wrapper.a: termios_wrapper.o
+ ar cr libtermios_wrapper.a termios_wrapper.o
+
+termios_wrapper.o: $(SRC)/termios_wrapper.c
+ cc -c $<
+
+clean:
+ rm -f termios_wrapper.o libtermios_wrapper.a
+ rm -f libterm-*.so
+ rm -f built
+
+.PHONY: clean build tests default
diff --git a/src/info.rs b/src/info.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/info.rs
diff --git a/src/ios.rs b/src/ios.rs
new file mode 100644
index 0000000..b4c0ad2
--- /dev/null
+++ b/src/ios.rs
@@ -0,0 +1,30 @@
+use core::libc::c_int;
+
+#[link_name = "termios_wrapper"]
+extern mod c {
+ fn cooked () -> c_int;
+ fn cbreak () -> c_int;
+ fn raw () -> c_int;
+ fn echo (enable: c_int) -> c_int;
+ fn crlf (enable: c_int) -> c_int;
+}
+
+pub fn cooked () -> bool {
+ unsafe { c::cooked() as bool }
+}
+
+pub fn cbreak () -> bool {
+ unsafe { c::cbreak() as bool }
+}
+
+pub fn raw () -> bool {
+ unsafe { c::raw() as bool }
+}
+
+pub fn echo (enable: bool) -> bool {
+ unsafe { c::echo(enable as c_int) as bool }
+}
+
+pub fn crlf (enable: bool) -> bool {
+ unsafe { c::crlf(enable as c_int) as bool }
+}
diff --git a/src/term.rs b/src/term.rs
new file mode 100644
index 0000000..f739fb7
--- /dev/null
+++ b/src/term.rs
@@ -0,0 +1,6 @@
+#[link(name = "term", vers = "0.0.1", author = "doy")];
+
+#[crate_type = "lib"];
+
+pub mod ios;
+pub mod info;
diff --git a/src/termios_wrapper.c b/src/termios_wrapper.c
new file mode 100644
index 0000000..6e2afe4
--- /dev/null
+++ b/src/termios_wrapper.c
@@ -0,0 +1,21 @@
+#include <termios.h>
+
+int cooked()
+{
+}
+
+int cbreak()
+{
+}
+
+int raw()
+{
+}
+
+int echo(int enabled)
+{
+}
+
+int crlf(int enabled)
+{
+}