diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-09 19:30:50 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-09 19:30:50 +0000 |
commit | d9d053d70b23ef46610867298dabdec579cef9c4 (patch) | |
tree | 74de256a82564ed80848297d118a55c300642025 /src | |
parent | 7daab4034dff228245cd8cdc16191457087fcd01 (diff) | |
download | tor-d9d053d70b23ef46610867298dabdec579cef9c4.tar.gz tor-d9d053d70b23ef46610867298dabdec579cef9c4.zip |
Clean windows a little
svn:r2757
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compat.c | 3 | ||||
-rw-r--r-- | src/common/util.c | 18 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index c9842b98d6..457b798f7e 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -11,10 +11,7 @@ #include "compat.h" #ifdef MS_WINDOWS -#include <io.h> #include <process.h> -#include <direct.h> -#include <windows.h> #endif #ifdef HAVE_UNAME #include <sys/utsname.h> diff --git a/src/common/util.c b/src/common/util.c index 8f0922c399..d045de9c74 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -18,12 +18,9 @@ #include "log.h" #include "crypto.h" -/* XXXX probably some of these are unneeded. find out which. */ #ifdef MS_WINDOWS #include <io.h> -#include <process.h> #include <direct.h> -#include <windows.h> #endif #ifdef HAVE_CTYPE_H @@ -90,6 +87,9 @@ #ifndef O_BINARY #define O_BINARY 0 #endif +#ifndef O_TEXT +#define O_TEXT 0 +#endif /* ===== * Memory management @@ -809,7 +809,7 @@ int write_bytes_to_file(const char *fname, const char *str, size_t len, log(LOG_WARN, "Filename %s.tmp too long (>1024 chars)", fname); return -1; } - if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:0), 0600)) + if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:O_TEXT), 0600)) < 0) { log(LOG_WARN, "Couldn't open %s for writing: %s", tempname, strerror(errno)); @@ -848,7 +848,7 @@ char *read_file_to_str(const char *filename, int bin) { return NULL; } - fd = open(filename,O_RDONLY|(bin?O_BINARY:0),0); + fd = open(filename,O_RDONLY|(bin?O_BINARY:O_TEXT),0); if (fd<0) { log_fn(LOG_WARN,"Could not open %s.",filename); return NULL; @@ -877,11 +877,9 @@ char *read_file_to_str(const char *filename, int bin) { } #ifdef MS_WINDOWS if (!bin && strchr(string, '\r')) { - if (strchr(string, '\r')) { - log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.", - filename); - tor_strstrip(string, "\r"); - } + log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.", + filename); + tor_strstrip(string, "\r"); } #endif close(fd); |