The "dm" Package

These routines are meant to provide a generic and simple to use descriptor management facility (ie. event processing on pipes, connections and terminals). NOTE: THIS PACKAGE IS WORK IN PROGRESS. THE INTERFACE MAY CHANGE IN THE NEXT RELEASE, POSSIBLY WITHOUT NOTICE.

Library: karma
Link With: -lkarma

Functions

dm_register_managersRegister the managers.
dm_manageManage a file descriptor for events.
dm_unmanageTerminate the management of a file descriptor for activity.
dm_native_setupSetup descriptor management using native implementation.
dm_native_pollPoll all managed descriptors for any activity.
dm_native_clear_activity_counterClear the idle counter.
dm_native_get_activity_countGet the current activity count.
dm_native_clear_idle_timerClear the idle timer.
dm_native_get_idle_timeGet the idle time in microseconds.
dm_native_wait_inputBlock waiting for input on a file descriptor.

Prototype Functions

dm_PROTO_input_funcInput event callback.
dm_PROTO_close_funcClose event callback.
dm_PROTO_output_funcOutput event callback.
dm_PROTO_exception_funcException event callback.
dm_PROTO_inode_write_funcInode write event callback.

Tables

dm_EVENTSList of event types


Functions


EXPERIMENTAL FUNCTION: subject to change without notice

void dm_register_managers ( KManagedDescriptor (*manage_func) (int fd, void *info, flag auto_close,va_list argp), void *(*unmanage_func) (int fd, KManagedDescriptor md) )

Register the managers.

Parameters:

Returns: Nothing. On failure the process aborts.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KManagedDescriptor dm_manage (int fd, void *info, flag auto_close, ...)

This routine will manage a file descriptor for activity by registering callback routines. Only one set of callbacks may be registered per file descriptor.

Parameters:

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


void * dm_unmanage (int fd, KManagedDescriptor md)

Terminate the management of a file descriptor for activity.

Parameters:

Returns: The arbitrary pointer passed when the descriptor was managed.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

void dm_native_setup ()

Setup descriptor management using native implementation.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void dm_native_poll (long timeout_ms)

Poll all managed descriptors for any activity.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void dm_native_clear_activity_counter ()

Clear the idle counter.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

unsigned long dm_native_get_activity_count ()

This function will get the current activity count. This is the count of the number of times the OS has detected activity on one or more file descriptors.

Parameters:

Returns: The activity count.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void dm_native_clear_idle_timer ()

Clear the idle timer.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

unsigned long dm_native_get_idle_time ()

Get the idle time in microseconds.

Parameters:

Returns: The idle time.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag dm_native_wait_input (int fd, int timeout)

Block waiting for input on a file descriptor.

Parameters:

Returns: TRUE on activity, else FALSE on error/timeout.
Multithreading Level: Unsafe


Prototype Functions


flag dm_PROTO_input_func (int fd, void **info)

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

Parameters:

Returns: TRUE if the descriptor is to remain managed and open, else it returns FALSE (indicating that the descriptor is to be unmanaged and closed). This routine MUST NOT unmanage or close the descriptor.
Multithreading Level: Unsafe
Note:


void dm_PROTO_close_func (int fd, void *info)

This routine is called when a descriptor closes.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


flag dm_PROTO_output_func (int fd, void **info)

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

Parameters:

Returns: TRUE if the descriptor is to remain managed and open, else it returns FALSE (indicating that the descriptor is to be unmanaged and closed). This routine MUST NOT unmanage or close the descriptor.
Multithreading Level: Unsafe
Note:


flag dm_PROTO_exception_func (int fd, void **info)

This routine is called when an exception occurs on a descriptor.

Parameters:

Returns: TRUE if the descriptor is to remain managed and open, else it returns FALSE (indicating that the descriptor is to be unmanaged and closed). This routine MUST NOT unmanage or close the descriptor.
Multithreading Level: Unsafe
Note:


flag dm_PROTO_inode_write_func (int fd, void **info)

This routine is called when an inode is written to.

Parameters:

Returns: TRUE if the descriptor is to remain managed and open, else it returns FALSE (indicating that the descriptor is to be unmanaged and closed). This routine MUST NOT unmanage or close the descriptor.
Multithreading Level: Unsafe
Note:


Tables


dm_EVENTS List of event types

Name Function Prototype Meaning
KARMA_FD_EVENT_END End of varargs list
KARMA_FD_EVENT_INPUT dm_PROTO_input_func
KARMA_FD_EVENT_OUTPUT dm_PROTO_output_func
KARMA_FD_EVENT_EXCEPTION dm_PROTO_exception_func
KARMA_FD_EVENT_CLOSE dm_PROTO_close_func
KARMA_FD_EVENT_INODE_WRITE dm_PROTO_inode_write_func


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services