2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1990 Regents of the University of Michigan.
19 #include <ac/socket.h>
20 #include <ac/string.h>
26 ldap_friendly_name( char *filename, char *uname, LDAPFriendlyMap **map )
39 if ( (fp = fopen( filename, "r" )) == NULL )
43 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
49 if ( (*map = (LDAPFriendlyMap *) malloc( (entries + 1) *
50 sizeof(LDAPFriendlyMap) )) == NULL ) {
56 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
60 if ( (s = strchr( buf, '\n' )) != NULL )
63 if ( (s = strchr( buf, '\t' )) == NULL )
68 int esc = 0, found = 0;
70 for ( ++s; *s && !found; s++ ) {
86 (*map)[i].lf_unfriendly = strdup( buf );
87 (*map)[i].lf_friendly = strdup( s );
92 (*map)[i].lf_unfriendly = NULL;
95 for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) {
96 if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 )
97 return( (*map)[i].lf_friendly );
104 ldap_free_friendlymap( LDAPFriendlyMap **map )
106 LDAPFriendlyMap* pF = *map;
111 while ( pF->lf_unfriendly )
113 free( pF->lf_unfriendly );
114 free( pF->lf_friendly );