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>
27 ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
35 #if !defined( MACOS ) && !defined( DOS )
42 if ( (fp = fopen( filename, "r" )) == NULL )
46 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
52 if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
53 sizeof(FriendlyMap) )) == NULL ) {
59 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
63 if ( (s = strchr( buf, '\n' )) != NULL )
66 if ( (s = strchr( buf, '\t' )) == NULL )
71 int esc = 0, found = 0;
73 for ( ++s; *s && !found; s++ ) {
89 (*map)[i].f_unfriendly = strdup( buf );
90 (*map)[i].f_friendly = strdup( s );
95 (*map)[i].f_unfriendly = NULL;
98 for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
99 if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
100 return( (*map)[i].f_friendly );
107 ldap_free_friendlymap( FriendlyMap **map )
109 struct friendly* pF = *map;
114 while ( pF->f_unfriendly )
116 free( pF->f_unfriendly );
117 free( pF->f_friendly );