cURL / Mailing Lists / curl-library / Single Mail

curl-library

Using libcurl on top of lwip on POSIX embedded platform (take 2)

From: Mason <mpeg.blue_at_free.fr>
Date: Thu, 15 Mar 2012 18:49:49 +0100

Hello,

I have almost (I hope!) succeeded in generating libcurl on
top of lwip for a (mostly) POSIX sh-superh-elf platform.

The last problem comes from "generic" POSIX functions, i.e.
those that deal with file descriptors which might describe
either a regular file or a socket (e.g. close and fcntl).

The platform's system libraries export close and fcntl, to
deal with regular files, while lwip exports lwip_close and
lwip_fcntl, to deal with sockets.

As far as I can tell, in libcurl, fcntl is only called on
sockets (in nonblock.c). Therefore I think it should be
possible to have libcurl call lwip_fcntl instead of fcntl
when lwip is used.

Proposed patch (general, untested, idea)

--- nonblock.c.orig 2011-11-04 23:32:56.000000000 +0100
+++ nonblock.c 2012-03-15 18:43:44.984375000 +0100
@@ -34,6 +34,9 @@
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
+#ifdef USE_LWIPSOCK
+#define fcntl lwip_fcntl
+#endif

 #if (defined(HAVE_IOCTL_FIONBIO) && defined(NETWARE))
 #include <sys/filio.h>

For close, the solution is not so clear-cut, because curl
deals with regular files as well as sockets, AFAIU. In my
case, I've only enabled the HTTP protocol, which is why
I think I can get away with the following patch:

--- setup_once.h.orig 2011-11-04 23:32:57.000000000 +0100
+++ setup_once.h 2012-03-15 13:49:19.875000000 +0100
@@ -239,6 +239,8 @@
 # define sclose(x) closesocket((x))
 #elif defined(HAVE_CLOSESOCKET_CAMEL)
 # define sclose(x) CloseSocket((x))
+#elif defined(USE_LWIPSOCK)
+# define sclose(x) lwip_close((x))
 #else
 # define sclose(x) close((x))
 #endif

But I'm not sure how to solve the problem in the general case.
I'm not sure there even is a simple solution. Do you see one?

-- 
Regards.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-15