From 1c0e86596edb9d9a5f4d7ec1f40e413ddbe99668 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 16 Aug 2013 21:33:41 +0000 Subject: [PATCH] Split Windows/POSIX implementations of ncat_openlog. O_BINARY doesn't exist on POSIX. --- ncat/ncat_core.c | 10 ---------- ncat/ncat_posix.c | 8 ++++++++ ncat/ncat_win.c | 8 ++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ncat/ncat_core.c b/ncat/ncat_core.c index 8332c5b7c..006386f36 100644 --- a/ncat/ncat_core.c +++ b/ncat/ncat_core.c @@ -454,16 +454,6 @@ int ncat_delay_timer(int delayval) return 1; } -/* Open a logfile for writing. - * Return the open file descriptor. */ -int ncat_openlog(const char *logfile, int append) -{ - if (append) - return Open(logfile, O_BINARY | O_WRONLY | O_CREAT | O_APPEND, 0664); - else - return Open(logfile, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0664); -} - static int ncat_hexdump(int logfd, const char *data, int len); void ncat_log_send(const char *data, size_t len) diff --git a/ncat/ncat_posix.c b/ncat/ncat_posix.c index c83e4c9cf..9946b20b6 100644 --- a/ncat/ncat_posix.c +++ b/ncat/ncat_posix.c @@ -391,6 +391,14 @@ char **cmdline_split(const char *cmdexec) return cmd_args; } +int ncat_openlog(const char *logfile, int append) +{ + if (append) + return Open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0664); + else + return Open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0664); +} + void set_lf_mode(void) { /* Nothing needed. */ diff --git a/ncat/ncat_win.c b/ncat/ncat_win.c index 7e6186ebf..d7ecce3a5 100644 --- a/ncat/ncat_win.c +++ b/ncat/ncat_win.c @@ -124,6 +124,14 @@ #include "nbase.h" #include "ncat.h" +int ncat_openlog(const char *logfile, int append) +{ + if (append) + return Open(logfile, O_BINARY | O_WRONLY | O_CREAT | O_APPEND, 0664); + else + return Open(logfile, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0664); +} + void set_lf_mode(void) { /* _O_TEXT (the default setting) converts \r\n to \n on input, making the