bizare...
authorPaul J R <me@pjr.cc>
Fri, 13 Nov 2009 14:34:08 +0000 (01:34 +1100)
committerPaul J R <me@pjr.cc>
Fri, 13 Nov 2009 14:34:08 +0000 (01:34 +1100)
.project [new file with mode: 0644]
src/dbconnector.go [new file with mode: 0644]
src/dbibridge.8 [new file with mode: 0644]
src/dbibridge.go [new file with mode: 0644]
src/dbibridge.go.or [new file with mode: 0644]
src/makeit [new file with mode: 0755]
src/webconnector.go [new file with mode: 0644]

diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..182d30d
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>goDBHammer</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+       </buildSpec>
+       <natures>
+       </natures>
+</projectDescription>
diff --git a/src/dbconnector.go b/src/dbconnector.go
new file mode 100644 (file)
index 0000000..f8b9131
--- /dev/null
@@ -0,0 +1 @@
+// um yes... its a db connector
\ No newline at end of file
diff --git a/src/dbibridge.8 b/src/dbibridge.8
new file mode 100644 (file)
index 0000000..b7d3036
Binary files /dev/null and b/src/dbibridge.8 differ
diff --git a/src/dbibridge.go b/src/dbibridge.go
new file mode 100644 (file)
index 0000000..7f0bcf8
--- /dev/null
@@ -0,0 +1,8 @@
+package dbibridge
+
+import "fmt"
+
+func dbiconnect()
+{
+       fmt.Printf("Hello, world\n");
+}
diff --git a/src/dbibridge.go.or b/src/dbibridge.go.or
new file mode 100644 (file)
index 0000000..0d5bad4
--- /dev/null
@@ -0,0 +1,28 @@
+package dbibridge
+
+// #include <stdio.h>
+// #include <dbi/dbi.h>
+import "C"
+
+import (
+       "unsafe";
+)
+
+func dbiconnect()
+{
+       
+       C.dbi_initialize(nil);
+       
+       myVar := C.dbi_conn_new(C.CString("mysql"));
+       
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("host"), C.CString("localhost"));
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("username"), C.CString("your_name"));
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("username"), C.CString("your_name"));
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("password"), C.CString("your_password"));
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("dbname"), C.CString("your_dbname"));
+       C.dbi_conn_set_option((unsafe.Pointer)(myVar), C.CString("encoding"), C.CString("UTF-8"));
+       C.dbi_conn_connect((unsafe.Pointer)(myVar));
+       
+       
+        
+}
diff --git a/src/makeit b/src/makeit
new file mode 100755 (executable)
index 0000000..cd40c77
--- /dev/null
@@ -0,0 +1,15 @@
+rm -f *.cgo[1234].* *.so *.o *.a *.8
+cgo dbibridge.go 
+
+8g -o _dbibridge_.8 dbibridge.cgo1.go dbibridge.cgo2.go
+8c -FVw -I/export/src/external/golang//src/pkg/runtime  dbibridge.cgo3.c
+gopack grc dbibridge.a _dbibridge_.8 dbibridge.cgo3.8
+#cp dbibridge.a /export/src/external/golang//pkg/linux_386/dbibridge.a
+gcc -m32 -fPIC -O2 -o dbibridge.cgo4.o -c  dbibridge.cgo4.c
+gcc -m32 -shared -lpthread -lm -o dbibridge.so dbibridge.cgo4.o 
+#cp dbibridge.so /export/src/external/golang//pkg/linux_386/./dbibridge.so
+
+
+
+8g -I. webconnector.go
+8l webconnector.8
diff --git a/src/webconnector.go b/src/webconnector.go
new file mode 100644 (file)
index 0000000..546341d
--- /dev/null
@@ -0,0 +1,25 @@
+// im a web connector
+
+package main
+
+
+import (
+       "http";
+       "io";
+       "./dbibridge";
+)
+
+// hello world, the web server
+func HelloServer(c *http.Conn, req *http.Request) {
+       io.WriteString(c, "<html><form method=post><input type=\"input\"><input type=\"submit\" name=\"go\" value=\"go\"></html>\n");
+}
+
+func main() {
+       dbibridge.dbiconnect();
+       http.Handle("/hello", http.HandlerFunc(HelloServer));
+       err := http.ListenAndServe(":12345", nil);
+       if err != nil {
+               panic("ListenAndServe: ", err.String())
+       }
+
+}