Sun Java System Web Server 6.1 SP11 NSAPI Programmer's Guide


The filter_create function defines a new filter.

The name parameter specifies a unique name for the filter. If a filter with the specified name already exists, it will be replaced.

Names beginning with magnus- or server- are reserved by the server.

The order parameter indicates the position of the filter in the filter stack by specifying what class of functionality the filter implements.

The following table describes parameters allowed order constants and their associated meanings for the filter_create function. The left column lists the name of the constant, the middle column describes the functionality the filter implements, and the right column lists the position the filter occupies in the filter stack.

Table 7–1 filter-create constants


Functionality Filter Implements  

Position in Filter Stack  


Translates content from one form to another (for example, XSLT) 



Encodes content (for example, HTTP gzip compression) 



Encodes entity bodies for transmission (for example, HTTP chunking) 


The methods parameter specifies a pointer to a FilterMethods structure. Before calling filter_create, you must first initialize the FilterMethods structure using the FILTER_METHODS_INITIALIZER macro, and then assign function pointers to the individual FilterMethods members (for example, insert, read, write, and so on) that correspond to the filter methods the filter will support.

filter_create returns const Filter *, a pointer to an opaque representation of the filter. This value may be passed to filter_insert to insert the filter in a particular filter stack.


const Filter *filter_create(const char *name, int order, const FilterMethods *methods);


The const Filter * that identifies the filter or NULL if an error occurred.


const char *name is the name of the filter.

int order is one of the order constants above.

const FilterMethods *methods contains pointers to the filter methods the filter supports.


const Filter *filter;
/* This filter will only support the "read" filter method */ = my_input_filter_read;
/* Create the filter */
filter = filter_create("my-input-filter", FILTER_CONTENT_TRANSLATION,