W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2002

Re: using threads in libwww

From: Vic Bancroft <bancroft@zvolve.com>
Date: Wed, 9 Oct 2002 00:48:25 -0400 (EDT)
To: mnautiyal@hss.hns.com
cc: www-lib@w3.org
Message-ID: <Pine.SOL.4.21.0210090005580.26243-300000@zweb>

Well, there are a few issues I had with your example to compile in 
linux.  Without knowing your compiler or Makefile, it may not be a
thing you are required to do.  I needed to add several headers, 

  #include <netdb.h>
  #include <sys/stat.h>
  #include <unistd.h>

in addition to the ones found in -I/usr/local/include/w3c-libwww/

It was also necessary to define HAVE_STRERROR to avoid a conflict.
A simple way is to define it on the command line along with _REENTRANT,
however the proper way is to use the www configuration header,

  #include <wwwconf.h>

A compiler warning can be removed if FALSE is used instead of NULL
when checking the return value of HTPostAnchor(), e.g.,

  PUBLIC HTChunk * PostAnchorToChunk (HTParentAnchor *    source,
                                      HTAnchor *             destination,
                                      HTRequest *            request)

  {
      if (source && destination && request) {
          HTChunk * chunk = NULL;
          HTStream * target = HTStreamToChunk(request, &chunk, 0);
          HTRequest_setOutputStream(request, target);
          if (HTPostAnchor(source, destination, request) != FALSE)
              return chunk;
          else {
              HTChunk_delete(chunk);
              return NULL;
          }
      }
      return NULL;
 }

In a similar way, main should usually return an int.  It makes for a
more flexible program to take variable program parameters, giving,

  int main( int argc, char** argv )

for program entry point.  I suggest taking in server url and file url.

I did not take the time to trim what libraries were actually being used, so I
just included them all, ending up with a compile line as follows,

  gcc hss.c -D_REENTRANT -lpthread -lwwwapp -lwwwgopher -lwwwnews -lwwwcache
      -lwwwhtml -lwwwstream -lwwwcore -lwwwhttp -lwwwtelnet -lwwwdir -lwwwinit 
      -lwwwtrans -lwwwfile -lwwwmime -lwwwutils -lwwwftp -lwwwmux -lwwwxml
      -lwwwzip -lxmlparse -lxmltok -lmd5 -I/usr/local/include/w3c-libwww/ -o hss

The modified code is attached along with the output log of a run . . . 

more,
l8r,

------------------------------------------------------------------- 
Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505 
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509 
Fellow, Artificial Intelligence Center              [v]706.542-0358 
Athens, Georgia  30602, U.S.A           http://ai.uga.edu/~bancroft 


Received on Wednesday, 9 October 2002 00:49:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:42 GMT