W3C libwww Using

Application Specific Core Modules

We have now almost finised the description of the W3C Sample Code Core - we only need the last module which we will describe in this section. The module is called HTAlert and it contains the functionality for prompting the user for feedback or for reporting messages from the Library. As mentioned many times in this guide, the Library has been designed to be as portable as possible. This means that the actual implementation of this module is very simple and does only use ANSI C I/O functions. However, the can be overridden by more complex applications, for example using a GUI window manager.

The Alert module is a part of the core as the rest of the core files depend on it. Hence the definition of the module must be provided either by the internal or an external definition. A C Library module can be overriding by redefining all external references (normally declared in the include file) by new definitions in an application module. By doing this the linker takes the new definition of the module instead of the Library version and links it into the final executable file. The declaration (the include file) stays the same, but the definition has changed. The application module does not need to be called the same as the Library module, only the external references. External references are both global variables and public functions visible to other modules. As an example, the following module:

	/* Library.c */
	char GlobalFlag;
	int GlobalFunction(void)
	{
		/* Library src */
	}
with the declaration file:

	/* Library.h */
	extern char GlobalFlag;
	extern int GlobalFunction(void);
can get a new definition module

	/* Application.c */
	char GlobalFlag;
	int GlobalFunction(void)
	{
		/* Application src */
	}
which will then be linked into the executable program. By using this method, the application can easily provide its own user interface (if any) and still be able to use the Library.


Henrik Frystyk, libwww@w3.org, @(#) $Id: Override.html,v 1.13 1997/02/16 18:41:43 frystyk Exp $