# The "chs" Package

These routines are meant to provide a simple method of reading (scanning) channel objects for ASCII representations of floating point and integer values.

Library: karma
Link With: -lkarma

#### Functions

chs_get_value | Scan a channel object for a whitespace separated value.
chs_get_value2 | Scan a channel object for a whitespace separated value.
chs_get_float | Scan a channel object for a float value.
chs_get_int | Scan a channel object for an integer value.
chs_get_line | Scan a channel object for a line.
chs_get_line2 | Scan a channel object for a line.

## Functions

unsigned int chs_get_value (Channel channel, char *string, unsigned int length)

Scan a channel object for a whitespace separated value.

Parameters:

- channel : The channel to read from.
- string : The routine will write the value here.
- length : The size of the buffer (in bytes).

Returns: The length of the string scanned on success, else 0.
Multithreading Level: Unsafe

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

unsigned int chs_get_value2 (Channel channel, char *string, unsigned int length, flag *newline)

This routine will scan a channel object for a whitespace separated value. '#' is the comment character.

Parameters:

- channel : The channel to read from.
- string : The buffer to write the value to.
- length : The size of the buffer (in bytes).
- newline : The value TRUE is written here if a newline was read, else FALSE is written here.

Returns: The length of the string scanned on success, else 0.
Multithreading Level: Unsafe

double chs_get_float (Channel channel)

This routine will scan a channel object for the ASCII representation of a floating point number. Any leading whitespace will be ignored.

Parameters:

- channel : The channel to read from.

Returns: The value scanned. On error the process exits.
Multithreading Level: Unsafe

int chs_get_int (Channel channel)

This routine will scan a channel object for the ASCII representation of an integer number. Any leading whitespace will be ignored.

Parameters:

- channel : The channel object to read from.

Returns: The value scanned. On error the process exits.
Multithreading Level: Unsafe

flag chs_get_line (Channel channel, char *buffer, unsigned int length)

This routine will read a line from a channel, stripping all comments, leading and trailing whitespace. The comment character is '#'. The comment character is ignored if between quotes. Blank or commented lines are ignored.

Parameters:

- channel : The channel object to read from.
- buffer : The buffer to write the line into.
- length : The size of the buffer.

Returns: TRUE on success, else FALSE (indicating End-Of-File). Data is still written to the buffer and NULL terminated on EOF.
Multithreading Level: Unsafe

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

flag chs_get_line2 (Channel channel, char *buffer, unsigned int length, char comment)

This routine will read a line from a channel, stripping all comments, leading and trailing whitespace. The comment character is ignored if between quotes. Blank or commented lines are ignored.

Parameters:

- channel : The channel object to read from.
- buffer : The buffer to write the line into.
- length : The size of the buffer.
- comment : The comment character.

Returns: TRUE on success, else FALSE (indicating End-Of-File). Data is still written to the buffer and NULL terminated on EOF.
Multithreading Level: Unsafe

Back to Karma Home Page