cut long lines to short lines within 78 characters, add ikcp_getconv

This commit is contained in:
skywind3000 2016-09-12 12:23:14 +08:00
parent e2812af1e5
commit 3befca7f98
2 changed files with 25 additions and 10 deletions

25
ikcp.c
View File

@ -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
View File

@ -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
}