Cichlid Library Utilities

In addition to the functions required to operate data servers and objects, Cichlid has several sets of functions and constants which can be useful in C programs in general. To access these functions in a server, put a "#define INCLUDE_CICHLID_UTILS" in your source before you include "cichlid_server.h".

This listing of the utility functions and constants provided is divided up by module.


non_ansi

This module started out as a place for common functions (like strdup(3)) that aren't part of ANSI C. It has evolved to also contain a hodge-podge of original functions and macros that don't fit in anywhere else. All of the functions and macros in this module have names starting with "na_".


pi

This is just a header file; it started out as a place to define pi, but has since grown to include a few other constants and macros. It contains:


str2long

This is a general-purpose library for converting text strings representing numbers to numeric values. These functions all return nonzero on error. These are all just wrappers for strtol(3) and strtod(3), but they perform error checking, range checking, and type conversion.

Each of these functions takes a pointer to a null-terminated string; it is expected to hold only the numeric value, and while leading spaces are tolerated, trailing spaces are not. The "base" parameter to the integer functions may range from 2 to 36, or if it's zero, bases 8, 10, and 16 will be auto-detected from the string -- see the FreeBSD strtol(3) manpage for more details. For the floating-point functions, the strings must be in base 10; see the FreeBSD strtod(3) manpage for more details. If any error is detected, such as invalid characters in the input, "result" will be set to something screwy, such as a maximum value for the type, and the function will return nonzero.


strsplit

This is a quickly-concieved library for taking a writable text string, and splitting it up at the whitespace values, null-terminating the individual strings, and creating an index of pointers to them -- much like creating an "argv" from a command line. There are two variants of this function, one that dynamically allocates the index, the other uses a pre-allocated fixed-size index.


sysdep

The "sysdep" module is for system-dependent functions and definitions, such as timing and sleeping. The idea was to keep all of the OS-specific stuff here, with the exception of the socket I/O code, to keep the majority of the source from getting mired down in #ifdef's.


colors

This library provides a searchable database of color name to RGB value mappings. The color database was derived from the XFree86 Version 3.3.2 file /usr/X11R6/lib/X11/rgb.txt. The program "lib/color_test" provides a command-line interface to this library.


Last modified: Wed Sep 1 16:25:51 PDT 1999