summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGisle Vanem <gvanem@broadpark.no>2007-04-03 10:30:36 +0000
committerGisle Vanem <gvanem@broadpark.no>2007-04-03 10:30:36 +0000
commitd07a8748998ca015a470d9e8ed7154de40311097 (patch)
treed9467e9430cc69dc56105e1c6c2d3aaddea968fe /src
parentc420113795994ca85abe545d5fdbfba667bedfb0 (diff)
downloadcurl-d07a8748998ca015a470d9e8ed7154de40311097.tar.gz
Simplify setting binary mode on file-descriptors.
Work around the non-standard _setmode() in Metaware's HighC.
Diffstat (limited to 'src')
-rw-r--r--src/main.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index 1c9bde1fc..612e5c26b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -112,6 +112,16 @@
#define DEFAULT_MAXREDIRS 50L
+#if defined(O_BINARY) && defined(HAVE_SETMODE)
+ #ifdef __HIGHC__
+ #define SET_BINMODE(file) _setmode(file,O_BINARY)
+ #else
+ #define SET_BINMODE(file) setmode(fileno(file),O_BINARY)
+ #endif
+#else
+ #define SET_BINMODE(file) ((void)0)
+#endif
+
#ifdef __DJGPP__
#include <dos.h>
@@ -2015,10 +2025,8 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
if(curlx_strequal("-", nextarg)) {
file = stdin;
-#if defined(O_BINARY) && defined(HAVE_SETMODE)
if(subletter == 'b') /* forced binary */
- setmode(fileno(stdin), O_BINARY);
-#endif
+ SET_BINMODE(stdin);
}
else {
file = fopen(nextarg, "rb");
@@ -3967,9 +3975,7 @@ operate(struct Configurable *config, int argc, char *argv[])
}
else if(uploadfile && curlx_strequal(uploadfile, "-")) {
-#if defined(O_BINARY) && defined(HAVE_SETMODE)
- setmode(fileno(stdin), O_BINARY);
-#endif
+ SET_BINMODE(stdin);
infd = stdin;
}
@@ -4030,13 +4036,11 @@ operate(struct Configurable *config, int argc, char *argv[])
if(!config->errors)
config->errors = stderr;
-#if defined(O_BINARY) && defined(HAVE_SETMODE)
if(!outfile && !(config->conf & CONF_GETTEXT)) {
/* We get the output to stdout and we have not got the ASCII/text flag,
then set stdout to be binary */
- setmode( fileno(stdout), O_BINARY );
+ SET_BINMODE(stdout);
}
-#endif
if(1 == config->tcp_nodelay)
my_setopt(curl, CURLOPT_TCP_NODELAY, 1);