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

C

CALLOC

The CALLOC macro is a platform-independent substitute for the C library routine calloc. It allocates num*size bytes from the request’s memory pool. If pooled memory has been disabled in the configuration file (with the pool-init built-in SAF), PERM_CALLOC and CALLOC both obtain their memory from the system heap.

Syntax

void *CALLOC(int size)

Returns

A void pointer to a block of memory.

Parameters

int size is the size in bytes of each element.

Example

char *name;name = (char *) CALLOC(100);

See Also

FREE, REALLOC, STRDUP, PERM_MALLOC, PERM_FREE, PERM_REALLOC, PERM_STRDUP

cinfo_find

The cinfo_find() function uses the MIME types information to find the type, encoding, and/or language based on the extension(s) of the URI or local file name. Use this information to send headers (rq->srvhdrs) to the client indicating the content-type, content-encoding, and content-language of the data it will be receiving from the server.

The name used is everything after the last slash (/) or the whole string if no slash is found. File name extensions are not case-sensitive. The name may contain multiple extensions separated by period (.) to indicate type, encoding, or language. For example, the URI a/b/filename.jp.txt.zip could represent a Japanese language, text/plain type, zip encoded file.

Syntax

cinfo *cinfo_find(char *uri);

Returns

A pointer to a newly allocated cinfo structure if content info was found, or NULL if no content was found.

The cinfo structure that is allocated and returned contains pointers to the content-type, content-encoding, and content-language, if found. Each is a pointer into static data in the types database, or NULL if not found. Do not free these pointers. You should free the cinfo structure when you are done using it.

Parameters

char *uri is a URI or local file name. Multiple file name extensions should be separated by periods (.).

condvar_init

The condvar_init function is a critical-section function that initializes and returns a new condition variable associated with a specified critical-section variable. You can use the condition variable to prevent interference between two threads of execution.

Syntax

CONDVAR condvar_init(CRITICAL id);

Returns

A newly allocated condition variable (CONDVAR).

Parameters

CRITICAL id is a critical-section variable.

See Also

condvar_notify, condvar_terminate, condvar_wait, crit_init, crit_enter, crit_exit, crit_terminate

condvar_notify

The condvar_notify function is a critical-section function that activates threads that are blocked on the given critical-section variable. Use this function to awaken threads of execution of a given critical section. First, use crit_enter to gain ownership of the critical section. Then use the returned critical-section variable to call condvar_notify to awaken the threads. Finally, when condvar_notify returns, call crit_exit to surrender ownership of the critical section.

Syntax

void condvar_notify(CONDVAR cv);

Returns

void

Parameters

CONDVAR cv is a condition variable.

See Also

condvar_init, condvar_terminate, condvar_wait, crit_init, crit_enter, crit_exit, crit_terminate

condvar_terminate

The condvar_terminate function is a critical-section function that frees a condition variable. Use this function to free a previously allocated condition variable.

Warning

Terminating a condition variable that is in use can lead to unpredictable results.

Syntax

void condvar_terminate(CONDVAR cv);

Returns

void

Parameters

CONDVAR cv is a condition variable.

See Also

condvar_init, condvar_notify, condvar_wait, crit_init, crit_enter, crit_exit, crit_terminate

condvar_wait

The condvar_wait function is a critical-section function that blocks on a given condition variable. Use this function to wait for a critical section (specified by a condition variable argument) to become available. The calling thread is blocked until another thread calls condvar_notify with the same condition variable argument. The caller must have entered the critical section associated with this condition variable before calling condvar_wait.

Syntax

void condvar_wait(CONDVAR cv);

Returns

void

Parameters

CONDVAR cv is a condition variable.

See Also

condvar_init, condvar_terminate, condvar_notify, crit_init, crit_enter, crit_exit, crit_terminate

crit_enter

The crit_enter function is a critical-section function that attempts to enter a critical section. Use this function to gain ownership of a critical section. If another thread already owns the section, the calling thread is blocked until the first thread surrenders ownership by calling crit_exit.

Syntax

void crit_enter(CRITICAL crvar);

Returns

void

Parameters

CRITICAL crvar is a critical-section variable.

See Also

crit_init, crit_exit, crit_terminate

crit_exit

The crit_exit function is a critical-section function that surrenders ownership of a critical section. Use this function to surrender ownership of a critical section. If another thread is blocked waiting for the section, the block will be removed and the waiting thread will be given ownership of the section.

Syntax

void crit_exit(CRITICAL crvar);

Returns

void

Parameters

CRITICAL crvar is a critical-section variable.

See Also

crit_init, crit_enter, crit_terminate

crit_init

The crit_init function is a critical-section function that creates and returns a new critical-section variable (a variable of type CRITICAL). Use this function to obtain a new instance of a variable of type CRITICAL (a critical-section variable) to be used in managing the prevention of interference between two threads of execution. At the time of its creation, no thread owns the critical section.

Warning

Threads must not own or be waiting for the critical section when crit_terminate is called.

Syntax

CRITICAL crit_init(void);

Returns

A newly allocated critical-section variable (CRITICAL).

Parameters

none

See Also

crit_enter, crit_exit, crit_terminate

crit_terminate

The crit_terminate function is a critical-section function that removes a previously allocated critical-section variable (a variable of type CRITICAL). Use this function to release a critical-section variable previously obtained by a call to crit_init.

Syntax

void crit_terminate(CRITICAL crvar);

Returns

void

Parameters

CRITICAL crvar is a critical-section variable.

See Also

crit_init, crit_enter, crit_exit