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>
27 LDAP_CONST char *filename,
28 /* LDAP_CONST */ char *uname,
29 LDAPFriendlyMap **map )
42 if ( (fp = fopen( filename, "r" )) == NULL )
46 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
52 if ( (*map = (LDAPFriendlyMap *) malloc( (entries + 1) *
53 sizeof(LDAPFriendlyMap) )) == 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].lf_unfriendly = strdup( buf );
90 (*map)[i].lf_friendly = strdup( s );
95 (*map)[i].lf_unfriendly = NULL;
98 for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) {
99 if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 )
100 return( (*map)[i].lf_friendly );
107 ldap_free_friendlymap( LDAPFriendlyMap **map )
109 LDAPFriendlyMap* pF = *map;
114 while ( pF->lf_unfriendly )
116 free( pF->lf_unfriendly );
117 free( pF->lf_friendly );