W3C Lib

HTUtils functions

HTUtils is a subset of the libwww modules that is used by CSLUtils. That is, the CSLUtils modules, CSParse and CSLabel, use certain functionality from libwww. The functions containing these modules have been sequestered into a seperated directory called HTUtils. When CSLApp is being used in an application not based on libwww, it is expected that the developer will either:
  1. import the modules
  2. emulate their functionality elsewhere in the app
  3. define macros to map HT functions to those already in the application
A combination of 1 and 2 can be see in the LablPars example.

function list

importing HT modules

The simplest way to provide the HT functionality to the application is to add the required modules to the application. Because all libwww functions and macros start with HT, there should be no name collisions. However, this may result in redundant code. If your application already has List, Chunk, string, or memory functions, it may be advisable to use one of the following solutions:

emulating HT functions in the application

Any of the HT functions may be resolved elsewhere in the application. The LablPars example uses this technique to provide the HTMemory_ functions. It includes simple version of the HTMemory_ functions in LabePars.c, eg:
void * HTMemory_malloc (size_t size)
{
    return malloc(size);
}

void HTMemory_free (void * ptr)
{
    free(ptr);
}

mapping HT functions to application functions

The parser modules all include HTUtils.h. This module maps macros to the HT functions listed above. The developer may with to replace HTUtils.h with one that maps the macros to funtions already present in the application. Some of the functions, HTTrace, and the HTMemory_ functions, correlate to stdlib functions and may be mapped directly to them, eg:
#define HT_MALLOC malloc
#define HT_CALLOC calloc
#define HT_REALLOC realloc
#define HT_FREE free

LablPars

The LablParse.c program is an example of a simple application using the CSLUtils interface to libpics. It includes the libwww modules The functionality of HTMemory.c is provided by the HTMemory_ functions in the bottom of LablPars.c. HTMemory.c's implementation of the HTMemory_ functions provides callbacks for out of memory conditions and was more complicated than the LablPars example merrited.


Eric Prud'hommeuax, libpics@w3.org, March 96