Commit 3ecfccaf authored by gwenn's avatar gwenn

Fix SqliteAuthorizer return type.

parent 51f4586d
...@@ -11,9 +11,9 @@ func trace(d interface{}, t string) { ...@@ -11,9 +11,9 @@ func trace(d interface{}, t string) {
fmt.Printf("%s: %s\n", d, t) fmt.Printf("%s: %s\n", d, t)
} }
func authorizer(d interface{}, action int, arg1, arg2, arg3, arg4 string) int { func authorizer(d interface{}, action int, arg1, arg2, arg3, arg4 string) Auth {
fmt.Printf("%s: %d, %s, %s, %s, %s\n", d, action, arg1, arg2, arg3, arg4) fmt.Printf("%s: %d, %s, %s, %s, %s\n", d, action, arg1, arg2, arg3, arg4)
return 0 return AUTH_OK
} }
func open(t *testing.T) *Conn { func open(t *testing.T) *Conn {
......
...@@ -53,8 +53,14 @@ func (c *Conn) Trace(f SqliteTrace, arg interface{}) { ...@@ -53,8 +53,14 @@ 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 Auth int
type SqliteAuthorizer func(d interface{}, action int, arg1, arg2, arg3, arg4 string) int const (
AUTH_OK Auth = C.SQLITE_OK
AUTH_DENY Auth = C.SQLITE_DENY
AUTH_IGNORE Auth = C.SQLITE_IGNORE
)
type SqliteAuthorizer func(d interface{}, action int, arg1, arg2, arg3, arg4 string) Auth
type sqliteAuthorizer struct { type sqliteAuthorizer struct {
f SqliteAuthorizer f SqliteAuthorizer
...@@ -63,13 +69,13 @@ type sqliteAuthorizer struct { ...@@ -63,13 +69,13 @@ type sqliteAuthorizer struct {
//export goXAuth //export goXAuth
func goXAuth(pUserData unsafe.Pointer, action C.int, arg1, arg2, arg3, arg4 *C.char) C.int { func goXAuth(pUserData unsafe.Pointer, action C.int, arg1, arg2, arg3, arg4 *C.char) C.int {
var result int var result Auth
if pUserData != nil { if pUserData != nil {
arg := (*sqliteAuthorizer)(pUserData) arg := (*sqliteAuthorizer)(pUserData)
result = arg.f(arg.d, int(action), C.GoString(arg1), C.GoString(arg2), C.GoString(arg3), C.GoString(arg4)) result = arg.f(arg.d, int(action), C.GoString(arg1), C.GoString(arg2), C.GoString(arg3), C.GoString(arg4))
} else { } else {
fmt.Printf("ERROR - %v\n", pUserData) fmt.Printf("ERROR - %v\n", pUserData)
result = 0 result = AUTH_OK
} }
return C.int(result) return C.int(result)
} }
......
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