Index: /trunk/include/cf_codec.h
===================================================================
--- /trunk/include/cf_codec.h	(revision 66)
+++ /trunk/include/cf_codec.h	(revision 66)
@@ -0,0 +1,35 @@
+/**
+ * @file	cf_codec.h
+ * @author	myusgun <myusgun@gmail.com>
+ *
+ * @remark
+ * 데이터 변환 기능 제공
+ *
+ * @example codec.c
+ */
+#include "cf_base.h"
+
+#include <stddef.h>
+
+#ifndef __CF_CODEC_H__
+#define __CF_CODEC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CF_EXPORT int
+CF_Codec_BinaryToHex		(const unsigned char	* bin,
+							 const size_t			len,
+							 char					* hex);
+
+CF_EXPORT int
+CF_Codec_HexToBinary		(const char		* hex,
+							 unsigned char	* bin,
+							 size_t			* len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef __CF_DEBUG_H__
Index: /trunk/include/cf_debug.h
===================================================================
--- /trunk/include/cf_debug.h	(revision 65)
+++ /trunk/include/cf_debug.h	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_debug.h
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  *
  * @remark
@@ -8,7 +7,5 @@
  * Preprocessor에 _DEBUG가 정의되어 있는 경우에 만
  * 디버그 코드가 동작하도록 할 수 있음 <br />
- * 디버그 메시지는 stdout 및 stderr를 이용한 파일 포인터 출력을 지원하고,
- * 환경에 적합하도록 사용자가 구성한 컨텍스트를 이용하여 사용할 수도 있음 <br />
- * (단, 콜스택의 푸시/팝은 컨텍스트를 이용해야만 사용 가능)
+ * 디버그 메시지는 stdout 및 stderr 등의 파일 포인터 출력을 지원함
  *
  * @example debug.c
@@ -20,4 +17,5 @@
 
 #include <stdio.h>
+#include <stddef.h>
 
 /** Windows 함수 이름 매크로 재정의 */
@@ -121,5 +119,5 @@
 						 const int				line,
 						 const unsigned char	* bin,
-						 const int				len,
+						 const size_t			len,
 						 const char				* fmt, ...);
 
Index: /trunk/include/cf_error.h
===================================================================
--- /trunk/include/cf_error.h	(revision 65)
+++ /trunk/include/cf_error.h	(revision 66)
@@ -1,2 +1,6 @@
+/**
+ * @file	cf_error.h
+ * @author	myusgun <myusgun@gmail.com>
+ */
 #ifndef __CF_ERROR_H__
 #define __CF_ERROR_H__
@@ -88,4 +92,11 @@
 /* }}} log */
 
+/* codec {{{ */
+#define CF_ERROR_CODEC						CF_ERROR_BASE * 8
+/*------------------------------------------------------------*/
+#define CF_ERROR_CODEC_INVALID_ARGS			CF_ERROR_CODEC - 1
+#define CF_ERROR_CODEC_NOT_HEXSTRING		CF_ERROR_CODEC - 2
+/* }}} codec */
+
 
 #endif // #ifndef __CF_ERROR_H__
Index: /trunk/include/cf_file.h
===================================================================
--- /trunk/include/cf_file.h	(revision 65)
+++ /trunk/include/cf_file.h	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_file.h
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  *
  * @example file.c
Index: /trunk/include/cf_log.h
===================================================================
--- /trunk/include/cf_log.h	(revision 65)
+++ /trunk/include/cf_log.h	(revision 66)
@@ -2,5 +2,8 @@
  * @file	cf_log.h
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
+ *
+ * @remark
+ * 매핑 ID 값을 이용하여 해당 로그에 기록 <br />
+ * 로그 레벨을 적용할 때도 용이하며 define 이나 enumeration 등을 활용하면 좋음
  *
  * @example log.c
Index: /trunk/include/cf_socket.h
===================================================================
--- /trunk/include/cf_socket.h	(revision 65)
+++ /trunk/include/cf_socket.h	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_socket.h
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  *
  * @remark TCP 소켓만 지원됨
Index: /trunk/include/cf_thread.h
===================================================================
--- /trunk/include/cf_thread.h	(revision 65)
+++ /trunk/include/cf_thread.h	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_thread.h
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  *
  * @remark 멀티스레드 및 뮤텍스 지원
Index: /trunk/src/cf_codec.c
===================================================================
--- /trunk/src/cf_codec.c	(revision 66)
+++ /trunk/src/cf_codec.c	(revision 66)
@@ -0,0 +1,115 @@
+/**
+ * @file	cf_codec.c
+ * @author	myusgun <myusgun@gmail.com>
+ */
+#include "cf_codec.h"
+#include "cf_error.h"
+
+#include <string.h>
+#include <stdio.h>
+
+#define ASSERT_ARGS(x)					\
+	if ((x))							\
+		return CF_ERROR_CODEC_INVALID_ARGS
+
+#define IS_NUMBER(x)		(x >= '0' && x <= '9')
+#define IS_LOWERCASE(x)		(x >= 'a' && x <= 'f')
+#define IS_UPPERCASE(x)		(x >= 'A' && x <= 'F')
+
+/**
+ * 바이너리 데이터를 16진수 문자열로 변환
+ *
+ * @return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * @param bin	바이너리 데이터
+ * @param len	바이너리 데이터 길이
+ * @param hex	16진수 문자열을 저장할 주소
+ *
+ * @remark 16진수 문자열을 저장할 메모리가 미리 할당되어야 하며, 크기는 len * 2 + 1
+ */
+int
+CF_Codec_BinaryToHex (const unsigned char	* bin,
+					  const size_t			len,
+					  char					* hex)
+{
+	size_t	iter = 0;
+	size_t	count = len * 2 + 1;
+
+	char	hexchar[] = {'0', '1', '2', '3',
+						 '4', '5', '6', '7',
+						 '8', '9', 'a', 'b',
+						 'c', 'd', 'e', 'f'};
+
+	const unsigned char	* ptr = bin;
+
+	ASSERT_ARGS (bin == NULL);
+	ASSERT_ARGS (hex == NULL);
+
+	for (iter = 0 ; iter < count ; iter += 2, ptr++)
+	{
+		hex[iter    ] = hexchar[((*(ptr)) >> 4) & 0x0f];
+		hex[iter + 1] = hexchar[((*(ptr))     ) & 0x0f];
+	}
+	hex[count] = '\0';
+
+	return CF_OK;
+}
+
+/**
+ * 16진수 문자열을 바이너리 데이터로 변환
+ *
+ * @return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * @param hex	16진수 문자열
+ * @param bin	바이너리 데이터를 저장할 주소
+ * @param len	바이너리 데이터의 길이를 저장할 주소
+ *
+ * @remark 바이너리 데이터를 저장할 메모리가 미리 할당되어야 하며, 크기는 strlen (hex) / 2
+ */
+int
+CF_Codec_HexToBinary (const char	* hex,
+					  unsigned char	* bin,
+					  size_t		* len)
+{
+	typedef	unsigned char __uchar;
+
+	int		result = 0;
+
+	size_t	length = strlen (hex); /* absolutely even-number */
+	size_t	iter = 0;
+	size_t	count = length / 2;
+	int		twochar = 0;
+
+	const char	* ptr = hex;
+	char		buf = 0;
+	__uchar		val = 0;
+
+	ASSERT_ARGS (hex == NULL);
+	ASSERT_ARGS (bin == NULL);
+	ASSERT_ARGS (len == NULL);
+
+	for (iter = 0 ; iter < count ; iter++)
+	{
+		for (twochar = 2, val = 0 ; twochar ; ptr++, twochar--)
+		{
+			buf = *ptr;
+			val = (__uchar)(val << 4);
+
+			if      (IS_NUMBER (buf))		val |= (__uchar)(buf - '0' +  0);
+			else if (IS_LOWERCASE (buf))	val |= (__uchar)(buf - 'a' + 10);
+			else if (IS_UPPERCASE (buf))	val |= (__uchar)(buf - 'A' + 10);
+			else
+			{
+				result = CF_ERROR_CODEC_NOT_HEXSTRING;
+				break;
+			}
+		}
+
+		bin[iter] = val;
+	}
+
+	if (result == 0)
+		*len = count;
+
+	return result;
+}
Index: /trunk/src/cf_debug.c
===================================================================
--- /trunk/src/cf_debug.c	(revision 65)
+++ /trunk/src/cf_debug.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_debug.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_debug.h"
@@ -105,5 +104,5 @@
 						 const int				line,
 						 const unsigned char	* bin,
-						 const int				len)
+						 const size_t			len)
 {
 	int i, j;
@@ -186,5 +185,5 @@
 				   const int			line,
 				   const unsigned char	* bin,
-				   const int			len,
+				   const size_t			len,
 				   const char			* fmt, ...)
 {
Index: /trunk/src/cf_file.c
===================================================================
--- /trunk/src/cf_file.c	(revision 65)
+++ /trunk/src/cf_file.c	(revision 66)
@@ -2,7 +2,7 @@
  * @file	cf_file.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_file.h"
+#include "cf_local.h"
 #include "cf_error.h"
 
@@ -18,5 +18,4 @@
 # define mkdir(a,b)		_mkdir (a)
 # define access(a,b)	_access (a,b)
-# define snprintf		_snprintf
 
 # define F_OK			0
Index: /trunk/src/cf_local.h
===================================================================
--- /trunk/src/cf_local.h	(revision 65)
+++ /trunk/src/cf_local.h	(revision 66)
@@ -1,4 +1,5 @@
 /**
- * cf_local.h
+ * @file	cf_local.h
+ * @author	myusgun <myusgun@gmail.com>
  */
 #ifndef __CF_LOCAL_H__
@@ -12,3 +13,8 @@
 #define CATCH_ELSE				else
 
+#if defined(_WIN32) || defined(_WIN64)
+# define snprintf		_snprintf
+#else
+#endif
+
 #endif // #ifndef __CF_LOCAL_H__
Index: /trunk/src/cf_log.c
===================================================================
--- /trunk/src/cf_log.c	(revision 65)
+++ /trunk/src/cf_log.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_log.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #if defined(_WIN32) || defined(_WIN64)
@@ -21,5 +20,4 @@
 
 #if defined(_WIN32) || defined(_WIN64)
-# define snprintf		_snprintf
 # include <Windows.h>
 #else
@@ -76,38 +74,33 @@
 
 #if defined(_WIN32) || defined(_WIN64)
-/* #if defined(_WIN32) || defined(_WIN64) {{{ */
+/* {{{ */
 struct timezone
 {
-	int tz_minuteswest; /* minutes W of Greenwich */
-	int tz_dsttime;     /* type of dst correction */
+	int tz_minuteswest;	/* minutes W of Greenwich */
+	int tz_dsttime;		/* type of dst correction */
 };
 
-// Definition of a gettimeofday function
-int gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-	// Define a structure to receive the current Windows filetime
-	FILETIME ft;
-
-	// Initialize the present time to 0 and the timezone to UTC
-	unsigned __int64 ui64 =0;
+int gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+	FILETIME			ft;
+	unsigned __int64	buf =0;
 	//static int tzflag = 0;
 
 	if (NULL != tv)
 	{
-		GetSystemTimeAsFileTime(&ft);
-
-		ui64 = (((unsigned __int64) ft.dwHighDateTime << 32)
-				+ (unsigned __int64) ft.dwLowDateTime);
-
-		if (ui64)
-		{
-			ui64 /= 10;
-			ui64 -= ((369 * 365 + 89) * (unsigned __int64) 86400) * 1000000;
-		}
-
-		// Finally change microseconds to seconds and place in the seconds value.
-		// The modulus picks up the microseconds.
-		tv->tv_sec = (long)(ui64 / 1000000UL);
-		tv->tv_usec = (long)(ui64 % 1000000UL);
+		GetSystemTimeAsFileTime (&ft);
+
+		buf |=	ft.dwHighDateTime;
+		buf <<=	32
+		buf |=	ft.dwLowDateTime;
+
+		if (buf)
+		{
+			buf /= 10;
+			buf -= ((369 * 365 + 89) * (unsigned __int64) 86400) * 1000000;
+		}
+
+		tv->tv_sec = (long)(buf / 1000000UL);
+		tv->tv_usec = (long)(buf % 1000000UL);
 	}
 
@@ -129,5 +122,5 @@
 	return 0;
 }
-/* }}} #if defined(_WIN32) || defined(_WIN64) */
+/* }}} */
 #endif
 
Index: /trunk/src/cf_socket.c
===================================================================
--- /trunk/src/cf_socket.c	(revision 65)
+++ /trunk/src/cf_socket.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_socket.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_socket.h"
Index: /trunk/src/cf_thread.c
===================================================================
--- /trunk/src/cf_thread.c	(revision 65)
+++ /trunk/src/cf_thread.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	cf_thread.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_thread.h"
Index: /trunk/src/makefile
===================================================================
--- /trunk/src/makefile	(revision 65)
+++ /trunk/src/makefile	(revision 66)
@@ -42,4 +42,5 @@
 					cf_debug		\
 					cf_log			\
+					cf_codec		\
 
 TARGET_NAME		= cf
Index: /trunk/test/codec.c
===================================================================
--- /trunk/test/codec.c	(revision 66)
+++ /trunk/test/codec.c	(revision 66)
@@ -0,0 +1,31 @@
+/**
+ * @file	codec.c
+ * @author	myusgun <myusgun@gmail.com>
+ */
+#include "cf_codec.h"
+#include "cf_debug.h"
+#include <stdio.h>
+#include <string.h>
+
+int main (void)
+{
+	char data[] =
+		"【 曲名 : 사랑하고 있는데 】\n"
+		"《 歌 : Kylee 》\n"
+		"『 절원의 템페스트 OP2 Theme 』\n";
+
+	char hex[512] = {0x00,};
+	unsigned char bin[512] = {0x00,};
+	size_t length = 0;
+
+	CF_Codec_BinaryToHex ((unsigned char *)data, strlen (data), hex);
+	CF_DEBUG_PRINT (stdout, "data : \n%s\n", data);
+	CF_DEBUG_PRINT (stdout, "hex : \n%s\n\n", hex);
+	CF_DEBUG_PRINT_BIN (stdout, (unsigned char *) data, strlen (data), "data : \n%s", data);
+
+	CF_Codec_HexToBinary (hex, bin, &length);
+	CF_DEBUG_PRINT (stdout, "bin : \n%s\n", bin);
+	CF_DEBUG_PRINT_BIN (stdout, bin, length, "bin : \n%s\n", bin);
+
+	return 0;
+}
Index: /trunk/test/debug.c
===================================================================
--- /trunk/test/debug.c	(revision 65)
+++ /trunk/test/debug.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	debug.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_file.h"
Index: /trunk/test/file.c
===================================================================
--- /trunk/test/file.c	(revision 65)
+++ /trunk/test/file.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	file.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_file.h"
Index: /trunk/test/log.c
===================================================================
--- /trunk/test/log.c	(revision 65)
+++ /trunk/test/log.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	log.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_log.h"
Index: /trunk/test/socket_client.c
===================================================================
--- /trunk/test/socket_client.c	(revision 65)
+++ /trunk/test/socket_client.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	socket_client.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_socket.h"
Index: /trunk/test/socket_server.c
===================================================================
--- /trunk/test/socket_server.c	(revision 65)
+++ /trunk/test/socket_server.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	socket_server.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_socket.h"
Index: /trunk/test/test.c
===================================================================
--- /trunk/test/test.c	(revision 65)
+++ /trunk/test/test.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	test.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_file.h"
Index: /trunk/test/thread.c
===================================================================
--- /trunk/test/thread.c	(revision 65)
+++ /trunk/test/thread.c	(revision 66)
@@ -2,5 +2,4 @@
  * @file	thread.c
  * @author	myusgun <myusgun@gmail.com>
- * @version	0.1
  */
 #include "cf_thread.h"
