W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

Re: How do I compile simple demo

From: Fox One <rockman66_1999@yahoo.com>
Date: Wed, 12 Jul 2000 19:50:28 -0700 (PDT)
Message-ID: <20000713025028.28236.qmail@web4303.mail.yahoo.com>
To: David Boosalis <boosalis@pacbell.net>
Cc: Libwww-List <www-lib@w3.org>
Hello David. 

--- David Boosalis <boosalis@pacbell.net> wrote:
> I downloaded the libwww software, and compiled it successfully on
> Linux.  However I have
> been unable to compile even the simplest of programs that use libwww.
> 
[...]
> If someone could please send or post a makefile that would really
> help.   Or if they can help me get it to compile and linked I would
> be
> happy to submit a Makefile for other newbies.

You forgot to CC: the libwww mailing list. There
are certainly libwww developers/users that know
more about it than I do. :-)

Anyway, what follows is a sample make file and
one of my play files. 

All of this code is under the GPL. 

================== makefile ===============

CFLAGS := $(CFLAGS) 

CFLAGS := $(CFLAGS) -g -I. \
        $(shell libwww-config --cflags) 

LINKFLAGS := $(LINKFLAGS) -g $(shell libwww-config --libs) 

% : %.c

% : %.o
        gcc -o $@ $^ $(LINKFLAGS)

%.o : %.c
        gcc $(CFLAGS) -c $<

all : lwplay4

clean : 
        rm -f $(wildcard lwplay*.o) lwplay lwplay2 lwplay3 lwplay4 \
                lwplay5 lwplay6 lwplay7 lwplay8 lwplay9 lwplay10 \
                lwplay11 logfile.o thork.o ablog.txt w3chttp.out

realclean : clean

distclean : clean

mtest : 
        gcc -E lwplay4.c $(CFLAGS) > outp

.PHONY: clean realclean distclean mtest

================ lwplay4.c ================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <WWWLib.h>
#include <HTProfil.h>
#include <HTChunk.h>

        /************** HEADER FILE *************/

        /************** DEFINES AND TYPES *************/

        /************** PROTOTYPES *************/

PRIVATE int             printer (const char * , va_list);
PRIVATE int             tracer (const char *, va_list);


        /************** GLOBAL VARIABLES *************/

static const int                always_true = 1;
static const int                always_false = 0;

        /************** MAIN *************/

int main (int argc, const char * argv [])
{
HTRequest * request = 0;
HTChunk * chunk = 0;
const char * url = "http://localhost:8080";

        if (argc > 1)
        {
                url = argv [1];
        }

                /***********************************
                Allocate a request object.
                ***********************************/
        request = HTRequest_new ();
        if (0 == request) return 1;

                /***********************************
                Initialize a profile.
                ***********************************/
        HTProfile_newPreemptiveClient ("play4", "0.1");

                /***********************************
                Set up the traces. 
                ***********************************/
        HTPrint_setCallback (printer);
        HTTrace_setCallback (tracer);

                /***********************************
                Turn on the tracing feature. 
                ***********************************/
        HTSetTraceMessageMask ("sop");

                /***********************************
                Use the raw output format, including
                headers. 
                ***********************************/
        HTRequest_setOutputFormat (request, WWW_RAW);

                /***********************************
                Close connection immediately. 
                ***********************************/
        HTRequest_addConnection (request, "close", "");

        if (always_true)
        {
        char * nullone = 0;
        char * absolute_url = HTSACopy (&nullone, url);
        if (absolute_url)
                {
                printf ("HT Copy : %s\n", absolute_url);
                chunk = HTLoadToChunk (absolute_url, request); 
                HT_FREE (absolute_url);
                }
        } /* end if */

        if (chunk)
        {
        char * chunkstring = 0;
                chunkstring = HTChunk_toCString (chunk);
                if (chunkstring)
                {
                printf ("CHUNK:\n%s\n", chunkstring);
                HT_FREE(chunkstring);
                }
        }

        puts ("Hmm");

        HTRequest_delete (request);
        HTProfile_delete ();
        return 0;
}

        /************** FUNCTIONS *************/

PRIVATE int     printer (const char * fmt, va_list pargs)
{
        return (vfprintf (stdout, fmt, pargs));
}

PRIVATE int     tracer (const char * fmt, va_list pargs)
{
        return (vfprintf (stdout, fmt, pargs));
}



__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail  Free email you can access from anywhere!
http://mail.yahoo.com/
Received on Wednesday, 12 July 2000 22:51:03 GMT

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