mirror of
https://github.com/skywind3000/kcp.git
synced 2025-01-13 20:10:12 +08:00
cut long lines to short lines within 78 characters, add ikcp_getconv
This commit is contained in:
parent
e2812af1e5
commit
3befca7f98
25
ikcp.c
25
ikcp.c
@ -292,13 +292,6 @@ ikcpcb* ikcp_create(IUINT32 conv, void *user)
|
||||
return kcp;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// set output function
|
||||
//---------------------------------------------------------------------
|
||||
void ikcp_setoutput(ikcpcb *kcp, int (*output)(const char *buf, int len, ikcpcb *kcp, void *user))
|
||||
{
|
||||
kcp->output = output;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// release a new kcpcb
|
||||
@ -347,6 +340,15 @@ void ikcp_release(ikcpcb *kcp)
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// set output callback, which will be invoked by kcp
|
||||
//---------------------------------------------------------------------
|
||||
void ikcp_setoutput(ikcpcb *kcp, int (*output)(const char *buf, int len,
|
||||
ikcpcb *kcp, void *user))
|
||||
{
|
||||
kcp->output = output;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// user/upper level recv: returns size, returns below zero for EAGAIN
|
||||
@ -1261,3 +1263,12 @@ int ikcp_waitsnd(const ikcpcb *kcp)
|
||||
}
|
||||
|
||||
|
||||
// read conv
|
||||
IUINT32 ikcp_getconv(const void *ptr)
|
||||
{
|
||||
IUINT32 conv;
|
||||
ikcp_decode32u((const char*)ptr, &conv);
|
||||
return conv;
|
||||
}
|
||||
|
||||
|
||||
|
10
ikcp.h
10
ikcp.h
@ -333,12 +333,13 @@ extern "C" {
|
||||
// output callback can be setup like this: 'kcp->output = my_udp_output'
|
||||
ikcpcb* ikcp_create(IUINT32 conv, void *user);
|
||||
|
||||
// set output function
|
||||
void ikcp_setoutput(ikcpcb *kcp, int (*output)(const char *buf, int len, ikcpcb *kcp, void *user));
|
||||
|
||||
// release kcp control object
|
||||
void ikcp_release(ikcpcb *kcp);
|
||||
|
||||
// set output callback, which will be invoked by kcp
|
||||
void ikcp_setoutput(ikcpcb *kcp, int (*output)(const char *buf, int len,
|
||||
ikcpcb *kcp, void *user));
|
||||
|
||||
// user/upper level recv: returns size, returns below zero for EAGAIN
|
||||
int ikcp_recv(ikcpcb *kcp, char *buffer, int len);
|
||||
|
||||
@ -392,6 +393,9 @@ void ikcp_log(ikcpcb *kcp, int mask, const char *fmt, ...);
|
||||
// setup allocator
|
||||
void ikcp_allocator(void* (*new_malloc)(size_t), void (*new_free)(void*));
|
||||
|
||||
// read conv
|
||||
IUINT32 ikcp_getconv(const void *ptr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user