2 * Copyright (c) 1990 Regents of the University of Michigan.
11 static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
19 #include <ac/socket.h>
20 #include <ac/string.h>
22 extern char *strdup (const char *);
27 ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
40 if ( (fp = fopen( filename, "r" )) == NULL )
44 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
50 if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
51 sizeof(FriendlyMap) )) == NULL ) {
57 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
61 if ( (s = strchr( buf, '\n' )) != NULL )
64 if ( (s = strchr( buf, '\t' )) == NULL )
69 int esc = 0, found = 0;
71 for ( ++s; *s && !found; s++ ) {
87 (*map)[i].f_unfriendly = strdup( buf );
88 (*map)[i].f_friendly = strdup( s );
93 (*map)[i].f_unfriendly = NULL;
96 for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
97 if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
98 return( (*map)[i].f_friendly );
105 ldap_free_friendlymap( FriendlyMap **map )
107 struct friendly* pF = *map;
112 while ( pF->f_unfriendly )
114 free( pF->f_unfriendly );
115 free( pF->f_friendly );