Re: using threads in libwww

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 UTC