cURL / Mailing Lists / curl-users / Single Mail

curl-users

HAVE_SYS_SELECT_H, HAVE_STRDUP, and port to an RTOS

From: Rolland Dudemaine <rolland_at_ghs.com>
Date: Tue, 24 Jun 2008 16:59:59 +0200

Hi,

I have successfully ported curl and libcurl to the INTEGRITY RTOS in a
few hours. curl seems to work well, and the port was straightforward.

Here are 3 patches that were necessary to make this work.
The first 2 are actually legit improvements to the code I think, the
last one doesn't hurt :
- curl-7.18.2_sys_select.diff : autoconf has a macro to define whether
sys/select.h is available, which is HAVE_SYS_SELECT_H. Adding it to the
list helps, and should not harm existing systems.

- curl-7.18.2_strdup.diff : src/setup.h already optionally include the
local strdup.h when strdup() is not available globally in the system.
The same include should be added in lib/setup.h

- curl-7.18.2_createconnection.diff : INTEGRITY native's API has
Connection Objects, and a native call is CreateConnection(). The
attached page renames the static function CreateConnection() to
CreateCURLConnection() so that there is no conflict anymore.

What do you think ?

--Rolland

diff -ur curl-7.18.2/lib/setup.h curl-7.18.2-new/lib/setup.h
--- curl-7.18.2/lib/setup.h 2008-04-23 22:07:52.000000000 +0200
+++ curl-7.18.2-new/lib/setup.h 2008-06-24 15:06:38.000000000 +0200
@@ -366,6 +366,11 @@
 #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
 #endif
 
+#ifndef HAVE_STRDUP
+#include "strdup.h"
+#define strdup(ptr) curlx_strdup(ptr)
+#endif
+
 /*
  * Include macros and defines that should only be processed once.
  */

diff -ur curl-7.18.2/include/curl/curl.h curl-7.18.2-new/include/curl/curl.h
--- curl-7.18.2/include/curl/curl.h 2008-06-04 17:36:10.000000000 +0200
+++ curl-7.18.2-new/include/curl/curl.h 2008-06-24 14:22:16.000000000 +0200
@@ -64,7 +64,7 @@
    libc5-based Linux systems. Only include it on system that are known to
    require it! */
 #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
- defined(__minix) || defined(__SYMBIAN32__)
+ defined(__minix) || defined(__SYMBIAN32__) || HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
 

diff -ur curl-7.18.2/lib/url.c curl-7.18.2-new/lib/url.c
--- curl-7.18.2/lib/url.c 2008-04-30 23:20:09.000000000 +0200
+++ curl-7.18.2-new/lib/url.c 2008-06-24 11:56:01.000000000 +0200
@@ -3156,7 +3156,7 @@
 
   /* The protocol was not found in the table, but we don't have to assign it
      to anything since it is already assigned to a dummy-struct in the
- CreateConnection() function when the connectdata struct is allocated. */
+ CreateCURLConnection() function when the connectdata struct is allocated. */
   failf(data, "Protocol %s not supported or disabled in " LIBCURL_NAME,
         conn->protostr);
   return CURLE_UNSUPPORTED_PROTOCOL;
@@ -3436,7 +3436,7 @@
 }
 
 /**
- * CreateConnection() sets up a new connectdata struct, or re-uses an already
+ * CreateCURLConnection() sets up a new connectdata struct, or re-uses an already
  * existing one, and resolves host name.
  *
  * if this function returns CURLE_OK and *async is set to TRUE, the resolve
@@ -3454,7 +3454,7 @@
  * *NOTE* this function assigns the conn->data pointer!
  */
 
-static CURLcode CreateConnection(struct SessionHandle *data,
+static CURLcode CreateCURLConnection(struct SessionHandle *data,
                                  struct connectdata **in_connect,
                                  struct Curl_dns_entry **addr,
                                  bool *async)
@@ -4228,12 +4228,12 @@
 }
 
 /* SetupConnection() is called after the name resolve initiated in
- * CreateConnection() is all done.
+ * CreateCURLConnection() is all done.
  *
  * NOTE: the argument 'hostaddr' is NULL when this function is called for a
  * re-used connection.
  *
- * conn->data MUST already have been setup fine (in CreateConnection)
+ * conn->data MUST already have been setup fine (in CreateCURLConnection)
  */
 
 static CURLcode SetupConnection(struct connectdata *conn,
@@ -4347,7 +4347,7 @@
   *asyncp = FALSE; /* assume synchronous resolves by default */
 
   /* call the stuff that needs to be called */
- code = CreateConnection(data, in_connect, &dns, asyncp);
+ code = CreateCURLConnection(data, in_connect, &dns, asyncp);
 
   if(CURLE_OK == code) {
     /* no error */

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-06-24