Index: trunk/include/cf_base.h
===================================================================
--- trunk/include/cf_base.h	(revision 4)
+++ trunk/include/cf_base.h	(revision 4)
@@ -0,0 +1,22 @@
+/**
+ * cf_base.h
+ */
+#ifndef __CF_BASE_H__
+#define __CF_BASE_H__
+
+typedef enum {
+	CF_TRUE = 0,
+	CF_FALSE = 1
+} E_CF_BOOL;
+
+#define CF_OK							0
+#define CF_ERROR						-1
+#define CF_ERROR_BASE					CF_ERROR * 1000
+
+#ifdef _WIN32
+# define CF_EXPORT		__declspec(dllexport)
+#else // #ifdef _WIN32
+# define CF_EXPORT
+#endif // #ifdef _WIN32
+
+#endif // #ifndef __CF_BASE_H__
Index: trunk/include/cf_file.h
===================================================================
--- trunk/include/cf_file.h	(revision 4)
+++ trunk/include/cf_file.h	(revision 4)
@@ -0,0 +1,60 @@
+/**
+ * cf_file.h
+ */
+#ifndef __CF_FILE_H__
+#define __CF_FILE_H__
+
+#include "cf_base.h"
+#include <fcntl.h>
+
+#ifdef _WIN32
+# define O_RDONLY		_O_RDONLY	| _O_BINARY
+# define O_WRONLY		_O_WRONLY	| _O_BINARY
+# define O_RDWR			_O_RDWR		| _O_BINARY
+# define O_APPEND		_O_APPEND	| _O_BINARY
+# define O_CREAT		_O_CREAT	| _O_BINARY
+# define O_TRUNC		_O_TRUNC
+#endif // #ifdef _WIN32
+
+#define CF_ERROR_FILE					CF_ERROR_BASE * 2
+
+#define CF_ERROR_FILE_OPEN				CF_ERROR_FILE - 1
+#define CF_ERROR_FILE_INVALID_ARGS		CF_ERROR_FILE - 2
+#define CF_ERROR_FILE_READ				CF_ERROR_FILE - 3
+#define CF_ERROR_FILE_WRITE				CF_ERROR_FILE - 4
+#define CF_ERROR_FILE_CREATE			CF_ERROR_FILE - 5
+#define CF_ERROR_FILE_CLOSE				CF_ERROR_FILE - 6
+#define CF_ERROR_FILE_GET_SIZE			CF_ERROR_FILE - 7
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CF_EXPORT int
+CF_File_Open			(const char	* path,
+						 const int	flag);
+
+CF_EXPORT int
+CF_FILE_Close			(const int	fd);
+
+CF_EXPORT int
+CF_File_Create			(const char * path);
+
+CF_EXPORT int
+CF_File_Read			(const int		fd,
+						 void			* buf,
+						 const size_t	len);
+
+CF_EXPORT int
+CF_File_Write			(const int		fd,
+						 const void		* buf, 
+						 const size_t	len);
+
+CF_EXPORT int
+CF_File_GetSize			(const int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef __CF_FILE_H__
Index: trunk/include/cf_socket.h
===================================================================
--- trunk/include/cf_socket.h	(revision 4)
+++ trunk/include/cf_socket.h	(revision 4)
@@ -0,0 +1,92 @@
+/**
+ * cf_socket.h
+ */
+#ifndef __CF_SOCKET_H__
+#define __CF_SOCKET_H__
+
+#include "cf_base.h"
+#include <stddef.h>
+
+#ifdef _WIN32
+typedef int socklen_t;
+#endif // #ifdef _WIN32
+
+#define CF_ERROR_SOCKET					CF_ERROR_BASE * 3
+
+#define CF_ERROR_SOCKET_INITIALIZE		CF_ERROR_SOCKET - 1
+#define CF_ERROR_SOCKET_NOT_INITIALIZED	CF_ERROR_SOCKET - 2
+#define CF_ERROR_SOCKET_FINALIZE		CF_ERROR_SOCKET - 3
+#define CF_ERROR_SOCKET_CLOSE			CF_ERROR_SOCKET - 4
+#define CF_ERROR_SOCKET_CREATE			CF_ERROR_SOCKET - 5
+#define CF_ERROR_SOCKET_CONNECT			CF_ERROR_SOCKET - 6
+#define CF_ERROR_SOCKET_SET_OPTION		CF_ERROR_SOCKET - 7
+#define CF_ERROR_SOCKET_GET_OPTION		CF_ERROR_SOCKET - 8
+#define CF_ERROR_SOCKET_SET_TIMEOUT		CF_ERROR_SOCKET - 9
+#define CF_ERROR_SOCKET_INVALID_ARGS	CF_ERROR_SOCKET - 10
+#define CF_ERROR_SOCKET_INVALID_SOCKET	CF_ERROR_SOCKET - 11
+#define CF_ERROR_SOCKET_GET_HOST		CF_ERROR_SOCKET - 12
+#define CF_ERROR_SOCKET_BIND			CF_ERROR_SOCKET - 13
+#define CF_ERROR_SOCKET_LISTEN			CF_ERROR_SOCKET - 14
+#define CF_ERROR_SOCKET_ACCEPT			CF_ERROR_SOCKET - 15
+#define CF_ERROR_SOCKET_SEND			CF_ERROR_SOCKET - 16
+#define CF_ERROR_SOCKET_RECV			CF_ERROR_SOCKET - 17
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CF_EXPORT E_CF_BOOL
+CF_Socket_IsInitialized	(void);
+
+CF_EXPORT int
+CF_Socket_Initialize	(void);
+
+CF_EXPORT int
+CF_Socket_Finalize		(void);
+
+CF_EXPORT int
+CF_Socket_Close			(const int sock);
+
+CF_EXPORT int
+CF_Socket_SetOption		(const int		sock,
+						 const int		optname,
+						 const void		* optval,
+						 const size_t	optlen);
+
+CF_EXPORT int
+CF_Socket_GetOption		(const int	sock,
+						 const int	optname,
+						 void		* optval,
+						 size_t		* optlen);
+
+CF_EXPORT int
+CF_Socket_SetTimeout	(const int	sock,
+						 const int	timeout);
+
+CF_EXPORT int
+CF_Socket_Connect		(const char				* ip,
+						 const unsigned short	port);
+
+CF_EXPORT int
+CF_Socket_Server		(const unsigned short	port,
+						 const int				backlog);
+
+CF_EXPORT int
+CF_Socket_Accept		(const int	sock,
+						 void		* address /* struct sockaddr_in * */);
+
+CF_EXPORT int
+CF_Socket_Send			(const int	sock,
+						 const void	* buf,
+						 const int	len);
+
+CF_EXPORT int
+CF_Socket_Recv			(const int	sock,
+						 void		* buf,
+						 const int	len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef __CF_SOCKET_H__
Index: trunk/include/cf_thread.h
===================================================================
--- trunk/include/cf_thread.h	(revision 4)
+++ trunk/include/cf_thread.h	(revision 4)
@@ -0,0 +1,62 @@
+/**
+ * cf_thread.h
+ */
+#ifndef __CF_THREAD_H__
+#define __CF_THREAD_H__
+
+#include "cf_base.h"
+
+#ifdef _WIN32
+//# include <stddef.h>
+# define CF_THREAD_RETURN	uintptr_t
+# define CF_THREAD_CALL		__stdcall
+#else // #ifdef _WIN32
+# define CF_THREAD_RETURN	void *
+# define CF_THREAD_CALL
+#endif // #ifdef _WIN32
+
+#define CF_THREAD_FUNCTION	CF_THREAD_RETURN CF_THREAD_CALL
+
+#define CF_ERROR_THREAD					CF_ERROR_BASE * 4
+#define CF_ERROR_THREAD_CREATE			CF_ERROR_THREAD - 1
+#define CF_ERROR_THREAD_INVALID_ARGS	CF_ERROR_THREAD - 2
+
+#define CF_ERROR_MUTEX					CF_ERROR_BASE * 5
+#define CF_ERROR_MUTEX_CREATE			CF_ERROR_MUTEX - 1
+#define CF_ERROR_MUTEX_INVALID_ARGS		CF_ERROR_MUTEX - 2
+
+typedef void *	CF_Thread;
+typedef void *	CF_Mutex;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CF_EXPORT int
+CF_Thread_Create	(CF_Thread			* threadID,
+					 CF_THREAD_RETURN	callback,
+					 void				* arg);
+
+CF_EXPORT int
+CF_Thread_Release	(CF_Thread * threadID);
+
+CF_EXPORT int
+CF_Thread_Join		(CF_Thread * threadID);
+
+CF_EXPORT int
+CF_Mutex_Create		(CF_Mutex * mutex);
+
+CF_EXPORT int
+CF_Mutex_Destory	(CF_Mutex * mutex);
+
+CF_EXPORT int
+CF_Mutex_Lock		(CF_Mutex * mutex);
+
+CF_EXPORT int
+CF_Mutex_Unlock		(CF_Mutex * mutex);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef __CF_THREAD_H__
Index: trunk/src/cf_file.c
===================================================================
--- trunk/src/cf_file.c	(revision 4)
+++ trunk/src/cf_file.c	(revision 4)
@@ -0,0 +1,86 @@
+/**
+ * cf_file.c
+ */
+#include "cf_file.h"
+
+#ifdef _WIN32
+# include <io.h>
+#else // #ifdef _WIN32
+# include <unistd.h>
+#endif // #ifdef _WIN32
+
+int
+CF_File_Open (const char	* path,
+			  const int		flag)
+{
+	int result = open (path, flag, 0);
+
+	if (result < 0)
+		return CF_ERROR_FILE_OPEN;
+
+	return result;
+}
+
+int
+CF_File_Create (const char * path)
+{
+	int result = open (path, O_CREAT | O_WRONLY | O_TRUNC, 0);
+
+	if (result < 0)
+		return CF_ERROR_FILE_CREATE;
+
+	return result;
+}
+
+int
+CF_File_Close (const int fd)
+{
+	int result = 0;
+
+	if (fd < 0)
+		return CF_ERROR_FILE_INVALID_ARGS;
+
+	result = close (fd);
+
+	if (result < 0)
+		return CF_ERROR_FILE_CLOSE;
+
+	return CF_OK;
+}
+
+int
+CF_File_Read (const int		fd,
+			  void			* buf,
+			  const size_t	len)
+{
+	int result = (int) read (fd, buf, len);
+
+	if (result < 0)
+		return CF_ERROR_FILE_READ;
+
+	return CF_OK;
+}
+
+int
+CF_File_Write (const int	fd,
+			   const void	* buf, 
+			   const size_t	len)
+{
+	int result = (int) write (fd, buf, len);
+
+	if (result != len)
+	  return CF_ERROR_FILE_WRITE;
+
+	return CF_OK;
+}
+
+int
+CF_File_GetSize (const int fd)
+{
+	int result = (int) lseek (fd, 0, SEEK_END);
+
+	if (result < 0 || lseek (fd, 0, SEEK_SET) < 0)
+		return CF_ERROR_FILE_GET_SIZE;
+
+	return result;
+}
Index: trunk/src/cf_local.h
===================================================================
--- trunk/src/cf_local.h	(revision 4)
+++ trunk/src/cf_local.h	(revision 4)
@@ -0,0 +1,13 @@
+/*
+ * cf_local.h
+ */
+#ifndef __CF_LOCAL_H__
+#define __CF_LOCAL_H__
+
+#define TRY						do
+#define TRY_BREAK				break
+#define CATCH_IF(__expr)		while (0); if (__expr)
+#define CATCH_ELSE_IF(__expr)	else if (__expr)
+#define CATCH_ELSE				else
+
+#endif // #ifndef __CF_LOCAL_H__
Index: trunk/src/cf_socket.c
===================================================================
--- trunk/src/cf_socket.c	(revision 4)
+++ trunk/src/cf_socket.c	(revision 4)
@@ -0,0 +1,316 @@
+/**
+ * cf_socket.c
+ */
+#include "cf_socket.h"
+#include "cf_local.h"
+
+#ifdef _WIN32
+# include <WinSock2.h>
+#else
+# include <netinet/in.h>
+# include <sys/socket.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+# include <unistd.h>
+#endif
+
+#include <string.h>
+
+#define CHECK_SOCKET_INIT()					\
+	if (!CF_Socket_IsInitialized ())		\
+		return CF_ERROR_SOCKET_NOT_INITIALIZED 
+
+#define CHECK_INVALID_SOCKET(__sock)		\
+	if (__sock < 0)						\
+		return CF_ERROR_SOCKET_INVALID_SOCKET
+
+E_CF_BOOL gInitialized = CF_FALSE;
+
+E_CF_BOOL
+CF_Socket_IsInitialized (void)
+{
+	return gInitialized;
+}
+
+int
+CF_Socket_Initialize (void)
+{
+	int result = 0;
+
+#ifdef WIN32
+	WSADATA winsockData;
+	result = WSAStartup (MAKEWORD (2, 0), &winsockData);
+#endif
+	gInitialized = CF_TRUE;
+
+	if (result != 0)
+	   return CF_ERROR_SOCKET_INITIALIZE;
+	
+	return CF_OK;
+}
+
+int
+CF_Socket_Finalize (void)
+{
+	int result = 0;
+
+	if (!CF_Socket_IsInitialized ())
+		return CF_ERROR_SOCKET_NOT_INITIALIZED;
+
+#ifdef WIN32
+	result = WSACleanup ();
+#endif
+   	if (result != 0)
+	   return CF_ERROR_SOCKET_FINALIZE;
+
+	return CF_OK;
+}
+
+int
+CF_Socket_Close (const int sock)
+{
+	int result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	result = /* continued */
+#ifdef _WIN32
+		closesocket (socket);
+#else
+		close (sock);
+#endif
+
+	if (result != 0)
+		return CF_ERROR_SOCKET_CLOSE;
+
+	return CF_OK;
+}
+
+int
+CF_Socket_SetOption (const int		sock,
+					 const int		optname,
+					 const void		* optval,
+					 const size_t	optlen)
+{
+	int	result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	result = setsockopt (sock,
+						 SOL_SOCKET,
+						 optname,
+#ifdef _WIN32
+						 (char *) optval,
+#else
+						 optval,
+#endif
+						 (socklen_t) optlen);
+	if (result < 0)
+		return CF_ERROR_SOCKET_SET_OPTION;
+
+	return CF_OK;
+}
+
+int
+CF_Socket_GetOption (const int	sock,
+					 const int	optname,
+					 void		* optval,
+					 size_t		* optlen)
+{
+	int	result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	result = getsockopt (sock,
+						 SOL_SOCKET,
+						 optname,
+#ifdef _WIN32
+						 (char *) optval,
+#else
+						 optval,
+#endif
+						 (socklen_t *) optlen);
+	if (result < 0)
+		return CF_ERROR_SOCKET_GET_OPTION;
+
+	return CF_OK;
+}
+
+int
+CF_Socket_SetTimeout (const int	sock,
+					  const int timeout)
+{
+	int result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	if (timeout < 0)
+		return CF_ERROR_SOCKET_INVALID_ARGS;
+
+#ifndef _WIN32
+	struct timeval	timeval;
+	timeval.tv_sec = timeout;
+	timeval.tv_usec= 0;
+#else
+	int				time_ms = timeout * 1000;
+#endif
+
+	result = CF_Socket_SetOption (sock,
+								  SO_RCVTIMEO,
+#ifdef _WIN32
+								  &time_ms,
+								  sizeof (time_ms));
+#else
+								  &timeval,
+								  sizeof (timeval));
+#endif
+	if (result < 0)
+		return CF_ERROR_SOCKET_SET_TIMEOUT;
+	/*----------------------------------------------------------------*/
+
+	return CF_OK;
+}
+
+int
+CF_Socket_Connect (const char			* ip,
+				   const unsigned short	port)
+{
+	int					result = 0;
+	int					sock = 0;
+	struct sockaddr_in	address;
+	struct hostent		* hostEnt;
+
+	CHECK_SOCKET_INIT ();
+
+	sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (sock < 0)
+		return CF_ERROR_SOCKET_CREATE;
+
+	address.sin_family		= AF_INET;
+	address.sin_port		= htons (port);
+	address.sin_addr.s_addr	= inet_addr (ip);
+
+	TRY
+	{
+		if (address.sin_addr.s_addr == (unsigned int)-1)
+		{
+			hostEnt = gethostbyname (ip);
+			if (hostEnt == NULL)
+			{
+				result = CF_ERROR_SOCKET_GET_HOST;
+				TRY_BREAK;
+			}
+
+			address.sin_family = (sa_family_t) hostEnt->h_addrtype;
+			memcpy (&(address.sin_addr.s_addr), hostEnt->h_addr, (size_t) hostEnt->h_length);
+		}
+
+		result = connect (sock, (struct sockaddr *) &address, sizeof (address));
+		if (result < 0)
+		{
+			result = CF_ERROR_SOCKET_CONNECT;
+			TRY_BREAK;
+		}
+	}
+	CATCH_IF (result < 0)
+	{
+		CF_Socket_Close (sock);
+		return result;
+	}
+
+	return CF_OK;
+}
+
+int
+CF_Socket_Server (const unsigned short	port,
+				  const int				backlog)
+{
+	int					result = 0;
+	int					sock = 0;
+	struct sockaddr_in	address;
+
+	CHECK_SOCKET_INIT ();
+
+	sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (sock < 0)
+		return CF_ERROR_SOCKET_CREATE;
+
+	address.sin_family		= AF_INET;
+	address.sin_addr.s_addr	= htonl (INADDR_ANY);
+	address.sin_port		= htons (port);
+
+	TRY {
+		result = bind (sock, (struct sockaddr *) &address, sizeof (struct sockaddr));
+		if (result < 0)
+		{
+			result = CF_ERROR_SOCKET_BIND;
+			TRY_BREAK;
+		}
+
+		result = listen (sock, backlog);
+		if (result < 0)
+		{
+			result = CF_ERROR_SOCKET_LISTEN;
+			TRY_BREAK;
+		}
+	}
+	CATCH_IF (result < 0)
+	{
+		CF_Socket_Close (sock);
+		return result;
+	}
+
+	return sock;
+}
+
+int
+CF_Socket_Accept (const int	sock,
+				  void		* address)
+{
+	int					sockClient;
+	struct sockaddr_in	remoteAddress;
+	socklen_t			len = sizeof (remoteAddress);
+
+	CHECK_INVALID_SOCKET (sock);
+
+	sockClient = accept (sock, (struct sockaddr *) &remoteAddress, &len);
+	if (sockClient < 0)
+		return CF_ERROR_SOCKET_ACCEPT;
+
+	if (address != NULL)
+		memcpy ((void *) address, (void *) &remoteAddress, sizeof (struct sockaddr_in));
+
+	return sockClient;
+}
+
+int
+CF_Socket_Send (const int	sock,
+				const void	* buf,
+				const int	len)
+{
+	int result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	result = (int) send (sock, buf, (size_t) len, 0);
+	if (result != len)
+		return CF_ERROR_SOCKET_SEND;
+
+	return CF_OK;
+}
+
+int
+CF_Socket_Recv (const int	sock,
+				void		* buf,
+				const int	len)
+{
+	int result = 0;
+
+	CHECK_INVALID_SOCKET (sock);
+
+	result = (int) recv (sock, buf, (size_t) len, 0);
+	if (result < 0)
+		return CF_ERROR_SOCKET_RECV;
+
+	return result;
+}
Index: trunk/src/cf_thread.c
===================================================================
--- trunk/src/cf_thread.c	(revision 4)
+++ trunk/src/cf_thread.c	(revision 4)
@@ -0,0 +1,166 @@
+/**
+ * cf_thread.c
+ */
+#include "cf_thread.h"
+#include "cf_local.h"
+
+#include <stdlib.h>
+
+#ifdef _WIN32
+# include <windows.h>
+# include <process.h>
+# define THREAD_TYPE	HANDLE
+# define MUTEX_TYPE		HANDLE
+#else // #ifdef _WIN32
+# include <pthread.h>
+# define THREAD_TYPE	pthread_t
+# define MUTEX_TYPE		pthread_mutex_t
+#endif // #ifdef _WIN32
+
+#define CHECK_INVALID_THREAD(__h)		\
+	if (__h == NULL)					\
+		return CF_ERROR_THREAD_INVALID_ARGS
+
+#define CHECK_INVALID_MUTEX(__h)		\
+	if (__h == NULL)					\
+		return CF_ERROR_MUTEX_INVALID_ARGS
+
+int
+CF_CLOSE_CTX (void * ctx)
+{
+#ifdef _WIN32
+	CloseHandle (ctx);
+#else
+	free (ctx);
+#endif
+
+	return CF_OK;
+}
+
+int
+CF_Thread_Create (CF_Thread			* threadID,
+				  CF_THREAD_RETURN	callback,
+				  void				* arg)
+{
+	int result = 0;
+
+	TRY
+	{
+#ifdef _WIN32
+		*threadID = (THREAD_TYPE) _beginthreadex (0, 0, callback, arg, 0, 0);
+		if (*threadID == NULL)
+			result = -1;
+#else
+		*threadID = (THREAD_TYPE *) calloc (sizeof (THREAD_TYPE), 1);
+		if (*threadID == NULL)
+		{
+			result = -2;
+			TRY_BREAK;
+		}
+
+		result = pthread_create ((THREAD_TYPE *) *threadID, NULL, callback, arg);
+#endif
+	}
+	CATCH_IF (result < 0)
+	{
+		return CF_ERROR_THREAD_CREATE;
+	}
+
+	return CF_OK;
+}
+
+int
+CF_Thread_Release (CF_Thread * threadID)
+{
+	CHECK_INVALID_THREAD (*threadID);
+
+	CF_CLOSE_CTX (*threadID);
+
+	return CF_OK;
+}
+
+int
+CF_Thread_Join (CF_Thread * threadID)
+{
+	CHECK_INVALID_THREAD (*threadID);
+
+#ifdef _WIN32
+	WaitForSingleObject ((THREAD_TYPE) *threaID, INFINITE);
+#else
+	int status;
+	pthread_join (*((THREAD_TYPE *) *threadID), (void *)&status);
+#endif
+
+	return CF_OK;
+}
+
+int
+CF_Mutex_Create (CF_Mutex * mutex)
+{
+	int result = 0;
+
+	TRY
+	{
+#ifdef _WIN32
+		*mutex = (MUTEX_TYPE) CreateMutexA (NULL, FALSE, NULL);
+		if (*mutex == NULL)
+		{
+			result = -1;
+			TRY_BREAK;
+		}
+#else
+		*mutex = (MUTEX_TYPE *) calloc (sizeof (MUTEX_TYPE), 1);
+		if (*mutex == NULL)
+		{
+			result = -2;
+			TRY_BREAK;
+		}
+
+		result = pthread_mutex_init (*mutex, NULL);
+#endif
+	}
+	CATCH_IF (result < 0)
+	{
+		return CF_ERROR_MUTEX_CREATE;
+	}
+
+	return CF_OK;
+}
+
+int
+CF_Mutex_Destory (CF_Mutex * mutex)
+{
+	CHECK_INVALID_MUTEX (*mutex);
+
+	CF_CLOSE_CTX (*mutex);
+
+	return CF_OK;
+}
+
+int
+CF_Mutex_Lock (CF_Mutex * mutex)
+{
+	CHECK_INVALID_MUTEX (*mutex);
+
+#ifdef _WIN32
+	WaitForSingleObject ((MUTEX_TYPE) *mutex, INFINITE);
+#else
+	pthread_mutex_lock ((MUTEX_TYPE *) *mutex);
+#endif
+
+	return CF_OK;
+}
+
+int
+CF_Mutex_Unlock (CF_Mutex * mutex)
+{
+	CHECK_INVALID_MUTEX (*mutex);
+
+#ifdef _WIN32
+	ReleaseMutex (*mutex);
+#else
+	pthread_mutex_unlock ((MUTEX_TYPE *) *mutex);
+#endif
+
+	return CF_OK;
+}
Index: trunk/src/makefile
===================================================================
--- trunk/src/makefile	(revision 4)
+++ trunk/src/makefile	(revision 4)
@@ -0,0 +1,95 @@
+#----------------------------------------------------------
+# platform
+#----------------------------------------------------------
+PLATFORM	= 64
+DEBUG		= true
+
+#----------------------------------------------------------
+# load system info
+#----------------------------------------------------------
+ifeq ($(PLATFORM), 64)
+	PLATFORM	= -m64
+else
+	PLATFORM	= -m32
+endif
+
+UNAME_A		:= $(shell uname -a)
+EXT_SHARED	= so
+EXT_STATIC	= a
+
+ifeq ($(findstring CYGWIN,$(UNAME_A)),CYGWIN)
+	# forced
+	PLATFORM	= -m32
+	EXT_SHARED	= dll
+	EXT_STATIC	= lib
+endif
+
+ifeq ($(DEBUG), true)
+	DEFS = -D_DEBUG
+	FLAG = -g
+else
+	DEFS = 
+	FLAG = 
+endif
+
+#----------------------------------------------------------
+# env
+#----------------------------------------------------------
+FILES			=	\
+					cf_file			\
+					cf_socket		\
+					cf_thread		\
+
+LIB_NAME		= CF
+
+CC				= gcc
+LD				= gcc
+AR				= ar
+CDEFS			= $(DEFS) -DLINUX -DUNIX -DMTHREAD -D_REENTRANT
+CFLAGS			= $(PLATFORM) $(FLAG) -Wall -Wconversion -Wpointer-arith -Wcast-align -fPIC
+LDFLAGS			= $(PLATFORM) -Wl,-Bsymbolic
+SHARED_FLAGS	= $(LDFLAGS) -shared
+ARFLAGS			= rc
+
+SOURCE_TYPE		= c
+TARGET_PATH		= ../_build
+OBJ_PATH		= ../_obj
+TARGET			= $(TARGET_PATH)/lib$(LIB_NAME).$(EXT_SHARED)
+SRCS			= $(addsuffix .$(SOURCE_TYPE),$(FILES))
+OBJS			= $(addprefix $(OBJ_PATH)/,$(addsuffix .o,$(FILES)))
+
+INCLUDES		= -I../include
+LIBS			= -lpthread
+
+#----------------------------------------------------------
+# label
+#----------------------------------------------------------
+all: $(OBJ_PATH) $(TARGET_PATH) $(TARGET)
+	@echo ========== Complete CHEROXY compilation ==========
+$(TARGET_PATH): dummy
+	@if [ ! -d $@ ] ; then mkdir $@ ; fi
+$(OBJ_PATH): dummy
+	@if [ ! -d $@ ] ; then mkdir $@ ; fi
+
+# link
+$(TARGET_PATH)/%.$(EXT_SHARED): $(OBJS)
+	$(LD) $(SHARED_FLAGS) -o $@ $?
+
+$(TARGET_PATH)/%.$(EXT_STATIC): $(OBJS)
+	$(AR) $(ARFLAGS) -o $@ $?
+
+# compile
+$(OBJ_PATH)/%.o: %.$(SOURCE_TYPE)
+	$(CC) $(CFLAGS) $(CDEFS) $(INCLUDES) -o $@ -c $?
+
+clean: dummy
+	rm -rf $(TARGET_PATH) $(OBJ_PATH)
+
+dummy:
+
+# test
+test: all
+	$(CXX) $(CXXFLAGS) $(INCLUDES) $(CXXDEFS) -o $(OBJ_PATH)/main.o -c main.cpp
+	$(LD) $(LDFLAGS) -o $(TARGET_PATH)/cf.ex $(OBJ_PATH)/main.o -L$(TARGET_PATH) -lpthread
+	LD_LIBRARY_PATH=$(TARGET_PATH) $(TARGET_PATH)/cf.ex
+
