From 3befca7f98f0e60f6ccbf34cc52a387d76cda822 Mon Sep 17 00:00:00 2001
From: skywind3000 <skywind3000@163.com>
Date: Mon, 12 Sep 2016 12:23:14 +0800
Subject: [PATCH] cut long lines to short lines within 78 characters, add
 ikcp_getconv

---
 ikcp.c | 25 ++++++++++++++++++-------
 ikcp.h | 10 +++++++---
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/ikcp.c b/ikcp.c
index 3edb43f..ef11690 100644
--- a/ikcp.c
+++ b/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;
+}
+
+
diff --git a/ikcp.h b/ikcp.h
index 9b92b16..c5f29a0 100644
--- a/ikcp.h
+++ b/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
 }