3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
16 #include <ac/stdlib.h>
20 #include <ac/socket.h>
21 #include <ac/string.h>
28 LDAP_CONST char *filename,
29 /* LDAP_CONST */ char *uname,
30 LDAPFriendlyMap **map )
43 if ( (fp = fopen( filename, "r" )) == NULL )
47 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
53 if ( (*map = (LDAPFriendlyMap *) LDAP_MALLOC( (entries + 1) *
54 sizeof(LDAPFriendlyMap) )) == NULL ) {
60 while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
64 if ( (s = strchr( buf, '\n' )) != NULL )
67 if ( (s = strchr( buf, '\t' )) == NULL )
72 int esc = 0, found = 0;
74 for ( ++s; *s && !found; s++ ) {
90 (*map)[i].lf_unfriendly = LDAP_STRDUP( buf );
91 (*map)[i].lf_friendly = LDAP_STRDUP( s );
96 (*map)[i].lf_unfriendly = NULL;
99 for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) {
100 if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 )
101 return( (*map)[i].lf_friendly );
108 ldap_free_friendlymap( LDAPFriendlyMap **map )
110 LDAPFriendlyMap* pF = *map;
115 while ( pF->lf_unfriendly )
117 LDAP_FREE( pF->lf_unfriendly );
118 LDAP_FREE( pF->lf_friendly );