Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_friendly_name()

The ldap_friendly_name() function maps a set of "unfriendly names" (for example, a two-letter country code such as "IS") to "friendly names" (for example, the full names of countries, such as "Iceland") .

This function relies on the existence of a file mapping "unfriendly names" to "friendly names". The names in the file are tab-delimited, as shown below:

...
<unfriendly_name>                        <friendly_name>
AD      Andorra 
AE      United Arab Emirates 
AF      Afghanistan 
AG      Antigua and Barbuda 
AI       Anguilla 
...

Syntax

#include <ldap.h>
char * ldap_friendly_name( char *filename, char *uname,
   FriendlyMap *map );

Parameters

This function has the following parameters:

filename

Name of the map file listing the "unfriendly names" and "friendly names"

uname

"Unfriendly name" for which you want to find the "friendly name"

map

Pointer to the mapping in memory. Initialize this pointer to NULL on the first call, then use the pointer during subsequent calls so that the mapping file does not need to be read again.

Returns

One of the following values:

Example

The following section of code reads in a map of friendly names and prints the name corresponding to the unfriendly name "IS".

#include <ldap.h>
#include <stdio.h>
...
FriendlyMap map = NULL;
char *map_file = "/u/mozilla/ldapsdk/examples/ldapfriendly";
char *unfriendly_name = "IS";
char *friendly_name;
...
/* Read the ldapfriendly file into the map in memory */
friendly_name = ldap_friendly_name( map_file, unfriendly_name, &map );
printf( "Friendly Name for %s: %s\n", unfriendly_name, friendly_name );
/* Since the file is in memory now, no need to reference it in subsequent calls */
friendly_name = ldap_friendly_name( NULL, "VI", &map );
printf( "Friendly Name for VI: %s\n", friendly_name );
...

See Also

ldap_free_friendlymap().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23