ldap_friendly_name(3ldap)


ldap_friendly_name, ldap_free_friendlymap -- LDAP unfriendly to friendly name mapping routine

Synopsis

#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);

Description

The ldap_friendly_name routine is used to map one set of strings to another. Typically, this is done for country names, to map from the two-letter country codes to longer more readable names. The mechanism is general enough to be used with other things, though.

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:

   FriendlyMap *map = NULL; 
   

printf( "unfriendly %s => friendly %s\n", name, ldap_friendly_name( "/usr/local/etc/ldapfriendly", name, &map ) );

The 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.

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.

Return values

NULL is returned by ldap_friendly_name if there is an error opening filename, if the file has a bad format, or if the map parameter is NULL.

Files

/usr/local/etc/ldapfriendly.conf

See also

Intro(3ldap)


30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.