[Freeswitch-svn] [commit] r5188 - freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file
Freeswitch SVN
anthonyl at freeswitch.org
Tue May 15 23:44:25 EDT 2007
Author: anthonyl
Date: Tue May 15 23:44:25 2007
New Revision: 5188
Modified:
freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c
Log:
yay! more apr fileio logic
Modified: freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c (original)
+++ freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c Tue May 15 23:44:25 2007
@@ -194,14 +194,15 @@
unsigned int i;
unsigned char *p;
unsigned char *q;
-
+ apr_status_t stat;
+ apr_file_t *l_afd;
+
globals.log_size = 0;
-
- ret = fseek(globals.log_fd, 0, SEEK_SET);
+ stat = apr_file_seek(globals.log_afd, APR_SET, 0);
- if (ret < 0) {
+ if (stat != APR_SUCCESS)
return SWITCH_STATUS_FALSE;
- }
+
p = malloc(strlen(globals.logfile)+WARM_FUZZY_OFFSET);
if (!p) {
return SWITCH_STATUS_FALSE;
@@ -214,14 +215,14 @@
memset(p, '\0', strlen(globals.logfile)+WARM_FUZZY_OFFSET);
for (i=1;i<MAX_ROT; i++) {
sprintf(p, "%s.%i", globals.logfile, i);
- fd = fopen(p, "r");
- if (fd != NULL) {
- fclose(fd);
+ stat = apr_file_open(l_afd, p, APR_READ, NULL, NULL);
+ if (stat == APR_SUCCESS) {
+ apr_file_close(l_afd);
continue;
}
- if(fd = fopen(p, "w"))
+ stat = apr_file_open(l_afd, p, APR_READ | APR_WRITE | APR_CREATE , NULL, NULL);
+ if (stat == APR_SUCCESS)
break;
-
}
while( ret = fread(q, 1024, 1, globals.log_fd)) {
fwrite(q, 1024, 1, fd);
More information about the Freeswitch-svn
mailing list