zhangmeng
2020-07-20 91a389294ddd1555349559d01141875bf2154c93
1
2
3
4
5
6
7
8
9
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef _c_libshm_queue_so_go_wrapper_h_
#define _c_libshm_queue_so_go_wrapper_h_
 
#include "libcsoftbus_func.h"
#include <stddef.h>
 
#ifdef __cplusplus
extern "C"{
#endif
 
// shm manipulate
static tfn_shm_init             fn_shm_init = NULL;
static tfn_shm_destroy          fn_shm_destroy = NULL;
static tfn_shm_rm_dead_queue    fn_shm_rm_dead_queue = NULL;
 
// shm queue create drop
static tfn_queue_create         fn_queue_create = NULL;
static tfn_queue_attach         fn_queue_attach = NULL;
static tfn_queue_drop           fn_queue_drop = NULL;
 
// shm queue size
static tfn_queue_size           fn_queue_size = NULL;
static tfn_queue_full           fn_queue_full = NULL;
static tfn_queue_empty          fn_queue_empty = NULL;
 
// shm queue push
static tfn_queue_push           fn_queue_push = NULL;
static tfn_queue_push_nowait    fn_queue_push_nowait = NULL;
static tfn_queue_push_timeout   fn_queue_push_timeout = NULL;
 
// shm queue pop
static tfn_queue_pop            fn_queue_pop = NULL;
static tfn_queue_pop_nowait     fn_queue_pop_nowait = NULL;
static tfn_queue_pop_timeout    fn_queue_pop_timeout = NULL;
static tfn_queue_free_poped     fn_queue_free_poped = NULL;
 
// socket mode
static tfn_socket_open          fn_socket_open = NULL;
static tfn_socket_close         fn_socket_close = NULL;
static tfn_socket_bind          fn_socket_bind = NULL;
static tfn_socket_listen        fn_socket_listen = NULL;
static tfn_socket_connect       fn_socket_connect = NULL;
static tfn_socket_send          fn_socket_send = NULL;
static tfn_socket_recv          fn_socket_recv = NULL;
static tfn_socket_buf_free      fn_socket_buf_free = NULL;
static tfn_socket_port          fn_socket_port = NULL;
 
//////////////////////////////////////////////////////////////////////
 
// labels
// shm
const static char l_shm_init[] = "shm_init";
const static char l_shm_destroy[] = "shm_destroy";
const static char l_shm_rm_dead_queue[] = "shm_remove_queues_exclude";
 
// queue
const static char l_queue_create[] = "shmqueue_create";
const static char l_queue_attach[] = "shmqueue_attach";
const static char l_queue_drop[] = "shmqueue_drop";
 
// queue size
const static char l_queue_size[] = "shmqueue_size";
const static char l_queue_full[] = "shmqueue_full";
const static char l_queue_empty[] = "shmqueue_empty";
 
// queue push
const static char l_queue_push[] = "shmqueue_push";
const static char l_queue_push_nowait[] = "shmqueue_push_nowait";
const static char l_queue_push_timeout[] = "shmqueue_push_timeout";
 
// queue pop
const static char l_queue_pop[] = "shmqueue_pop";
const static char l_queue_pop_nowait[] = "shmqueue_pop_nowait";
const static char l_queue_pop_timeout[] = "shmqueue_pop_timeout";
const static char l_queue_free_poped[] = "shmqueue_free";
 
// mode socket
const static char l_socket_open[] = "mod_open_socket";
const static char l_socket_close[] = "mod_close_socket";
const static char l_socket_bind[] = "mod_socket_bind";
const static char l_socket_listen[] = "mod_listen";
const static char l_socket_connect[] = "mod_connect";
const static char l_socket_send[] = "mod_send";
const static char l_socket_recv[] = "mod_recv";
const static char l_socket_free[] = "mod_free";
const static char l_socket_port[] = "mod_get_socket_port";
 
 
//////////////////////////////////////////////////////////////////////
 
// dlopen dynamic library
typedef void* hcsoftbus;
hcsoftbus c_softbus_handle(const char *so);
void c_softbus_release(hcsoftbus lib);
 
// shm manipulate
void wrap_fn_shm_init(hcsoftbus lib, int size);
void wrap_fn_shm_destroy(hcsoftbus lib);
void wrap_fn_shm_rm_dead_queue(hcsoftbus lib, void *array, int len);
 
// queue create/drop
void* wrap_fn_queue_create(hcsoftbus lib, int *key, int queue_size);
void* wrap_fn_queue_attach(hcsoftbus lib, int key);
void wrap_fn_queue_drop(hcsoftbus lib, void* shmq);
 
// queue size
int wrap_fn_queue_size(hcsoftbus lib, void *shmq);
int wrap_fn_queue_full(hcsoftbus lib, void *shmq);
int wrap_fn_queue_empty(hcsoftbus lib, void *shmq);
 
// queue push
int wrap_fn_queue_push(hcsoftbus lib, void *shmq, void *ele, int ele_size);
int wrap_fn_queue_push_nowait(hcsoftbus lib, void *shmq, void *ele, int ele_size);
int wrap_fn_queue_push_timeout(hcsoftbus lib, void *shmq, void *ele, int ele_size, int sec, int nsec);
 
// queue pop
int wrap_fn_queue_pop(hcsoftbus lib, void *shmq, void **ele, int *ele_size);
int wrap_fn_queue_pop_nowait(hcsoftbus lib, void *shmq, void **ele, int *ele_size);
int wrap_fn_queue_pop_timeout(hcsoftbus lib, void *shmq, void **ele, int *ele_size, int sec, int nsec);
void wrap_fn_queue_free_poped(hcsoftbus lib, void *ptr);
 
/////////////////////////////////////////////////////////
// socket mode
void *wrap_fn_socket_open(hcsoftbus lib, int mod);
int wrap_fn_socket_close(hcsoftbus lib, void* s);
int wrap_fn_socket_bind(hcsoftbus lib, void *s, int port);
int wrap_fn_socket_listen(hcsoftbus lib, void *s);
int wrap_fn_socket_connect(hcsoftbus lib, void *s, int port);
int wrap_fn_socket_send(hcsoftbus lib, void *s, const void *buf, const int size);
int wrap_fn_socket_recv(hcsoftbus lib, void *s, void **buf, int *size);
void wrap_fn_socket_buf_free(hcsoftbus lib, void *buf);
int wrap_fn_socket_port(hcsoftbus lib, void *s);
 
 
 
#ifdef __cplusplus
}
#endif
 
#endif