Changeset 19 in libcf for trunk/src/cf_log.c
- Timestamp:
- 02/01/13 12:48:28 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cf_log.c
r14 r19 201 201 CF_Log_Finalize (void) 202 202 { 203 int mapid = 0; 204 205 for (mapid = 0 ; mapid < gLogEnvironment.ctxSize ; mapid++) 206 { 207 CF_Log_UnmapCtxID (mapid); 208 } 209 210 if (gLogEnvironment.ctxPool != NULL) 211 free (gLogEnvironment.ctxPool); 212 203 213 memset (&gLogEnvironment, 0x00, sizeof (CF_LOG_ENVIRONMENT)); 204 214 … … 257 267 258 268 int 259 CF_Log_SetMultiThread (CF_Log_Ctx ctx)260 {261 CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;262 263 CHECK_INVALID_CTX (ctx);264 265 if (CF_Mutex_Create (&context->mutex) < 0)266 return CF_ERROR_LOG_SET_MULTITHREAD;267 268 return CF_OK;269 }270 271 int272 CF_Log_UnsetMultiThread (CF_Log_Ctx ctx)273 {274 CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;275 276 CHECK_INVALID_CTX (ctx);277 278 if (CF_Mutex_Destory (&context->mutex) < 0)279 return CF_ERROR_LOG_UNSET_MULTITHREAD;280 281 return CF_OK;282 }283 284 int285 269 CF_Log_DestroyCtx (CF_Log_Ctx ctx) 286 270 { … … 313 297 314 298 int 299 CF_Log_SetMultiThread (CF_Log_Ctx ctx) 300 { 301 CF_LOG_CTX * context = (CF_LOG_CTX *) ctx; 302 303 CHECK_INVALID_CTX (ctx); 304 305 if (CF_Mutex_Create (&context->mutex) < 0) 306 return CF_ERROR_LOG_SET_MULTITHREAD; 307 308 return CF_OK; 309 } 310 311 int 312 CF_Log_UnsetMultiThread (CF_Log_Ctx ctx) 313 { 314 CF_LOG_CTX * context = (CF_LOG_CTX *) ctx; 315 316 CHECK_INVALID_CTX (ctx); 317 318 if (CF_Mutex_Destory (&context->mutex) < 0) 319 return CF_ERROR_LOG_UNSET_MULTITHREAD; 320 321 return CF_OK; 322 } 323 324 int 315 325 CF_Log_Write (CF_Log_Ctx ctx, 316 326 const char * prefix, … … 373 383 return CF_OK; 374 384 } 385 386 int 387 CF_Log_MapCtxID (const int mapid, 388 const CF_Log_Ctx ctx) 389 { 390 if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0) 391 return CF_ERROR_LOG_NOT_INITIALIZE; 392 393 if (gLogEnvironment.ctxPool[mapid] != NULL) 394 return CF_ERROR_LOG_ALREADY_MAPPED_ID; 395 396 gLogEnvironment.ctxPool[mapid] = ctx; 397 398 return CF_OK; 399 } 400 401 int 402 CF_Log_UnmapCtxID (const int mapid) 403 { 404 if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0) 405 return CF_ERROR_LOG_NOT_INITIALIZE; 406 407 if (gLogEnvironment.ctxPool[mapid] == NULL) 408 return CF_ERROR_LOG_NOT_MAPPED_ID; 409 410 CF_Log_DestroyCtx (gLogEnvironment.ctxPool[mapid]); 411 412 free (gLogEnvironment.ctxPool[mapid]); 413 gLogEnvironment.ctxPool[mapid] = NULL; 414 415 return CF_OK; 416 } 417 418 CF_Log_Ctx 419 CF_Log_GetMappedCtx (const int mapid) 420 { 421 if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0) 422 return NULL; 423 424 return gLogEnvironment.ctxPool[mapid]; 425 }
Note:
See TracChangeset
for help on using the changeset viewer.