# The "chm" Package

These routines are meant to provide a generic and simple to use channel management facility (i.e. event processing on pipes, connections and terminals). A similar set of routines: chx_ provide identical functionality (with the exception of the polling routine), except that they rely on the Xt Intrinsics event dispatching system.

Library: karma
Link With: -lkarma

#### Functions

chm_manage | Manage a channel for activity by registering callback routines.
chm_unmanage | Terminate the management of a channel for activity.
chm_unmanage_by_handle | Terminate the management of a channel for activity.

#### Prototype Functions

chm_PROTO_input_func | This routine is called when new input occurs on a channel.
chm_PROTO_close_func | This routine is called when a channel closes.
chm_PROTO_output_func | This routine is called when a channel becomes ready for writing.
chm_PROTO_exception_func | This routine is called when an exception occurs on channel.

## Functions

KManagedChannel chm_manage ( Channel channel, void *info, flag (*input_func) (), void (*close_func) (), flag (*output_func) (),flag (*exception_func) () )

Manage a channel for activity by registering callback routines.

Parameters:

- channel : The channel object to manage.
- info : The arbitrary information pointer associated with the managed channel. This pointer may be modified by the callback routines.
- input_func : This routine is called when new input occurs on the channel. If this is NULL, no callback routine is installed. The prototype function is chm_PROTO_input_func.
- close_func : This routine is called when the channel closes. If this is NULL, no callback routine is installed. The prototype function is chm_PROTO_close_func. The channel object MUST be capable of detecting closure if this routine is supplied (i.e. this routine cannot be supplied for dock channels). Any unread buffered data in the channel will be lost upon closure. The call to this function is the last chance to read this buffered data.
- output_func : This routine is called when the channel becomes ready for output. If this is NULL, no callback routine is installed. The prototype function is chm_PROTO_output_func.
- exception_func : This routine is called when exceptions occur on the channel. If this is NULL, no callback routine is installed. The prototype function is chm_PROTO_exception_func.

Returns: A KManagedChannel object on success, else NULL.
Multithreading Level: Unsafe

void chm_unmanage (Channel channel)

Terminate the management of a channel for activity.

Parameters:

- channel : The channel object to unmanage. The channel must be open.

Returns: Nothing.
Multithreading Level: Unsafe
Note:

- This routine will NOT close the channel.

#### EXPERIMENTAL FUNCTION: subject to change without notice

void chm_unmanage_by_handle (KManagedChannel mch)

Terminate the management of a channel for activity.

Parameters:

- mch : The KManagedChannel object.

Returns: Nothing.
Multithreading Level: Unsafe
Note:

- This routine will NOT close the channel.

## Prototype Functions

flag chm_PROTO_input_func (Channel channel, void **info)

This routine is called when new input occurs on a channel.

Parameters:

- channel : The channel object.
- info : A pointer to the arbitrary information pointer. This may be modified

Returns: TRUE if the channel is to remain managed and open, else FALSE (indicating that the channel is to be unmanaged and closed).
Multithreading Level: Unsafe
Note:

- This routine MUST NOT unmanage or close the channel.
- The close_func will be called if this routine returns FALSE.

void chm_PROTO_close_func (Channel channel, void *info)

This routine is called when a channel closes.

Parameters:

- channel : The channel object.
- info : The arbitrary pointer for the channel.

Returns: Nothing.
Multithreading Level: Unsafe
Note:

- This routine MUST NOT unmanage the channel. The channel will be automatically unmanaged and deleted upon closure (even if no close_func is specified).

flag chm_PROTO_output_func (Channel channel, void **info)

This routine is called when a channel becomes ready for writing.

Parameters:

- channel : The channel object.
- info : A pointer to the arbitrary information pointer. This may be modified

Returns: TRUE if the channel is to remain managed and open, else FALSE (indicating that the channel is to be unmanaged and closed).
Multithreading Level: Unsafe
Note:

- This routine MUST NOT unmanage or close the channel.
- The close_func will be called if this routine returns FALSE.

flag chm_PROTO_exception_func (Channel channel, void **info)

This routine is called when an exception occurs on channel.

Parameters:

- channel : The channel object.
- info : A pointer to the arbitrary information pointer. This may be modified

Returns: TRUE if the channel is to remain managed and open, else FALSE (indicating that the channel is to be unmanaged and closed).
Multithreading Level: Unsafe
Note:

- This routine MUST NOT unmanage or close the channel.
- The close_func will be called if this routine returns FALSE.

Back to Karma Home Page