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.
37 static char copyright
[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
44 ldap_friendly_name( char *filename
, char *name
, FriendlyMap
*map
)
60 if ( (fp
= fopen( filename
, "rF" )) == NULL
)
64 while ( fgets( buf
, sizeof(buf
), fp
) != NULL
) {
70 if ( (*map
= (FriendlyMap
)NSLDAPI_MALLOC( (entries
+ 1) *
71 sizeof(struct friendly
) )) == NULL
) {
77 while ( fgets( buf
, sizeof(buf
), fp
) != NULL
&& i
< entries
) {
81 if ( (s
= strchr( buf
, '\n' )) != NULL
)
84 if ( (s
= strchr( buf
, '\t' )) == NULL
)
89 int esc
= 0, found
= 0;
91 for ( ++s
; *s
&& !found
; s
++ ) {
107 (*map
)[i
].f_unfriendly
= nsldapi_strdup( buf
);
108 (*map
)[i
].f_friendly
= nsldapi_strdup( s
);
113 (*map
)[i
].f_unfriendly
= NULL
;
116 for ( i
= 0; (*map
)[i
].f_unfriendly
!= NULL
; i
++ ) {
117 if ( strcasecmp( name
, (*map
)[i
].f_unfriendly
) == 0 )
118 return( (*map
)[i
].f_friendly
);
126 ldap_free_friendlymap( FriendlyMap
*map
)
130 if ( map
== NULL
|| *map
== NULL
) {
134 for ( pF
= *map
; pF
->f_unfriendly
; pF
++ ) {
135 NSLDAPI_FREE( pF
->f_unfriendly
);
136 NSLDAPI_FREE( pF
->f_friendly
);
138 NSLDAPI_FREE( *map
);