add remove keys and remove keys exclude
| | |
| | | } |
| | | } |
| | | |
| | | // 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 |
| | |
| | | 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 |
| | |
| | | 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 |
| | | //////////////////////////////////////////// |
| | |
| | | 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){ |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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"; |
| | |
| | | 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"; |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | */ |
| | | 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 |
| | |
| | | * 释放存储接收信息的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); |
| | | |
| | | |
| | | /** |
| | | * 创建 |