Last change
on this file since 11 was 11, checked in by cheese, 11 years ago |
#1 add logging module (working), fix some bug code and move NAME_LENGTH definition
|
File size:
857 bytes
|
Rev | Line | |
---|
[11] | 1 | /*
|
---|
| 2 | * cf_log.c
|
---|
| 3 | */
|
---|
| 4 | #include "cf_log.h"
|
---|
| 5 | #include "cf_thread.h"
|
---|
| 6 |
|
---|
| 7 | #include <string.h>
|
---|
| 8 |
|
---|
| 9 | #ifdef _WIN32
|
---|
| 10 | #else // #ifdef _WIN32
|
---|
| 11 | # include <sys/stat.h>
|
---|
| 12 | #endif // #ifdef _WIN32
|
---|
| 13 |
|
---|
| 14 | typedef struct __cf_log_ctx__ {
|
---|
| 15 | char path[NAME_LENGTH + 1];
|
---|
| 16 | int fd;
|
---|
| 17 | char * buffer;
|
---|
| 18 | int entireLength;
|
---|
| 19 | int bufferLength;
|
---|
| 20 | CF_Mutex mutex;
|
---|
| 21 | } S_CF_LOG_CTX, CF_LOG_CTX;
|
---|
| 22 |
|
---|
| 23 | typedef struct __cf_log_environment__ {
|
---|
| 24 | __blksize_t fsBlockSize;
|
---|
| 25 | } S_CF_Log_Environment, CF_Log_Environment;
|
---|
| 26 |
|
---|
| 27 | CF_Log_Environment gLogEnvironment;
|
---|
| 28 |
|
---|
| 29 | int
|
---|
| 30 | CF_Log_Initialize (void)
|
---|
| 31 | {
|
---|
| 32 | struct stat fsstat;
|
---|
| 33 |
|
---|
| 34 | memset (&gLogEnvironment, 0x00, sizeof (CF_Log_Environment));
|
---|
| 35 |
|
---|
| 36 | if (stat ("./", &fsstat) < 0)
|
---|
| 37 | return CF_ERROR_LOG_INITIALIZE;
|
---|
| 38 |
|
---|
| 39 | gLogEnvironment.fsBlockSize = fsstat.st_blksize;
|
---|
| 40 |
|
---|
| 41 | return CF_OK;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | int
|
---|
| 45 | CF_Log_Finalize (void)
|
---|
| 46 | {
|
---|
| 47 | memset (&gLogEnvironment, 0x00, sizeof (CF_Log_Environment));
|
---|
| 48 |
|
---|
| 49 | return CF_OK;
|
---|
| 50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.