diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-16 08:56:05 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-16 08:56:05 +0000 |
commit | 28a583f0d7871acf7d44a71fc8fb4c7590745731 (patch) | |
tree | 1227b7cb561d9a1399850af4887fb2381bc32d8b | |
parent | b75ebdeff0df04c54aad88ff4f016758e6a7972d (diff) |
Ticket #184: Added pj_file_flush() to file I/O API to flush file buffers
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/pjproject-0.5-stable@1073 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjlib/include/pj/file_io.h | 10 | ||||
-rw-r--r-- | pjlib/src/pj/config.c | 2 | ||||
-rw-r--r-- | pjlib/src/pj/file_io_ansi.c | 10 | ||||
-rw-r--r-- | pjlib/src/pj/file_io_win32.c | 14 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 1 |
5 files changed, 36 insertions, 1 deletions
diff --git a/pjlib/include/pj/file_io.h b/pjlib/include/pj/file_io.h index c5d9ac6c..0442103c 100644 --- a/pjlib/include/pj/file_io.h +++ b/pjlib/include/pj/file_io.h @@ -163,6 +163,16 @@ PJ_DECL(pj_status_t) pj_file_setpos(pj_oshandle_t fd, PJ_DECL(pj_status_t) pj_file_getpos(pj_oshandle_t fd, pj_off_t *pos); +/** + * Flush file buffers. + * + * @param fd The file descriptor. + * + * @return PJ_SUCCESS or the appropriate error code on error. + */ +PJ_DECL(pj_status_t) pj_file_flush(pj_oshandle_t fd); + + /** @} */ diff --git a/pjlib/src/pj/config.c b/pjlib/src/pj/config.c index 40a105f5..4f69b8a5 100644 --- a/pjlib/src/pj/config.c +++ b/pjlib/src/pj/config.c @@ -21,7 +21,7 @@ #include <pj/ioqueue.h> static const char *id = "config.c"; -const char *PJ_VERSION = "0.5.10.2-release"; +const char *PJ_VERSION = "0.5.10.3-pre"; PJ_DEF(void) pj_dump_config(void) { diff --git a/pjlib/src/pj/file_io_ansi.c b/pjlib/src/pj/file_io_ansi.c index a2425818..6d340ce1 100644 --- a/pjlib/src/pj/file_io_ansi.c +++ b/pjlib/src/pj/file_io_ansi.c @@ -154,4 +154,14 @@ PJ_DEF(pj_status_t) pj_file_getpos( pj_oshandle_t fd, return PJ_SUCCESS; } +PJ_DEF(pj_status_t) pj_file_flush(pj_oshandle_t fd) +{ + int rc; + + rc = fflush((FILE*)fd); + if (rc == EOF) { + return PJ_RETURN_OS_ERROR(errno); + } + return PJ_SUCCESS; +} diff --git a/pjlib/src/pj/file_io_win32.c b/pjlib/src/pj/file_io_win32.c index 2497be68..27848497 100644 --- a/pjlib/src/pj/file_io_win32.c +++ b/pjlib/src/pj/file_io_win32.c @@ -204,3 +204,17 @@ PJ_DEF(pj_status_t) pj_file_getpos( pj_oshandle_t fd, return PJ_SUCCESS; } +PJ_DEF(pj_status_t) pj_file_flush(pj_oshandle_t fd) +{ + BOOL rc; + + rc = FlushFileBuffers(fd); + + if (!rc) { + DWORD dwStatus = GetLastError(); + if (dwStatus != 0) + return PJ_RETURN_OS_ERROR(dwStatus); + } + + return PJ_SUCCESS; +} diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 8a681427..4da868bc 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -290,6 +290,7 @@ static void log_writer(int level, const char *buffer, int len) if (pjsua_var.log_file) { pj_ssize_t size = len; pj_file_write(pjsua_var.log_file, buffer, &size); + pj_file_flush(pjsua_var.log_file); } if (level <= (int)pjsua_var.log_cfg.console_level) { |