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>
28 ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
41 if ( (fp = fopen( filename, "r" )) == NULL )
45 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
51 if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
52 sizeof(FriendlyMap) )) == NULL ) {
58 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
62 if ( (s = strchr( buf, '\n' )) != NULL )
65 if ( (s = strchr( buf, '\t' )) == NULL )
70 int esc = 0, found = 0;
72 for ( ++s; *s && !found; s++ ) {
88 (*map)[i].f_unfriendly = ldap_strdup( buf );
89 (*map)[i].f_friendly = ldap_strdup( s );
94 (*map)[i].f_unfriendly = NULL;
97 for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
98 if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
99 return( (*map)[i].f_friendly );
106 ldap_free_friendlymap( FriendlyMap **map )
108 struct friendly* pF = *map;
113 while ( pF->f_unfriendly )
115 free( pF->f_unfriendly );
116 free( pF->f_friendly );