Use text mode file io, don't mess with the constants.

On Mon, Dec 13, 2010 at 11:56 AM, David Sommerseth
<d...@users.sourceforge.net> wrote:
> The newline style is different from most Unices and Windows, where
> Windows uses \r\n instead of just \n.
>
> Reported-by: Thomas Reifferscheid
> Signed-off-by: David Sommerseth <d...@users.sourceforge.net>
> ---
>  config-win32.h |    3 +++
>  error.c        |   12 ++++++++----
>  2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/config-win32.h b/config-win32.h
> index be0b320..56c40cd 100644
> --- a/config-win32.h
> +++ b/config-win32.h
> @@ -275,6 +275,9 @@ typedef unsigned long in_addr_t;
>  #error The Windows version of OpenVPN does not support PTHREAD yet
>  #endif
>
> +/* Windows uses a different NL style than *nix for logging */
> +#define NEWLINE "\r\n"
> +
>  #ifdef _MSC_VER
>  /* MSVC++ hacks */
>  #pragma warning(disable:4244) // conversion from 'foo' to 'bar', possible 
> loss of data
> diff --git a/error.c b/error.c
> index 873718c..40c8107 100644
> --- a/error.c
> +++ b/error.c
> @@ -49,6 +49,10 @@
>  #endif
>  #endif
>
> +#ifndef NEWLINE
> +#define NEWLINE "\n"
> +#endif
> +
>  /* Globals */
>  unsigned int x_debug_level; /* GLOBAL */
>
> @@ -326,7 +330,7 @@ void x_msg (const unsigned int flags, const char *format, 
> ...)
>                       prefix,
>                       prefix_sep,
>                       m1,
> -                      (flags&M_NOLF) ? "" : "\n");
> +                      (flags&M_NOLF) ? "" : NEWLINE);
>            }
>          else
>            {
> @@ -337,14 +341,14 @@ void x_msg (const unsigned int flags, const char 
> *format, ...)
>                       prefix,
>                       prefix_sep,
>                       m1,
> -                      (flags&M_NOLF) ? "" : "\n");
> +                      (flags&M_NOLF) ? "" : NEWLINE);
>  #else
>              fprintf (fp, "%s %s%s%s%s",
>                       time_string (0, 0, show_usec, &gc),
>                       prefix,
>                       prefix_sep,
>                       m1,
> -                      (flags&M_NOLF) ? "" : "\n");
> +                      (flags&M_NOLF) ? "" : NEWLINE);
>  #endif
>            }
>          fflush(fp);
> @@ -411,7 +415,7 @@ assert_failed (const char *filename, int line)
>  void
>  out_of_memory (void)
>  {
> -  fprintf (stderr, PACKAGE_NAME ": Out of Memory\n");
> +  fprintf (stderr, PACKAGE_NAME ": Out of Memory" NEWLINE);
>   exit (1);
>  }
>
> --
> 1.7.2.3
>
>
> ------------------------------------------------------------------------------
> Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
> new data types, scalar functions, improved concurrency, built-in packages,
> OCI, SQL*Plus, data movement tools, best practices and more.
> http://p.sf.net/sfu/oracle-sfdev2dev
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
>

Reply via email to