zhangmeng
2021-02-08 e3c307aa858f8f81d4cb0a5cfe4271cdc5d984be
add remove keys and remove keys exclude
4个文件已修改
123 ■■■■ 已修改文件
bhomebus.go 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus.c 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus.h 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus_func.h 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
bhomebus.go
@@ -185,6 +185,44 @@
    }
}
// Removekeys socket
func (s *Socket) Removekeys(keys []int) int {
    if libbhomebus == nil || s.socket == nil {
        return -1
    }
    ckey := C.create_int_array(C.int(len(keys)))
    defer C.release_int_array(ckey)
    if ckey == nil {
        return -2
    }
    for i, v := range keys {
        C.set_1_int(ckey, C.int(i), C.int(v))
    }
    return int(C.wrap_fn_shm_remove_keys(libbhomebus, ckey, C.int(len(keys))))
}
// RemoveOtherkeys socket
func (s *Socket) RemoveOtherkeys(keys []int) int {
    if libbhomebus == nil || s.socket == nil {
        return -1
    }
    ckey := C.create_int_array(C.int(len(keys)))
    defer C.release_int_array(ckey)
    if ckey == nil {
        return -2
    }
    for i, v := range keys {
        C.set_1_int(ckey, C.int(i), C.int(v))
    }
    return int(C.wrap_fn_shm_remove_keys_exclude(libbhomebus, ckey, C.int(len(keys))))
}
// Socket of bhomebus
type Socket struct {
    socket unsafe.Pointer
@@ -630,34 +668,6 @@
        return -1
    }
    return 0
}
// Removekey socket
func (s *Socket) Removekey(key int) int {
    if libbhomebus == nil || s.socket == nil {
        return -1
    }
    return int(C.wrap_fn_socket_remove_key(libbhomebus, C.int(key)))
}
// Removekeys socket
func (s *Socket) Removekeys(keys []int) int {
    if libbhomebus == nil || s.socket == nil {
        return -1
    }
    ckey := C.create_int_array(C.int(len(keys)))
    defer C.release_int_array(ckey)
    if ckey == nil {
        return -2
    }
    for i, v := range keys {
        C.set_1_int(ckey, C.int(i), C.int(v))
    }
    return int(C.wrap_fn_socket_remove_keys(libbhomebus, ckey, C.int(len(keys))))
}
// ServerSocket tcp
libcbhomebus.c
@@ -73,6 +73,22 @@
    fn_shm_destroy();
}
int wrap_fn_shm_remove_keys(hbhomebus lib, void *keys, int length){
    if (!fn_shm_remove_keys){
        fn_shm_remove_keys = (tfn_shm_remove_keys)dlsym(lib, l_shm_remove_keys);
        check_with_ret(fn_shm_remove_keys, lib, -1);
    }
    return fn_shm_remove_keys((int*)keys, length);
}
int wrap_fn_shm_remove_keys_exclude(hbhomebus lib, void *keys, int length){
    if (!fn_shm_remove_keys_exclude){
        fn_shm_remove_keys_exclude = (tfn_shm_remove_keys_exclude)dlsym(lib, l_shm_remove_keys_exclude);
        check_with_ret(fn_shm_remove_keys_exclude, lib, -1);
    }
    return fn_shm_remove_keys_exclude((int*)keys, length);
}
////////////////////////////////////////////
// dgram socket mode
////////////////////////////////////////////
@@ -337,22 +353,6 @@
        check_only(fn_socket_free, lib);
    }
    return fn_socket_free(buf);
}
int wrap_fn_socket_remove_key(hbhomebus lib, int key){
    if (!fn_socket_remove_key){
        fn_socket_remove_key = (tfn_shm_mod_socket_remove_key)dlsym(lib, l_shm_mod_socket_remove_key);
        check_with_ret(fn_socket_remove_key, lib, -1);
    }
    return fn_socket_remove_key(key);
}
int wrap_fn_socket_remove_keys(hbhomebus lib, void *keys, int length){
    if (!fn_socket_remove_keys){
        fn_socket_remove_keys = (tfn_shm_mod_socket_remove_keys)dlsym(lib, l_shm_mod_socket_remove_keys);
        check_with_ret(fn_socket_remove_keys, lib, -1);
    }
    return fn_socket_remove_keys((int*)keys, length);
}
void *wrap_fn_server_socket_open(hbhomebus lib, int port){
libcbhomebus.h
@@ -13,6 +13,8 @@
static tfn_shm_init                             fn_shm_init = NULL;
static tfn_shm_alloc_key                        fn_shm_alloc_key = NULL;
static tfn_shm_destroy                          fn_shm_destroy = NULL;
static tfn_shm_remove_keys                      fn_shm_remove_keys = NULL;
static tfn_shm_remove_keys_exclude              fn_shm_remove_keys_exclude = NULL;
// net mode socket
static tfn_net_mod_socket_open                  fn_socket_open = NULL;
@@ -46,8 +48,6 @@
static tfn_net_mod_socket_get_key               fn_socket_get_key = NULL;
static tfn_net_mod_socket_free_recv_msg_arr     fn_socket_free_recv_msg_arr = NULL;
static tfn_net_mod_socket_free                  fn_socket_free = NULL;
static tfn_shm_mod_socket_remove_key            fn_socket_remove_key = NULL;
static tfn_shm_mod_socket_remove_keys           fn_socket_remove_keys = NULL;
static tfn_net_mod_server_socket_open           fn_server_socket_open = NULL;
static tfn_net_mod_server_socket_close          fn_server_socket_close = NULL;
@@ -64,6 +64,8 @@
const static char l_shm_init[] = "shm_mm_wrapper_init";
const static char l_shm_destroy[] = "shm_mm_wrapper_destroy";
const static char l_shm_alloc_key[] = "shm_mm_wrapper_alloc_key";
const static char l_shm_remove_keys[] = "shm_mm_wrapper_remove_keys";
const static char l_shm_remove_keys_exclude[] = "shm_mm_wrapper_remove_keys_exclude";
// net mode socket
const static char l_socket_open[] = "net_mod_socket_open";
@@ -98,8 +100,6 @@
const static char l_net_mod_socket_get_key[] = "net_mod_socket_get_key";
const static char l_net_mod_socket_free_recv_msg_arr[] = "net_mod_socket_free_recv_msg_arr";
const static char l_net_mod_socket_free[] = "net_mod_socket_free";
const static char l_shm_mod_socket_remove_key[] = "shm_mod_socket_remove_key";
const static char l_shm_mod_socket_remove_keys[] = "shm_mod_socket_remove_keys";
const static char l_net_mod_server_socket_open[] = "net_mod_server_socket_open";
const static char l_net_mod_server_socket_close[] = "net_mod_server_socket_close";
@@ -120,6 +120,8 @@
void wrap_fn_shm_init(hbhomebus lib, int size);
int wrap_fn_shm_alloc_key(hbhomebus lib);
void wrap_fn_shm_destroy(hbhomebus lib);
int wrap_fn_shm_remove_keys(hbhomebus lib, void *keys, int length);
int wrap_fn_shm_remove_keys_exclude(hbhomebus lib, void *keys, int length);
/////////////////////////////////////////////////////////
// net mode socket
@@ -157,9 +159,6 @@
int wrap_fn_socket_get_key(hbhomebus lib, void * _socket) ;
void  wrap_fn_socket_free_recv_msg_arr(hbhomebus lib, void * arr, int size);
void wrap_fn_socket_free(hbhomebus lib, void *buf) ;
int wrap_fn_socket_remove_key(hbhomebus lib, int key);
int wrap_fn_socket_remove_keys(hbhomebus lib, void *keys, int length);
void *wrap_fn_server_socket_open(hbhomebus lib, int port);
void wrap_fn_server_socket_close(hbhomebus lib, void* _socket);
libcbhomebus_func.h
@@ -46,6 +46,11 @@
 */
typedef int(*tfn_shm_alloc_key) ();
/**
 * 批量删除key对应的共享队列,并在bus里删除该key的订阅
 */
typedef int(*tfn_shm_remove_keys) (int*, int);
typedef int(*tfn_shm_remove_keys_exclude) (int*, int);
/////////////////////////////////////////////
// net_mod_socket
@@ -227,13 +232,6 @@
 * 释放存储接收信息的buf
 */
typedef void (*tfn_net_mod_socket_free)(void *buf) ;
typedef int(*tfn_shm_mod_socket_remove_key) (int);
/**
 * 批量删除key对应的共享队列,并在bus里删除该key的订阅
 */
typedef int(*tfn_shm_mod_socket_remove_keys) (int*, int);
/**
 * 创建