make all C callback functions unexported

merge_conn
fangdingjun 6 years ago
parent 2b04f2d580
commit 3409e5e702

@ -7,23 +7,23 @@
#define ARRLEN(x) (sizeof(x) / sizeof(x[0]))
extern ssize_t OnClientDataRecvCallback(void *, void *data, size_t);
extern ssize_t OnClientDataSendCallback(void *, void *data, size_t);
extern ssize_t OnDataSourceReadCallback(void *, void *, size_t);
extern int OnClientDataChunkRecv(void *, int, void *, size_t);
extern int OnClientBeginHeaderCallback(void *, int);
extern int OnClientHeaderCallback(void *, int, void *, int, void *, int);
extern int OnClientHeadersDoneCallback(void *, int);
extern int OnClientStreamClose(void *, int);
extern ssize_t OnServerDataRecvCallback(void *, void *data, size_t);
extern ssize_t OnServerDataSendCallback(void *, void *data, size_t);
extern int OnServerDataChunkRecv(void *, int, void *, size_t);
extern int OnServerBeginHeaderCallback(void *, int);
extern int OnServerHeaderCallback(void *, int, void *, int, void *, int);
extern int OnServerStreamEndCallback(void *, int);
extern int OnServerHeadersDoneCallback(void *, int);
extern int OnServerStreamClose(void *, int);
extern ssize_t onClientDataRecvCallback(void *, void *data, size_t);
extern ssize_t onClientDataSendCallback(void *, void *data, size_t);
extern ssize_t onDataSourceReadCallback(void *, void *, size_t);
extern int onClientDataChunkRecv(void *, int, void *, size_t);
extern int onClientBeginHeaderCallback(void *, int);
extern int onClientHeaderCallback(void *, int, void *, int, void *, int);
extern int onClientHeadersDoneCallback(void *, int);
extern int onClientStreamClose(void *, int);
extern ssize_t onServerDataRecvCallback(void *, void *data, size_t);
extern ssize_t onServerDataSendCallback(void *, void *data, size_t);
extern int onServerDataChunkRecv(void *, int, void *, size_t);
extern int onServerBeginHeaderCallback(void *, int);
extern int onServerHeaderCallback(void *, int, void *, int, void *, int);
extern int onServerStreamEndCallback(void *, int);
extern int onServerHeadersDoneCallback(void *, int);
extern int onServerStreamClose(void *, int);
int send_server_connection_header(nghttp2_session *session);
struct nv_array

@ -23,11 +23,11 @@ const (
NGHTTP2_ERR_DEFERRED = -508
)
// OnServerDataRecvCallback callback function for libnghttp2 library
// onServerDataRecvCallback callback function for libnghttp2 library
// want receive data from network.
//
//export OnServerDataRecvCallback
func OnServerDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer,
//export onServerDataRecvCallback
func onServerDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer,
length C.size_t) C.ssize_t {
conn := (*ServerConn)(ptr)
buf := make([]byte, int(length))
@ -41,11 +41,11 @@ func OnServerDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer,
return C.ssize_t(n)
}
// OnServerDataSendCallback callback function for libnghttp2 library
// onServerDataSendCallback callback function for libnghttp2 library
// want send data to network.
//
//export OnServerDataSendCallback
func OnServerDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer,
//export onServerDataSendCallback
func onServerDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer,
length C.size_t) C.ssize_t {
//log.Println("server data send")
conn := (*ServerConn)(ptr)
@ -58,10 +58,10 @@ func OnServerDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer,
return C.ssize_t(n)
}
// OnServerDataChunkRecv callback function for libnghttp2 library's data chunk recv.
// onServerDataChunkRecv callback function for libnghttp2 library's data chunk recv.
//
//export OnServerDataChunkRecv
func OnServerDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
//export onServerDataChunkRecv
func onServerDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
data unsafe.Pointer, length C.size_t) C.int {
conn := (*ServerConn)(ptr)
s, ok := conn.streams[int(streamID)]
@ -74,10 +74,10 @@ func OnServerDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
return C.int(length)
}
// OnServerBeginHeaderCallback callback function for begin begin header recv.
// onServerBeginHeaderCallback callback function for begin begin header recv.
//
//export OnServerBeginHeaderCallback
func OnServerBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//export onServerBeginHeaderCallback
func onServerBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
conn := (*ServerConn)(ptr)
var TLS tls.ConnectionState
if tlsconn, ok := conn.conn.(*tls.Conn); ok {
@ -102,10 +102,10 @@ func OnServerBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnServerHeaderCallback callback function for each header recv.
// onServerHeaderCallback callback function for each header recv.
//
//export OnServerHeaderCallback
func OnServerHeaderCallback(ptr unsafe.Pointer, streamID C.int,
//export onServerHeaderCallback
func onServerHeaderCallback(ptr unsafe.Pointer, streamID C.int,
name unsafe.Pointer, namelen C.int,
value unsafe.Pointer, valuelen C.int) C.int {
conn := (*ServerConn)(ptr)
@ -139,10 +139,10 @@ func OnServerHeaderCallback(ptr unsafe.Pointer, streamID C.int,
return NGHTTP2_NO_ERROR
}
// OnServerStreamEndCallback callback function for the stream when END_STREAM flag set
// onServerStreamEndCallback callback function for the stream when END_STREAM flag set
//
//export OnServerStreamEndCallback
func OnServerStreamEndCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//export onServerStreamEndCallback
func onServerStreamEndCallback(ptr unsafe.Pointer, streamID C.int) C.int {
conn := (*ServerConn)(ptr)
s, ok := conn.streams[int(streamID)]
@ -160,10 +160,10 @@ func OnServerStreamEndCallback(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnServerHeadersDoneCallback callback function for the stream when all headers received.
// onServerHeadersDoneCallback callback function for the stream when all headers received.
//
//export OnServerHeadersDoneCallback
func OnServerHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//export onServerHeadersDoneCallback
func onServerHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
conn := (*ServerConn)(ptr)
s, ok := conn.streams[int(streamID)]
if !ok {
@ -181,10 +181,10 @@ func OnServerHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnServerStreamClose callback function for the stream when closed.
// onServerStreamClose callback function for the stream when closed.
//
//export OnServerStreamClose
func OnServerStreamClose(ptr unsafe.Pointer, streamID C.int) C.int {
//export onServerStreamClose
func onServerStreamClose(ptr unsafe.Pointer, streamID C.int) C.int {
conn := (*ServerConn)(ptr)
s, ok := conn.streams[int(streamID)]
if !ok {
@ -197,13 +197,13 @@ func OnServerStreamClose(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnDataSourceReadCallback callback function for libnghttp2 library
// onDataSourceReadCallback callback function for libnghttp2 library
// want read data from data provider source,
// return NGHTTP2_ERR_DEFERRED will cause data frame defered,
// application later call nghttp2_session_resume_data will re-quene the data frame
//
//export OnDataSourceReadCallback
func OnDataSourceReadCallback(ptr unsafe.Pointer,
//export onDataSourceReadCallback
func onDataSourceReadCallback(ptr unsafe.Pointer,
buf unsafe.Pointer, length C.size_t) C.ssize_t {
//log.Println("data source read")
dp := (*dataProvider)(ptr)
@ -224,10 +224,10 @@ func OnDataSourceReadCallback(ptr unsafe.Pointer,
return C.ssize_t(n)
}
// OnClientDataChunkRecv callback function for libnghttp2 library data chunk received.
// onClientDataChunkRecv callback function for libnghttp2 library data chunk received.
//
//export OnClientDataChunkRecv
func OnClientDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
//export onClientDataChunkRecv
func onClientDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
buf unsafe.Pointer, length C.size_t) C.int {
//log.Println("on data recv")
conn := (*ClientConn)(ptr)
@ -252,10 +252,10 @@ func OnClientDataChunkRecv(ptr unsafe.Pointer, streamID C.int,
return C.int(length)
}
// OnClientDataRecvCallback callback function for libnghttp2 library want read data from network.
// onClientDataRecvCallback callback function for libnghttp2 library want read data from network.
//
//export OnClientDataRecvCallback
func OnClientDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.size_t) C.ssize_t {
//export onClientDataRecvCallback
func onClientDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.size_t) C.ssize_t {
//log.Println("data read req", int(size))
conn := (*ClientConn)(ptr)
buf := make([]byte, int(size))
@ -271,10 +271,10 @@ func OnClientDataRecvCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.si
return C.ssize_t(n)
}
// OnClientDataSendCallback callback function for libnghttp2 library want send data to network.
// onClientDataSendCallback callback function for libnghttp2 library want send data to network.
//
//export OnClientDataSendCallback
func OnClientDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.size_t) C.ssize_t {
//export onClientDataSendCallback
func onClientDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.size_t) C.ssize_t {
//log.Println("data write req ", int(size))
conn := (*ClientConn)(ptr)
buf := C.GoBytes(data, C.int(size))
@ -287,10 +287,10 @@ func OnClientDataSendCallback(ptr unsafe.Pointer, data unsafe.Pointer, size C.si
return C.ssize_t(n)
}
// OnClientBeginHeaderCallback callback function for begin header receive.
// onClientBeginHeaderCallback callback function for begin header receive.
//
//export OnClientBeginHeaderCallback
func OnClientBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//export onClientBeginHeaderCallback
func onClientBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//log.Println("begin header")
conn := (*ClientConn)(ptr)
@ -313,10 +313,10 @@ func OnClientBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnClientHeaderCallback callback function for each header received.
// onClientHeaderCallback callback function for each header received.
//
//export OnClientHeaderCallback
func OnClientHeaderCallback(ptr unsafe.Pointer, streamID C.int,
//export onClientHeaderCallback
func onClientHeaderCallback(ptr unsafe.Pointer, streamID C.int,
name unsafe.Pointer, namelen C.int,
value unsafe.Pointer, valuelen C.int) C.int {
//log.Println("header")
@ -352,10 +352,10 @@ func OnClientHeaderCallback(ptr unsafe.Pointer, streamID C.int,
return NGHTTP2_NO_ERROR
}
// OnClientHeadersDoneCallback callback function for the stream when all headers received.
// onClientHeadersDoneCallback callback function for the stream when all headers received.
//
//export OnClientHeadersDoneCallback
func OnClientHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//export onClientHeadersDoneCallback
func onClientHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
//log.Println("frame recv")
conn := (*ClientConn)(ptr)
s, ok := conn.streams[int(streamID)]
@ -366,10 +366,10 @@ func OnClientHeadersDoneCallback(ptr unsafe.Pointer, streamID C.int) C.int {
return NGHTTP2_NO_ERROR
}
// OnClientStreamClose callback function for the stream when closed.
// onClientStreamClose callback function for the stream when closed.
//
//export OnClientStreamClose
func OnClientStreamClose(ptr unsafe.Pointer, streamID C.int) C.int {
//export onClientStreamClose
func onClientStreamClose(ptr unsafe.Pointer, streamID C.int) C.int {
//log.Println("stream close")
conn := (*ClientConn)(ptr)

@ -4,7 +4,7 @@ static ssize_t server_send_callback(nghttp2_session *session,
const uint8_t *data, size_t length,
int flags, void *user_data)
{
return OnServerDataSendCallback(user_data, (void *)data, length);
return onServerDataSendCallback(user_data, (void *)data, length);
}
static int on_server_frame_recv_callback(nghttp2_session *session,
@ -16,12 +16,12 @@ static int on_server_frame_recv_callback(nghttp2_session *session,
case NGHTTP2_HEADERS:
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST)
{
OnServerHeadersDoneCallback(user_data, frame->hd.stream_id);
onServerHeadersDoneCallback(user_data, frame->hd.stream_id);
}
case NGHTTP2_DATA:
if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM)
{
OnServerStreamEndCallback(user_data, frame->hd.stream_id);
onServerStreamEndCallback(user_data, frame->hd.stream_id);
}
break;
}
@ -34,7 +34,7 @@ static int on_server_stream_close_callback(nghttp2_session *session,
void *user_data)
{
OnServerStreamClose(user_data, stream_id);
onServerStreamClose(user_data, stream_id);
return 0;
}
@ -50,7 +50,7 @@ static int on_server_header_callback(nghttp2_session *session,
case NGHTTP2_HEADERS:
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST)
{
OnServerHeaderCallback(user_data, frame->hd.stream_id,
onServerHeaderCallback(user_data, frame->hd.stream_id,
(void *)name, namelen, (void *)value, valuelen);
}
break;
@ -64,7 +64,7 @@ static int on_server_data_chunk_recv_callback(nghttp2_session *session,
const uint8_t *data,
size_t len, void *user_data)
{
return OnServerDataChunkRecv(user_data, stream_id, (void *)data, len);
return onServerDataChunkRecv(user_data, stream_id, (void *)data, len);
}
static int on_server_begin_headers_callback(nghttp2_session *session,
@ -77,7 +77,7 @@ static int on_server_begin_headers_callback(nghttp2_session *session,
case NGHTTP2_HEADERS:
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST)
{
OnServerBeginHeaderCallback(user_data, frame->hd.stream_id);
onServerBeginHeaderCallback(user_data, frame->hd.stream_id);
}
break;
}
@ -135,14 +135,14 @@ int send_server_connection_header(nghttp2_session *session)
static ssize_t client_send_callback(nghttp2_session *session, const uint8_t *data,
size_t length, int flags, void *user_data)
{
return OnClientDataSendCallback(user_data, (void *)data, length);
return onClientDataSendCallback(user_data, (void *)data, length);
}
// recv_callback read data from network
static ssize_t client_recv_callback(nghttp2_session *session, uint8_t *buf,
size_t length, int flags, void *user_data)
{
return OnClientDataRecvCallback(user_data, (void *)buf, length);
return onClientDataRecvCallback(user_data, (void *)buf, length);
}
static int on_client_header_callback(nghttp2_session *session,
@ -158,7 +158,7 @@ static int on_client_header_callback(nghttp2_session *session,
{
/* Print response headers for the initiated request. */
//print_header(stderr, name, namelen, value, valuelen);
OnClientHeaderCallback(user_data, frame->hd.stream_id,
onClientHeaderCallback(user_data, frame->hd.stream_id,
(void *)name, namelen, (void *)value, valuelen);
break;
}
@ -179,7 +179,7 @@ static int on_client_begin_headers_callback(nghttp2_session *session,
{
//fprintf(stderr, "Response headers for stream ID=%d:\n",
// frame->hd.stream_id);
OnClientBeginHeaderCallback(user_data, stream_id);
onClientBeginHeaderCallback(user_data, stream_id);
}
break;
}
@ -242,7 +242,7 @@ static int on_client_frame_recv_callback(nghttp2_session *session,
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE)
{
//fprintf(stderr, "All headers received\n");
OnClientHeadersDoneCallback(user_data, frame->hd.stream_id);
onClientHeadersDoneCallback(user_data, frame->hd.stream_id);
}
break;
case NGHTTP2_RST_STREAM:
@ -259,13 +259,13 @@ static int on_client_data_chunk_recv_callback(nghttp2_session *session, uint8_t
int32_t stream_id, const uint8_t *data,
size_t len, void *user_data)
{
return OnClientDataChunkRecv(user_data, stream_id, (void *)data, len);
return onClientDataChunkRecv(user_data, stream_id, (void *)data, len);
}
static int on_client_stream_close_callback(nghttp2_session *session, int32_t stream_id,
uint32_t error_code, void *user_data)
{
OnClientStreamClose(user_data, stream_id);
onClientStreamClose(user_data, stream_id);
return 0;
}
@ -273,7 +273,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session, int32_t strea
uint8_t *buf, size_t length, uint32_t *data_flags,
nghttp2_data_source *source, void *user_data)
{
int ret = OnDataSourceReadCallback(source->ptr, buf, length);
int ret = onDataSourceReadCallback(source->ptr, buf, length);
if (ret == 0)
{
*data_flags = NGHTTP2_DATA_FLAG_EOF;

Loading…
Cancel
Save