From: Paul J R Date: Fri, 13 Nov 2009 14:34:08 +0000 (+1100) Subject: bizare... X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=70e916f77d2ccc9b296e53981ccca0c11798e0d5;p=goDBhammer.git bizare... --- 70e916f77d2ccc9b296e53981ccca0c11798e0d5 diff --git a/.project b/.project new file mode 100644 index 0000000..182d30d --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + goDBHammer + + + + + + + + diff --git a/src/dbconnector.go b/src/dbconnector.go new file mode 100644 index 0000000..f8b9131 --- /dev/null +++ b/src/dbconnector.go @@ -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 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 index 0000000..7f0bcf8 --- /dev/null +++ b/src/dbibridge.go @@ -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 index 0000000..0d5bad4 --- /dev/null +++ b/src/dbibridge.go.or @@ -0,0 +1,28 @@ +package dbibridge + +// #include +// #include +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 index 0000000..cd40c77 --- /dev/null +++ b/src/makeit @@ -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 index 0000000..546341d --- /dev/null +++ b/src/webconnector.go @@ -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, "
\n"); +} + +func main() { + dbibridge.dbiconnect(); + http.Handle("/hello", http.HandlerFunc(HelloServer)); + err := http.ListenAndServe(":12345", nil); + if err != nil { + panic("ListenAndServe: ", err.String()) + } + +}