2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
5 #pragma ident "%Z%%M% %I% %E% SMI"
8 * The contents of this file are subject to the Netscape Public
9 * License Version 1.1 (the "License"); you may not use this file
10 * except in compliance with the License. You may obtain a copy of
11 * the License at http://www.mozilla.org/NPL/
13 * Software distributed under the License is distributed on an "AS
14 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 * implied. See the License for the specific language governing
16 * rights and limitations under the License.
18 * The Original Code is Mozilla Communicator client code, released
21 * The Initial Developer of the Original Code is Netscape
22 * Communications Corporation. Portions created by Netscape are
23 * Copyright (C) 1998-1999 Netscape Communications Corporation. All
29 * Copyright (c) 1990 Regents of the University of Michigan.
30 * All rights reserved.
38 static char copyright
[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
46 ldap_friendly_name( char *filename
, char *name
, FriendlyMap
*map
)
62 if ( (fp
= fopen( filename
, "rF" )) == NULL
)
66 while ( fgets( buf
, sizeof(buf
), fp
) != NULL
) {
72 if ( (*map
= (FriendlyMap
)NSLDAPI_MALLOC( (entries
+ 1) *
73 sizeof(struct friendly
) )) == NULL
) {
79 while ( fgets( buf
, sizeof(buf
), fp
) != NULL
&& i
< entries
) {
83 if ( (s
= strchr( buf
, '\n' )) != NULL
)
86 if ( (s
= strchr( buf
, '\t' )) == NULL
)
91 int esc
= 0, found
= 0;
93 for ( ++s
; *s
&& !found
; s
++ ) {
109 (*map
)[i
].f_unfriendly
= nsldapi_strdup( buf
);
110 (*map
)[i
].f_friendly
= nsldapi_strdup( s
);
115 (*map
)[i
].f_unfriendly
= NULL
;
118 for ( i
= 0; (*map
)[i
].f_unfriendly
!= NULL
; i
++ ) {
119 if ( strcasecmp( name
, (*map
)[i
].f_unfriendly
) == 0 )
120 return( (*map
)[i
].f_friendly
);
128 ldap_free_friendlymap( FriendlyMap
*map
)
132 if ( map
== NULL
|| *map
== NULL
) {
136 for ( pF
= *map
; pF
->f_unfriendly
; pF
++ ) {
137 NSLDAPI_FREE( pF
->f_unfriendly
);
138 NSLDAPI_FREE( pF
->f_friendly
);
140 NSLDAPI_FREE( *map
);