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>
26 ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
39 if ( (fp = fopen( filename, "r" )) == NULL )
43 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
49 if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
50 sizeof(FriendlyMap) )) == 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].f_unfriendly = strdup( buf );
87 (*map)[i].f_friendly = strdup( s );
92 (*map)[i].f_unfriendly = NULL;
95 for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
96 if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
97 return( (*map)[i].f_friendly );
104 ldap_free_friendlymap( FriendlyMap **map )
106 struct friendly* pF = *map;
111 while ( pF->f_unfriendly )
113 free( pF->f_unfriendly );
114 free( pF->f_friendly );