- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
package eapi
// #include <eggdrop/mod/module.h>
// #include <eggdrop/main.h>
// #include <eggdrop/proto.h>
import (
"C"
"errors"
)
const (
DP_STDOUT = 0x7FF1
DP_LOG = 0x7FF2
DP_SERVER = 0x7FF3
DP_HELP = 0x7FF4
DP_STDERR = 0x7FF5
DP_MODE = 0x7FF6
DP_MODE_NEXT = 0x7FF7
DP_SERVER_NEXT = 0x7FF8
DP_HELP_NEXT = 0x7FF9
)
var (
binds []struct{
flags,match string
list *C.tcl_bind_list_t
}
bind_num int = 0
)
//...
func Bind(event,flags,match string, proc func(cd *C.ClientData, irp *C.Tcl_Interp, argc C.int, argv *[]C.char)) int,error{
tl := C.find_bind_table(C.CString(event))
if tl == nil{
return -1,errors.New("No such event table : "+ event)
}
func_name := bname(bind_num)
bind_num++
var cmd []C.tcl_cmds = {
{func_name,proc},
{nil,nil}
}
C.tcl_add_commands(cmd)
C.bind_bind_entry(tl, C.CString(flags), C.CString(match), C.CString(func_name))
append(binds,{flags,match,tl})
return bind_num-1,nil
}
func Unbind(int num){
if binds[num] == nil{
return
}
C.unbind_bind_entry(binds[num].list, C.CString(binds[num].flags), C.CString(binds[num].match), C.CString(bname(num)))
}