Commit 51f4586d authored by gwenn's avatar gwenn

Fix SetAuthorizer return type.

parent adbe176b
...@@ -25,7 +25,12 @@ func open(t *testing.T) *Conn { ...@@ -25,7 +25,12 @@ func open(t *testing.T) *Conn {
t.Fatal("opened database is nil") t.Fatal("opened database is nil")
} }
//db.Trace(trace, "TRACE") //db.Trace(trace, "TRACE")
//db.SetAuthorizer(authorizer, "AUTH") /*
err = db.SetAuthorizer(authorizer, "AUTH")
if err != nil {
t.Fatal("couldn't set an authorizer", err)
}
*/
return db return db
} }
......
...@@ -26,6 +26,7 @@ import "C" ...@@ -26,6 +26,7 @@ import "C"
import ( import (
"fmt" "fmt"
"os"
"unsafe" "unsafe"
) )
...@@ -52,6 +53,7 @@ func (c *Conn) Trace(f SqliteTrace, arg interface{}) { ...@@ -52,6 +53,7 @@ func (c *Conn) Trace(f SqliteTrace, arg interface{}) {
C.goSqlite3Trace(c.db, pArg) C.goSqlite3Trace(c.db, pArg)
} }
// TODO SQLITE_DENY, SQLITE_IGNORE, SQLITE_OK
type SqliteAuthorizer func(d interface{}, action int, arg1, arg2, arg3, arg4 string) int type SqliteAuthorizer func(d interface{}, action int, arg1, arg2, arg3, arg4 string) int
type sqliteAuthorizer struct { type sqliteAuthorizer struct {
...@@ -73,11 +75,10 @@ func goXAuth(pUserData unsafe.Pointer, action C.int, arg1, arg2, arg3, arg4 *C.c ...@@ -73,11 +75,10 @@ func goXAuth(pUserData unsafe.Pointer, action C.int, arg1, arg2, arg3, arg4 *C.c
} }
// Calls http://sqlite.org/c3ref/set_authorizer.html // Calls http://sqlite.org/c3ref/set_authorizer.html
func (c *Conn) SetAuthorizer(f SqliteAuthorizer, arg interface{}) int { func (c *Conn) SetAuthorizer(f SqliteAuthorizer, arg interface{}) os.Error {
// c.authorizer = f
if f == nil { if f == nil {
return int(C.sqlite3_set_authorizer(c.db, nil, nil)) return c.error(C.sqlite3_set_authorizer(c.db, nil, nil))
} }
pArg := unsafe.Pointer(&sqliteAuthorizer{f, arg}) pArg := unsafe.Pointer(&sqliteAuthorizer{f, arg})
return int(C.goSqlite3SetAuthorizer(c.db, pArg)) return c.error(C.goSqlite3SetAuthorizer(c.db, pArg))
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment