Sun Java System Web Proxy Server 4.0.2 2005Q4 NSAPI Developer's Guide

D

daemon_atrestart

The daemon_atrestart function lets you register a callback function named by fn to be used when the server terminates. Use this function when you need a callback function to deallocate resources allocated by an initialization function. The daemon_atrestart function is a generalization of the magnus_atrestart function.

The magnus.conf directives TerminateTimeout and ChildRestartCallback also affect the callback of NSAPI functions.

Syntax

void daemon_atrestart(void (*fn)(void *), void *data);

Returns

void

Parameters

void (* fn) (void *) is the callback function.

void *data is the parameter passed to the callback function when the server is restarted.

Example

/* Register the log_close function, passing it NULL */ /* to close *a log 
	file when the server is *//* restarted or shutdown. 
	*/daemon_atrestart(log_close, NULL);NSAPI_PUBLIC void log_close(void *parameter)
	{system_fclose(global_logfd);}

dns_set_hostent

The dns_set_hostent function sets the DNS host entry information in the request.If this is set, the proxy won’t try to resolve host information by itself, but instead it will just use this host information which was already resolved within custom DNS resolution SAF.

Syntax

int dns_set_hostent(struct hostent *hostent, Session *sn, Request *rq);

Returns

REQ_PROCEED on success or REQ_ABORTED on error.

Parameters

struct hostent *hostent is a pointer to the host entry structure.

Session *sn is the Session

Request *rq is the Request

Example

int my_dns_func(pblock *pb, Session *sn, Request *rq)
{
    char *host = pblock_findval("dns-host", rq->vars);
    struct hostent *hostent;
    hostent = gethostbyname(host);//replace with custom DNS implementation
    dns_set_hostent(hostent, sn, rq);
    return REQ_PROCEED;
}