From 70e916f77d2ccc9b296e53981ccca0c11798e0d5 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sat, 14 Nov 2009 01:34:08 +1100 Subject: [PATCH 1/1] bizare... --- .project | 11 +++++++++++ src/dbconnector.go | 1 + src/dbibridge.8 | Bin 0 -> 5379 bytes src/dbibridge.go | 8 ++++++++ src/dbibridge.go.or | 28 ++++++++++++++++++++++++++++ src/makeit | 15 +++++++++++++++ src/webconnector.go | 25 +++++++++++++++++++++++++ 7 files changed, 88 insertions(+), 0 deletions(-) create mode 100644 .project create mode 100644 src/dbconnector.go create mode 100644 src/dbibridge.8 create mode 100644 src/dbibridge.go create mode 100644 src/dbibridge.go.or create mode 100755 src/makeit create mode 100644 src/webconnector.go 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 0000000000000000000000000000000000000000..b7d3036f58a6c67eb3d433bbd2a0fb3501dd6711 GIT binary patch literal 5379 zcmb7I+fEx-6dhj%upu~vdkE%m3kHncv`rI<98p>lB~Oh+r1qgw<=}x>u|3F`T+}vF z`vH|u6{+ue=nqulrBC!X@*PoCRciOzXU=5?Cv8SiJhNtB)?RzhnZtZ^^OL*~!L!4# z(>)Tk<8IihbsKxNX7jl?2--oX)(z@nzZ15|tp2d^u+yj?1eJqOG}_{@w)ePp5QqhH zV}YzhqlIYs{L+#T)v6ATJI2E}c|yL=a_PSE53(o zK0lv-;oVN%s(SqMC~O7l?67v+?5NYD&Yn66_L_~uqhRA{*m-BBw`>k%JMvxE0|A&t48(t0|{s$-51_gp9yt# zS|Js^8k@ZQn>hDvWm3Zwqu;~`nn5eF7|#-={@qkzo*g{zdGt#p28=^v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`7VX7`q<;ZM#)|+11fP=O(__;&P?AE!`XNZelkjWwgTt)dCFz5j9q@5bDOriJ zhK@@ge}LK*p8!o|)lx}rDoK@9q7uO|Duf3V5r?6&nxrxTDywlS6Gc zbt$xwCdPybr*ARbZi9m`;n8OeEAYDX@u*wEGa$SkCp;5XWe5|X36~Aw_~vAEv%f5b z!W@Ch(#Jg8e6z?`j^~?|eqT%=0(8C&lh1h-(@S+j;xAkBa*}Pt7F#kBNVXAACZwN< zB_lv5vwy0;|ND^|REY$j_o`_GLK9A3srYM!!Ou*v97Ye6uRQz>A z1zicreziBuM=X0pNAHexEAx$UxShHB0y_VHNvwN>Z$FDT2nnE(I) literal 0 HcmV?d00001 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()) + } + +} -- 1.7.0.4