KP_UTILS(3) KP_UTILS(3) NAME kp_dir_open, kp_dir_getpath, kp_dir_close, kp_get_enum, kp_set_enum, kp_get_bool, kp_set_bool - keeper utility functions SYNOPSIS #include KPDIR *kp_dir_open (const char *keypath); const char *kp_dir_getpath (KPDIR *kpdir, const char *subkey); int kp_dir_close (KPDIR *kpdir); int kp_get_enum (const char *keypath, const char *names[], int *valp); int kp_set_enum (const char *keypath, const char *names[], int val); int kp_get_bool (const char *keypath, int *boolp); int kp_set_bool (const char *keypath, int boolval); DESCRIPTION kp_dir_open kp_dir_getpath kp_dir_close These functions make it easier to build the keypath argu- ment required for most of the keeper manipulation func- tions. The kp_dir_open function returns a pointer to newly allo- cated KPDIR structure. Note: this function does not actu- ally check if the key exist and it does not get the con- tents of the directory. Use the kp_get_dir function for that. Note: in a multithreaded program you cannot share one KPDIR structure between two different threads. The kp_dir_getpath function returns a keypath, which is created by appending the subkey parameter to the keypath argument given in kp_dir_open. The macro KP_P is defined to be the same as kp_dir_getpath. You probably want to use this macro instead of the function, for a shorter line, and less typing. The kp_dir_close function deallocates space allocated by kp_dir_open and kp_dir_getpath. kp_get_enum kp_set_enum These functions make it easier to store and retrieve enu- merated values as strings. The functions take an array of strings, which are the names of the enumerated constants. This array must be NULL terminated. In case the value can- not be found in the name array, KPERR_BADTYPE is returned. kp_get_bool Version 1.0 20 Feb 2000 1 KP_UTILS(3) KP_UTILS(3) kp_set_bool These functions can be used to store and retieve boolean values as strings "TRUE" and "FALSE". RETURN VALUE kp_dir_open kp_dir_getpath kp_dir_close These functions always succeed. If the memory cannot be allocated (very unlikely) then the program is aborted. kp_get_enum kp_set_enum kp_get_bool kp_set_bool These functions return KPERR_BADTYPE in case the enumer- ated value cannot be found in the name array. Otherwise they return the result of the kp_get_string or the kp_set_string functions respectively. SEE ALSO keeper(3), kp_base(3), kptool(1) http://www.inf.bme.hu/~mszeredi/keeper/index.html AUTHOR Miklos Szeredi (EMAIL: mszeredi@inf.bme.hu) Version 1.0 20 Feb 2000 2