]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
portability fix
authorYang Tse <yangsita@gmail.com>
Thu, 28 Jan 2010 10:27:09 +0000 (10:27 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 28 Jan 2010 10:27:09 +0000 (10:27 +0000)
tests/libtest/lib568.c
tests/libtest/lib569.c
tests/libtest/lib571.c

index 5e59a9caef6d03191c8122b033b250b748612abf..c9406b0ecd732ad94195d2affbd50e77a41b7574 100644 (file)
 
 #include "test.h"
 
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 
 #include <curl/mprintf.h>
 
@@ -34,7 +36,7 @@ int test(char *URL)
   CURL *curl;
   int sdp;
   FILE *sdpf;
-  struct stat file_info;
+  struct_stat file_info;
   char *stream_uri;
   int request=1;
   struct curl_slist *custom_headers=NULL;
@@ -61,9 +63,10 @@ int test(char *URL)
 
   sdp = open("log/file568.txt", O_RDONLY);
   fstat(sdp, &file_info);
-  sdpf = fdopen(sdp, "rb");
+  close(sdp);
+
+  sdpf = fopen("log/file568.txt", "rb");
   if(sdpf == NULL) {
-    close(sdp);
     fprintf(stderr, "can't open log/file568.txt\n");
     return TEST_ERR_MAJOR_BAD;
   }
@@ -77,13 +80,11 @@ int test(char *URL)
   res = curl_easy_perform(curl);
   if(res) {
     fclose(sdpf);
-    close(sdp);
     return res;
   }
 
   curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L);
   fclose(sdpf);
-  close(sdp);
 
   /* Make sure we can do a normal request now */
   stream_uri = suburl(URL, request++);
index 6f276d350f56ec9aeb7c73e4678e0df9a795e756..9c5d803b9f82a0180477f41232dd13a3a3c3ae2f 100644 (file)
@@ -33,7 +33,7 @@ int test(char *URL)
   int i;
   FILE *idfile;
 
-  idfile = fopen(libtest_arg2, "w");
+  idfile = fopen(libtest_arg2, "wb");
   if(idfile == NULL) {
     fprintf(stderr, "couldn't open the Session ID File\n");
     return TEST_ERR_MAJOR_BAD;
index f530deadc526db450b37c16a27f52e04cd55ce8f..4e9f387088dc72ffeedbc159eb9820259e22f151 100644 (file)
 
 #include "test.h"
 
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 
 #include <curl/mprintf.h>
 
@@ -67,7 +69,7 @@ int test(char *URL)
   int request=1;
   FILE *protofile;
 
-  protofile = fopen(libtest_arg2, "w");
+  protofile = fopen(libtest_arg2, "wb");
   if(protofile == NULL) {
     fprintf(stderr, "Couldn't open the protocol dump file\n");
     return TEST_ERR_MAJOR_BAD;