W3C libwww Using

Getting Started

This guide assumes that you have already compiled libwww and are ready to use it building an application. Libwww is divided into a set of packages containing various part of functionality. They all have a name starting with WWW - two of them are required to use in all libwww applications, the rest is optional:

The WWW Utility module contains a lot of the functionality that makes it possible to make applications, that is container modules for data objects, basic string functionality etc. This module is the basis for all of the following modules and is used extensively.
The WWW Core module is a set of registration modules that glues an application together. It contains no real functionality in itself; it is for example not capable of loading an HTML document. It only provides a large set of hooks which can be used to add functionality to libwww and to give an application "real life". We will here a lot more to the structure of the core, and much of this guide is actually describing how to add functionality to the core.

The application must explicitly initialize libwww before it can start using it so that the internal file descriptors, and variables can be set to their respective values. This only has to be done once while the application is running and is typically done when the application is started. The application also should close down libwww when it has stopped using it - typically when the application is closing down. Libwww will then return resources like file descriptors and dynamic memory to the operating system.

Building your first Application

Note: If you are on Unix and you have installed libwww then you can use the libwww-config script to make linking against libwww easier. In Windows MSVC you have to include the DLLs in your application project.

The sample app above doesn't do anything whatsoever. There are now two ways you can go for intializing the features you need in libwww:

Which method is right for you depends on your application and how much you want to get your feet wet. If you are in doubt then I would recommend using profiles.

Adding Functionality

Sometimes, profiles are not enough - you may need a combination of features that is not supported by a default profile. In this case, you may be able to take one of the profiles and then edit it to suit your needs. You can also have a look at the sample applications to get a better idea about which profiles can be used for what purposes.

Fetching a Document from the Web

Some operations that are often used is to get or save a document on the Web. There are already several sample applications that do this kind of thing - I recommend that you have a look at the libwww applications and see whether you can not start from there.

Henrik Frystyk Nielsen,
@(#) $Id: Startup.html,v 1.23 1999/05/18 20:31:07 frystyk Exp $