introduce ngx_write_console() to support OEM code pages

This commit is contained in:
Igor Sysoev 2009-04-28 15:05:27 +00:00
parent bffd3196cf
commit 9d4a8d9111
4 changed files with 24 additions and 2 deletions

View File

@ -152,7 +152,7 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
(void) ngx_sprintf(msg, "[%V]: ", &err_levels[level]);
(void) ngx_write_fd(ngx_stderr, msg, p - msg);
(void) ngx_write_console(ngx_stderr, msg, p - msg);
}
@ -224,7 +224,7 @@ ngx_log_stderr(ngx_err_t err, const char *fmt, ...)
ngx_linefeed(p);
(void) ngx_write_fd(ngx_stderr, errstr, p - errstr);
(void) ngx_write_console(ngx_stderr, errstr, p - errstr);
}

View File

@ -113,6 +113,10 @@ ngx_write_fd(ngx_fd_t fd, void *buf, size_t n)
#define ngx_write_fd_n "write()"
#define ngx_write_console ngx_write_fd
#define ngx_linefeed(p) *p++ = LF;
#define NGX_LINEFEED_SIZE 1

View File

@ -232,6 +232,21 @@ ngx_write_fd(ngx_fd_t fd, void *buf, size_t size)
}
ssize_t
ngx_write_console(ngx_fd_t fd, void *buf, size_t size)
{
u_long n;
(void) CharToOemBuff(buf, buf, size);
if (WriteFile(fd, buf, size, &n, NULL) != 0) {
return (size_t) n;
}
return -1;
}
ngx_int_t
ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_log_t *log)
{

View File

@ -98,6 +98,9 @@ ssize_t ngx_write_fd(ngx_fd_t fd, void *buf, size_t size);
#define ngx_write_fd_n "WriteFile()"
ssize_t ngx_write_console(ngx_fd_t fd, void *buf, size_t size);
#define ngx_linefeed(p) *p++ = CR; *p++ = LF;
#define NGX_LINEFEED_SIZE 2