Oracle iPlanet Web Proxy Server 4.0.14 NSAPI Developer's Guide

R

read

The read filter method is called when input data is required. Filters that modify or consume incoming data should implement the read filter method.

Upon receiving control, a read implementation should fill buf with up to amount bytes of input data. This data may be obtained by calling the net_read function, as shown in the example below.

Syntax

int read(FilterLayer *layer, void *buf, int amount, int timeout);

Returns

The number of bytes placed in buf on success, 0 if no data is available, or a negative value if an error occurred.

Parameters

FilterLayer *layer is the filter layer in which the filter is installed.

void *buf is the buffer in which data should be placed.

int amount is the maximum number of bytes that should be placed in the buffer.

int timeout is the number of seconds to allow for the read operation before returning. Do not use timeoutto return because not enough bytes were read in the given time. Instead, use this function to limit the amount of time devoted to waiting until some data arrives.

Example

int myfilter_read(FilterLayer *layer, void *buf, int amount, int timeout)
	{ return net_read(layer->lower, buf, amount, timeout);}

See Also

net_read

REALLOC

The REALLOC macro is a platform-independent substitute for the C library routine realloc. It changes the size of a specified memory block that was originally created by MALLOC, CALLOC, or STRDUP. The contents of the object remains unchanged up to the lesser of the old and new sizes. If the new size is larger, the new space is uninitialized.

Warning

Calling REALLOC for a block that was allocated with PERM_MALLOC, PERM_CALLOC, or PERM_STRDUP will not work.

Syntax

void *REALLOC(void *ptr, int size);

Returns

A pointer to the new space if the request could be satisfied.

Parameters

void *ptr is a (void *) pointer to a block of memory. If the pointer was not created by MALLOC, CALLOC, or STRDUP, the behavior is undefined.

int size is the number of bytes to allocate.

Example

char *name;name = (char *) MALLOC(256);if (NotBigEnough())    
	name = (char *) REALLOC(512);

See Also

MALLOC, FREE, STRDUP, CALLOC, PERM_MALLOC, PERM_FREE, PERM_REALLOC, PERM_CALLOC, PERM_STRDUP

remove

The remove filter method is called when the filter stack is destroyed, or when a filter is removed from a filter stack by the filter_remove function or remove-filter SAF (applicable in Input-, Output-, Service-, and Error-class directives).

Waiting to flush buffered data when the remove method is invoked might be too late. For this reason, filters that buffer outgoing data should implement the flush filter method.

Syntax

void remove(FilterLayer *layer);

Returns

void

Parameters

FilterLayer *layer is the filter layer the filter is installed in.

See Also

flush

request_create

The request_create function is a utility function that creates a new request structure.

Syntax

#include <frame/req.h>
Request *request_create(void);

Returns

A Request structure

Parameters

No parameter is required.

See Also

request_free, request_header

request_free

The request_free function frees a specified request structure.

Syntax

#include <frame/req.h>
void request_free(Request *req);

Returns

void

Parameters

Request *rq is the Request structure to be freed.

See Also

request_header

request_header

The request_header function finds an entry in the pblock containing the client’s HTTP request headers (rq->headers). You must use this function rather than pblock_findval when accessing the client headers because the server might begin processing the request before the headers have been completely read.

Syntax

int request_header(char *name, char **value, Session *sn, Request *rq);

Returns

Returns REQ_PROCEED if the header was found, REQ_ABORTED if the header was not found, or REQ_EXIT if an error occurred reading from the client.

Parameters

char *name is the name of the header.

char **value is the address where the function will place the value of the specified header. If none is found, the function stores NULL.

Session *sn identifies the Session structure.

Request *rq identifies the Request structure.

The Session and Request parameters are the same as the parameters passed into your SAF.

See Also

request_create, request_free