#include <lber.h> #include <ldap.h>typedef struct friendly { char
f_unfriendly; char
f_friendly; } FriendlyMap;
char
ldap_friendly_name(char
filename, char
name, FriendlyMap
map);
void ldap_free_friendlymap(FriendlyMap
map);
filename is the name of a file containing the unfriendly to friendly mapping, name is the unfriendly name to map to a friendly name, and map is a result-parameter that should be set to NULL on the first call. It is then used to hold the mapping in memory so that the file need not be read on subsequent calls.
For example:
FriendlyMapThe mapping file should contain lines like unfriendlyname\tfriendlyname, where ``\t'' represents a tab. Lines that begin with a number sign (#) are comments and are ignored.map = NULL;
printf( "unfriendly %s => friendly %s\n", name, ldap_friendly_name( "/usr/local/etc/ldapfriendly", name, &map ) );
The ldap_free_friendlymap call is used to free structures allocated by ldap_friendly_name when no more calls to ldap_friendly_name are to be made.