2 * Copyright (c) 1990 Regents of the University of Michigan.
9 static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
20 #if defined( DOS ) || defined( _WIN32 )
25 #if !defined( MACOS ) && !defined( DOS )
27 #include <sys/types.h>
28 #include <sys/socket.h>
35 ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
43 #if !defined( MACOS ) && !defined( DOS )
50 if ( (fp = fopen( filename, "r" )) == NULL )
54 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
60 if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
61 sizeof(FriendlyMap) )) == NULL ) {
67 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
71 if ( (s = strchr( buf, '\n' )) != NULL )
74 if ( (s = strchr( buf, '\t' )) == NULL )
79 int esc = 0, found = 0;
81 for ( ++s; *s && !found; s++ ) {
97 (*map)[i].f_unfriendly = strdup( buf );
98 (*map)[i].f_friendly = strdup( s );
103 (*map)[i].f_unfriendly = NULL;
106 for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
107 if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
108 return( (*map)[i].f_friendly );
115 ldap_free_friendlymap( FriendlyMap **map )
117 struct friendly* pF = *map;
122 while ( pF->f_unfriendly )
124 free( pF->f_unfriendly );
125 free( pF->f_friendly );