Changeset 14 in libcf
- Timestamp:
- 01/31/13 22:55:37 (11 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_debug.h
r10 r14 17 17 18 18 #ifdef _DEBUG 19 # define CF_UPDATE_CTX(__ctx) \ 20 CF_Debug_UpdateCtx (__ctx,__FILE__,__func__,__LINE__) 19 21 # define CF_DEBUG_TRACE(__ctx,__fmt,...) \ 20 CF_Debug_Trace (__ctx,__fmt,##__VA_ARGS__) 22 do { \ 23 CF_UPDATE_CTX (__ctx); \ 24 CF_Debug_Trace (__ctx,__fmt,##__VA_ARGS__); \ 25 } while (0) 21 26 # define CF_DEBUG_TRACE_BIN(__ctx,__bin,__len,__fmt,...) \ 22 CF_Debug_Trace (__ctx,__bin,__len,__fmt,##__VA_ARGS__) 27 do { \ 28 CF_UPDATE_CTX (__ctx); \ 29 CF_Debug_Trace (__ctx,__bin,__len,__fmt,##__VA_ARGS__); \ 30 } while (0) 23 31 # define CF_DEBUG_CALLSTACK_PUSH(__ctx) \ 24 CF_Debug_Call stackPush (__ctx,__FILE__,__func__,__LINE__)32 CF_Debug_CallStackPush (__ctx,__FILE__,__func__,__LINE__) 25 33 # define CF_DEBUG_CALLSTACK_POP \ 26 CF_Debug_Call stackPop34 CF_Debug_CallStackPop 27 35 #else // #ifdef _DEBUG 36 # define CF_UPDATE_CTX(__ctx) 28 37 # define CF_DEBUG_TRACE(__ctx,__fmt,...) 29 38 # define CF_DEBUG_TRACE_BIN(__ctx,__bin,__len,__fmt,...) … … 34 43 typedef void * CF_Debug_Ctx; 35 44 typedef struct cf_debug_callStack { 45 char file[NAME_LENGTH + 1]; 36 46 char function[NAME_LENGTH + 1]; 37 47 int line; … … 51 61 CF_Debug_SetOutputFD (CF_Debug_Ctx ctx, 52 62 int fd); 63 64 CF_EXPORT int 65 CF_Debug_UpdateCtx (CF_Debug_Ctx ctx, 66 const char * file, 67 const char * func, 68 const int line); 53 69 54 70 CF_EXPORT int -
trunk/src/cf_debug.c
r12 r14 49 49 } S_CF_DEBUG_CTX, CF_DEBUG_CTX; 50 50 51 void 51 int 52 52 CF_Debug_Local_Print (CF_DEBUG_CTX * ctx, 53 53 const char * fmt, 54 54 va_list valist) 55 55 { 56 fprintf (GET_CTX_OSTREAM (ctx), "[DEBUG][%s %s(%d)] ",56 fprintf (GET_CTX_OSTREAM (ctx), "[DEBUG][%s:%d][%s] ", 57 57 ctx->file, 58 ctx-> func,59 ctx-> line);58 ctx->line, 59 ctx->func); 60 60 vfprintf (GET_CTX_OSTREAM (ctx), fmt, valist); 61 62 return CF_OK; 61 63 } 62 64 … … 129 131 return CF_ERROR_DEBUG_SET_OUTPUT_FD; 130 132 } 133 134 return CF_OK; 135 } 136 137 int 138 CF_Debug_UpdateCtx (CF_Debug_Ctx ctx, 139 const char * file, 140 const char * func, 141 const int line) 142 { 143 CF_DEBUG_CTX * context = (CF_DEBUG_CTX *) ctx; 144 145 CHECK_INVALID_CTX (ctx); 146 147 strncpy (context->file, file, strlen (file)); 148 strncpy (context->func, func, strlen (func)); 149 context->line = line; 131 150 132 151 return CF_OK; … … 154 173 const char * fmt, ...) 155 174 { 156 int i, j; 157 va_list valist; 158 FILE * fp = GET_CTX_OSTREAM (ctx); 159 160 CHECK_INVALID_CTX (ctx); 175 int i, j; 176 va_list valist; 177 FILE * fp = NULL; 178 179 CHECK_INVALID_CTX (ctx); 180 fp = GET_CTX_OSTREAM (ctx); 161 181 162 182 va_start (valist, fmt); … … 210 230 context->callstack.caller = push; 211 231 212 /* set current context */ 213 sprintf (context->file, "%s", file); 214 sprintf (context->func, "%s", func); 215 context->line = line; 232 CF_Debug_UpdateCtx (ctx, file, func, line); 216 233 217 234 return CF_OK; … … 233 250 if (callstack != NULL) 234 251 { 252 sprintf (callstack->file , "%s", pop->file); 235 253 sprintf (callstack->function, "%s", pop->func); 236 254 callstack->line = pop->line; … … 244 262 if (pop->caller != NULL) 245 263 { 246 sprintf (context->file, "%s", pop->caller->file); 247 sprintf (context->func, "%s", pop->caller->func); 248 context->line = pop->caller->line; 249 context->callstack.caller = pop->caller; 250 } 251 264 CF_Debug_UpdateCtx (ctx, 265 pop->caller->file, 266 pop->caller->func, 267 pop->caller->line); 268 } 269 270 context->callstack.caller = pop->caller; 252 271 free (pop); 253 272 -
trunk/src/cf_file.c
r5 r14 5 5 6 6 #ifdef _WIN32 7 # include <stdio.h> 7 8 # include <io.h> 8 # include <stdio.h> 9 # include <sys/stat.h> 10 11 # define S_IWUSR _S_IWRITE 12 # define S_IRUSR _S_IREAD 13 # define S_IXUSR _S_IEXEC 14 # define S_IRGRP 0x00000000 15 # define S_IWGRP 0x00000000 16 # define S_IXGRP 0x00000000 17 # define S_IROTH 0x00000000 18 # define S_IWOTH 0x00000000 19 # define S_IXOTH 0x00000000 9 20 #else // #ifdef _WIN32 10 21 # include <unistd.h> … … 26 37 CF_File_Create (const char * path) 27 38 { 28 int result = open (path, O_CREAT | O_WRONLY | O_TRUNC, 0);39 int result = open (path, O_CREAT | O_WRONLY | O_TRUNC, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); 29 40 30 41 if (result < 0) -
trunk/src/cf_log.c
r13 r14 2 2 * cf_log.c 3 3 */ 4 #ifdef _WIN32 5 # define _USE_32BIT_TIME_T 6 #endif 7 4 8 #include "cf_log.h" 5 9 #include "cf_file.h" … … 14 18 15 19 #ifdef _WIN32 20 # define snprintf _snprintf 16 21 # include <Windows.h> 17 22 #else // #ifdef _WIN32 … … 24 29 25 30 #define LOCK_LOG_CTX(__ctx) \ 26 if (CF_Mutex_Lock (&__ctx->mutex) < 0) \ 27 return CF_ERROR_LOG_LOCK_CTX 31 CF_Mutex_Lock (&__ctx->mutex) 28 32 29 33 #define UNLOCK_LOG_CTX(__ctx) \ 30 if (CF_Mutex_Unlock (&__ctx->mutex) < 0) \ 31 return CF_ERROR_LOG_UNLOCK_CTX 34 CF_Mutex_Unlock (&__ctx->mutex) 32 35 33 36 #define CF_LOG_BUFFER_DEFAULT_SIZE 128 * 1024 … … 146 149 CF_Log_Local_GetTime (&dt); 147 150 148 sprintf (buffer, "%02d-%02d-%02d %02d:%02d:%02d.%03d", 149 dt.year, dt.month, dt.day, 150 dt.hour, dt.min, dt.sec, dt.usec); 151 152 153 snprintf (buffer, strlen ("0000-00-00 00:00:00.000"), 154 "%02d-%02d-%02d %02d:%02d:%02d.%03d", 155 dt.year, dt.month, dt.day, 156 dt.hour, dt.min, dt.sec, dt.usec); 151 157 152 158 return CF_OK; … … 287 293 if (context->buffer != NULL) 288 294 { 289 /* FIXME : write residual data in buffer */ 290 295 CF_Log_Flush (ctx); 291 296 free (context->buffer); 292 297 context->buffer = NULL; -
trunk/src/makefile
r10 r14 43 43 cf_log \ 44 44 45 LIB_NAME = cf45 TARGET_NAME = cf 46 46 47 47 CC = gcc … … 57 57 TARGET_PATH = ../_build 58 58 OBJ_PATH = ../_obj 59 TARGET = $(TARGET_PATH)/lib$( LIB_NAME).$(EXT_SHARED)59 TARGET = $(TARGET_PATH)/lib$(TARGET_NAME).$(EXT_SHARED) 60 60 SRCS = $(addsuffix .$(SOURCE_TYPE),$(FILES)) 61 61 OBJS = $(addprefix $(OBJ_PATH)/,$(addsuffix .o,$(FILES))) -
trunk/windows/libcf.sln
r13 r14 2 2 Microsoft Visual Studio Solution File, Format Version 10.00 3 3 # Visual Studio 2008 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcf", "libcf/libcf.vcproj", "{E5FB2D95-3841-464C-B23F-94ADA4499FE6}" 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCF", "libcf\libcf.vcproj", "{E5FB2D95-3841-464C-B23F-94ADA4499FE6}" 5 EndProject 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{D344FA91-7B7A-4390-9CA5-E1ABCCECA3A2}" 7 ProjectSection(ProjectDependencies) = postProject 8 {E5FB2D95-3841-464C-B23F-94ADA4499FE6} = {E5FB2D95-3841-464C-B23F-94ADA4499FE6} 9 EndProjectSection 5 10 EndProject 6 11 Global … … 14 19 {E5FB2D95-3841-464C-B23F-94ADA4499FE6}.Release|Win32.ActiveCfg = Release|Win32 15 20 {E5FB2D95-3841-464C-B23F-94ADA4499FE6}.Release|Win32.Build.0 = Release|Win32 21 {D344FA91-7B7A-4390-9CA5-E1ABCCECA3A2}.Debug|Win32.ActiveCfg = Debug|Win32 22 {D344FA91-7B7A-4390-9CA5-E1ABCCECA3A2}.Debug|Win32.Build.0 = Debug|Win32 23 {D344FA91-7B7A-4390-9CA5-E1ABCCECA3A2}.Release|Win32.ActiveCfg = Release|Win32 24 {D344FA91-7B7A-4390-9CA5-E1ABCCECA3A2}.Release|Win32.Build.0 = Release|Win32 16 25 EndGlobalSection 17 26 GlobalSection(SolutionProperties) = preSolution -
trunk/windows/libcf/libcf.vcproj
r13 r14 22 22 IntermediateDirectory="$(ConfigurationName)" 23 23 ConfigurationType="2" 24 CharacterSet=" 1"24 CharacterSet="0" 25 25 > 26 26 <Tool … … 95 95 IntermediateDirectory="$(ConfigurationName)" 96 96 ConfigurationType="2" 97 CharacterSet=" 1"97 CharacterSet="0" 98 98 WholeProgramOptimization="1" 99 99 >
Note:
See TracChangeset
for help on using the changeset viewer.