Index: /trunk/include/cf_debug.h
===================================================================
--- /trunk/include/cf_debug.h	(revision 15)
+++ /trunk/include/cf_debug.h	(revision 16)
@@ -6,4 +6,6 @@
 
 #include "cf_base.h"
+
+#include <stdio.h>
 
 #define CF_ERROR_DEBUG_INVALID_CTX			CF_ERROR_DEBUG - 1
@@ -19,4 +21,8 @@
 # define CF_UPDATE_CTX(__ctx)										\
 	CF_Debug_UpdateCtx (__ctx,__FILE__,__func__,__LINE__)
+# define CF_DEBUG_PRINT(__fp,__fmt,...)								\
+	CF_Debug_Print (__fp,__FILE__,__func__,__LINE__,__fmt,##__VA_ARGS__)
+# define CF_DEBUG_PRINT_BIN(__fp,__bin,__len,__fmt,...)				\
+	CF_Debug_PrintBin (__fp,__FILE__,__func__,__LINE__,__bin,__len,__fmt,##__VA_ARGS__)
 # define CF_DEBUG_TRACE(__ctx,__fmt,...)							\
 	do {															\
@@ -63,4 +69,20 @@
 
 CF_EXPORT int
+CF_Debug_Print			(FILE		* fp,
+						 const char	* file,
+						 const char	* func,
+						 const int	line,
+						 const char	* fmt, ...);
+
+int
+CF_Debug_PrintBin		(FILE					* fp,
+						 const char				* file,
+						 const char				* func,
+						 const int				line,
+						 const unsigned char	* bin,
+						 const int				len,
+						 const char				* fmt, ...);
+
+CF_EXPORT int
 CF_Debug_UpdateCtx		(CF_Debug_Ctx	ctx,
 						 const char		* file,
Index: /trunk/include/cf_file.h
===================================================================
--- /trunk/include/cf_file.h	(revision 15)
+++ /trunk/include/cf_file.h	(revision 16)
@@ -16,9 +16,11 @@
 #define CF_ERROR_FILE_GET_SIZE			CF_ERROR_FILE - 7
 
-#define RO		O_RDONLY
-#define WO		O_WRONLY
-#define WR		O_RDWR
-#define CR		O_CREAT
-#define TR		O_TRUNC
+typedef enum{
+	CF_FILE_RO = O_RDONLY,
+	CF_FILE_WO = O_WRONLY,
+	CF_FILE_WR = O_RDWR,
+	CF_FILE_CR = O_CREAT,
+	CF_FILE_TR = O_TRUNC
+} E_CF_FILE_FLAG, CF_FILE_FLAG;
 
 #ifdef __cplusplus
@@ -27,6 +29,6 @@
 
 CF_EXPORT int
-CF_File_Open			(const char	* path,
-						 const int	flag);
+CF_File_Open			(const char			* path,
+						 const CF_FILE_FLAG	flag);
 
 CF_EXPORT int
Index: /trunk/src/cf_debug.c
===================================================================
--- /trunk/src/cf_debug.c	(revision 15)
+++ /trunk/src/cf_debug.c	(revision 16)
@@ -5,5 +5,4 @@
 #include "cf_local.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -50,140 +49,30 @@
 
 int
-CF_Debug_Local_Print (CF_DEBUG_CTX	* ctx,
+CF_Debug_Local_Print (FILE			* fp,
+					  const char	* file,
+					  const char	* func,
+					  const int		line,
 					  const char	* fmt,
 					  va_list		valist)
 {
-	fprintf (GET_CTX_OSTREAM (ctx), "[DEBUG][%s:%d][%s] ",
-									ctx->file,
-									ctx->line,
-									ctx->func);
-	vfprintf (GET_CTX_OSTREAM (ctx), fmt, valist);
-
-	return CF_OK;
-}
-
-CF_Debug_Ctx
-CF_Debug_CreateCtx (void)
-{
-	CF_DEBUG_CTX * ctx = NULL;
-
-	ctx = (CF_DEBUG_CTX *) calloc (sizeof (CF_DEBUG_CTX), 1);
-
-	return (CF_Debug_Ctx) ctx;
-}
-
-int
-CF_Debug_DestroyCtx (CF_Debug_Ctx ctx)
-{
-	CF_DEBUG_CTX		* context = (CF_DEBUG_CTX *) ctx;
-	CF_DEBUG_CALLSTACK	* pop = NULL;
-	CF_DEBUG_CALLSTACK	* next = NULL;
-
-	CHECK_INVALID_CTX (ctx);
-
-	if (context->fp != NULL)
-		fclose (context->fp);
-
-	for (pop = next = context->callstack.caller ; pop ; pop = next)
-	{
-		next = next->caller;
-		free (pop);
-	}
-
-	free (context);
-
-	return CF_OK;
-}
-
-int
-CF_Debug_SetOutputFD (CF_Debug_Ctx	ctx,
-					  int			fd)
-{
-	int result = 0;
-	int dupfd = 0;
-
-	CF_DEBUG_CTX	* context = (CF_DEBUG_CTX *) ctx;
-	FILE			* fp = NULL;
-
-	CHECK_INVALID_CTX (ctx);
-
-	TRY
-	{
-		dupfd = dup (fd);
-		if (dupfd < 0)
-		{
-			result = -1;
-			TRY_BREAK;
-		}
-
-		fp = fdopen (dupfd, "a+");
-		if (fp == NULL)
-		{
-			close (dupfd);
-			result = -2;
-			TRY_BREAK;
-		}
-
-		context->fp = fp;
-	}
-	CATCH_IF (result < 0)
-	{
-		return CF_ERROR_DEBUG_SET_OUTPUT_FD;
-	}
-
-	return CF_OK;
-}
-
-int
-CF_Debug_UpdateCtx (CF_Debug_Ctx	ctx,
-					const char		* file,
-					const char		* func,
-					const int		line)
-{
-	CF_DEBUG_CTX * context = (CF_DEBUG_CTX *) ctx;
-
-	CHECK_INVALID_CTX (ctx);
-
-	strncpy (context->file, file, strlen (file));
-	strncpy (context->func, func, strlen (func));
-	context->line = line;
-
-	return CF_OK;
-}
-
-int
-CF_Debug_Trace (CF_Debug_Ctx	ctx,
-				const char		* fmt, ...)
-{
-	va_list			valist;
-
-	CHECK_INVALID_CTX (ctx);
-
-	va_start (valist, fmt);
-	CF_Debug_Local_Print ((CF_DEBUG_CTX *) ctx, fmt, valist);
-	va_end (valist);
-
-	return CF_OK;
-}
-
-int
-CF_Debug_TraceBin (CF_Debug_Ctx			ctx,
-				   const unsigned char	* bin,
-				   const int			len,
-				   const char			* fmt, ...)
-{
-	int		i, j;
-	va_list	valist;
-	FILE	* fp = NULL;
-
-	CHECK_INVALID_CTX (ctx);
-	fp = GET_CTX_OSTREAM (ctx); 
-
-	va_start (valist, fmt);
-	CF_Debug_Local_Print ((CF_DEBUG_CTX *) ctx, fmt, valist);
+	fprintf (fp, "[DEBUG][%s:%d][%s] ", file, line, func);
+	vfprintf (fp, fmt, valist);
+
+	return CF_OK;
+}
+
+int
+CF_Debug_Local_PrintBin (FILE					* fp,
+						 const char				* file,
+						 const char				* func,
+						 const int				line,
+						 const unsigned char	* bin,
+						 const int				len)
+{
+	int i, j;
 
 	for (i = 0 ; i < len ; i += 16)
 	{
-		fprintf (fp, "[DEBUG][%s %s(%d)] ", __FILE__, __func__, __LINE__);
+		fprintf (fp, "[DEBUG][%s:%d][%s] ", file, line, func);
 		fprintf (fp, "%06x : ", i);
 
@@ -208,4 +97,178 @@
 }
 
+CF_Debug_Ctx
+CF_Debug_CreateCtx (void)
+{
+	CF_DEBUG_CTX * ctx = NULL;
+
+	ctx = (CF_DEBUG_CTX *) calloc (sizeof (CF_DEBUG_CTX), 1);
+
+	return (CF_Debug_Ctx) ctx;
+}
+
+int
+CF_Debug_DestroyCtx (CF_Debug_Ctx ctx)
+{
+	CF_DEBUG_CTX		* context = (CF_DEBUG_CTX *) ctx;
+	CF_DEBUG_CALLSTACK	* pop = NULL;
+	CF_DEBUG_CALLSTACK	* next = NULL;
+
+	CHECK_INVALID_CTX (ctx);
+
+	if (context->fp != NULL)
+		fclose (context->fp);
+
+	for (pop = next = context->callstack.caller ; pop ; pop = next)
+	{
+		next = next->caller;
+		free (pop);
+	}
+
+	free (context);
+
+	return CF_OK;
+}
+
+int
+CF_Debug_SetOutputFD (CF_Debug_Ctx	ctx,
+					  int			fd)
+{
+	int result = 0;
+	int dupfd = 0;
+
+	CF_DEBUG_CTX	* context = (CF_DEBUG_CTX *) ctx;
+	FILE			* fp = NULL;
+
+	CHECK_INVALID_CTX (ctx);
+
+	TRY
+	{
+		dupfd = dup (fd);
+		if (dupfd < 0)
+		{
+			result = -1;
+			TRY_BREAK;
+		}
+
+		fp = fdopen (dupfd, "a+");
+		if (fp == NULL)
+		{
+			close (dupfd);
+			result = -2;
+			TRY_BREAK;
+		}
+
+		context->fp = fp;
+	}
+	CATCH_IF (result < 0)
+	{
+		return CF_ERROR_DEBUG_SET_OUTPUT_FD;
+	}
+
+	return CF_OK;
+}
+
+int
+CF_Debug_Print (FILE		* fp,
+				const char	* file,
+				const char	* func,
+				const int	line,
+				const char	* fmt, ...)
+{
+	va_list valist;
+
+	va_start (valist, fmt);
+	CF_Debug_Local_Print (fp, file, func, line, fmt, valist);
+	va_end (valist);
+
+	return CF_OK;
+}
+
+int
+CF_Debug_PrintBin (FILE					* fp,
+				   const char			* file,
+				   const char			* func,
+				   const int			line,
+				   const unsigned char	* bin,
+				   const int			len,
+				   const char			* fmt, ...)
+{
+	va_list valist;
+
+	va_start (valist, fmt);
+	CF_Debug_Local_Print (fp, file, func, line, fmt, valist);
+	va_end (valist);
+
+	CF_Debug_Local_PrintBin (fp, file, func, line, bin, len);
+
+	return CF_OK;
+}
+
+int
+CF_Debug_UpdateCtx (CF_Debug_Ctx	ctx,
+					const char		* file,
+					const char		* func,
+					const int		line)
+{
+	CF_DEBUG_CTX * context = (CF_DEBUG_CTX *) ctx;
+
+	CHECK_INVALID_CTX (ctx);
+
+	strncpy (context->file, file, strlen (file));
+	strncpy (context->func, func, strlen (func));
+	context->line = line;
+
+	return CF_OK;
+}
+
+int
+CF_Debug_Trace (CF_Debug_Ctx	ctx,
+				const char		* fmt, ...)
+{
+	va_list			valist;
+	CF_DEBUG_CTX	* context = (CF_DEBUG_CTX *) ctx;
+
+	CHECK_INVALID_CTX (ctx);
+
+	va_start (valist, fmt);
+	CF_Debug_Local_Print (GET_CTX_OSTREAM (context),
+						  context->file,
+						  context->func,
+						  context->line,
+						  fmt, valist);
+	va_end (valist);
+
+	return CF_OK;
+}
+
+int
+CF_Debug_TraceBin (CF_Debug_Ctx			ctx,
+				   const unsigned char	* bin,
+				   const int			len,
+				   const char			* fmt, ...)
+{
+	va_list			valist;
+	FILE			* fp = NULL;
+	CF_DEBUG_CTX	* context = (CF_DEBUG_CTX *) ctx;
+ 
+	CHECK_INVALID_CTX (ctx);
+
+	va_start (valist, fmt);
+	CF_Debug_Local_Print (GET_CTX_OSTREAM (context),
+						  context->file,
+						  context->func,
+						  context->line,
+						  fmt, valist);
+	va_end (valist);
+
+	CF_Debug_Local_PrintBin (context->fp,
+							 context->file,
+							 context->func,
+							 context->line,
+							 bin, len);
+
+	return CF_OK;
+}
+
 int
 CF_Debug_CallStackPush (CF_Debug_Ctx	ctx,
Index: /trunk/src/cf_file.c
===================================================================
--- /trunk/src/cf_file.c	(revision 15)
+++ /trunk/src/cf_file.c	(revision 16)
@@ -25,6 +25,6 @@
 
 int
-CF_File_Open (const char	* path,
-			  const int		flag)
+CF_File_Open (const char			* path,
+			  const CF_FILE_FLAG	flag)
 {
 	int result = open (path, flag);
@@ -39,5 +39,5 @@
 CF_File_Create (const char * path)
 {
-	int result = open (path, CR|WO|TR, FILE_MODE);
+	int result = open (path, CF_FILE_CR|CF_FILE_WO|CF_FILE_TR, FILE_MODE);
 
 	if (result < 0)
Index: /trunk/test/test.c
===================================================================
--- /trunk/test/test.c	(revision 15)
+++ /trunk/test/test.c	(revision 16)
@@ -25,5 +25,5 @@
 	gLogCtx = CF_Log_CreateCtx (file, CF_LOG_BUFFER_DEFAULT);
 	if (gDebugCtx == NULL)
-		CF_DEBUG_TRACE (gDebugCtx, "create debug ctx error\n");
+		CF_DEBUG_PRINT (stderr, "create debug ctx error\n");
 
 	for (i = 0 ; i < 10000 ; i++)
@@ -49,5 +49,5 @@
 	CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
 
-	fd = CF_File_Open (file, RO);
+	fd = CF_File_Open (file, CF_FILE_RO);
 	if (fd < 0)
 		CF_DEBUG_TRACE (gDebugCtx, "what the ... file open ?\n");
@@ -101,20 +101,20 @@
 
 	if (gLogCtx == NULL)
-		CF_DEBUG_TRACE (gDebugCtx, "create log ctx error\n");
+		CF_DEBUG_PRINT (stderr, "create log ctx error\n");
 
 	CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
 
-	CF_DEBUG_TRACE (gDebugCtx, " == LOG TEST ==\n");
+	CF_DEBUG_PRINT (stderr, " == LOG TEST ==\n");
 	log_test ("LOG_TEST");
 
-	CF_DEBUG_TRACE (gDebugCtx, " == FILE READ TEST ==\n");
+	CF_DEBUG_PRINT (stderr, " == FILE READ TEST ==\n");
 	file_test ("FILE_READ_TEST");
 
-	CF_DEBUG_TRACE (gDebugCtx, " == CALLSTACK TEST ==\n");
+	CF_DEBUG_PRINT (stderr, " == CALLSTACK TEST ==\n");
 	callee1 ();
 
 	CF_DEBUG_CALLSTACK_POP (gDebugCtx, &gDebugCallstack);
 
-	CF_DEBUG_TRACE (gDebugCtx, " == END OF TEST ==\n");
+	CF_DEBUG_PRINT (stderr, " == END OF TEST ==\n");
 	CF_DEBUG_TRACE (gDebugCtx, "here is the end of function [file:%s line:%d func:%s]\n",
 								gDebugCallstack.file,
