/*
* Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1994 Regents of the University of Michigan.
* All rights reserved.
*
* getdn.c
*/
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h> /* malloc(), realloc(), calloc() for Solaris */
#ifdef MACOS
#include <stdlib.h>
#include "macos.h"
#else /* MACOS */
#include <malloc.h>
#include "msdos.h"
#else /* DOS */
#endif /* DOS */
#endif /* MACOS */
#include "lber.h"
#include "ldap.h"
#include "ldap-private.h"
#include "ldap-int.h"
char *
{
char *dn;
return( NULL );
}
return( NULL );
}
return( dn );
}
char *
{
char *p, *ufn, *r;
int state;
switch ( *p ) {
case '\\':
if ( *++p == '\0' )
p--;
else {
*r++ = '\\';
*r++ = *p;
}
break;
case '"':
else
*r++ = *p;
break;
case ';':
case ',':
*r++ = ',';
else
*r++ = *p;
break;
case '=':
*r++ = *p;
else {
char *rsave = r;
*r-- = '\0';
while ( !isspace( *r ) && *r != ';'
&& *r != ',' && r > ufn )
r--;
r++;
if ( strcasecmp( r, "c" )
&& strcasecmp( r, "o" )
&& strcasecmp( r, "ou" )
&& strcasecmp( r, "st" )
&& strcasecmp( r, "l" )
&& strcasecmp( r, "cn" ) ) {
r = rsave;
*r++ = '=';
}
}
break;
default:
*r++ = *p;
break;
}
}
*r = '\0';
return( ufn );
}
char **
{
char *s;
char **rdns;
return( NULL );
}
maxcomps = 8;
ncomps = 0;
maxcomps *= 2;
sizeof(char *) )) == NULL ) {
return( NULL );
}
}
}
return( rdns );
}
char **
{
if ( ldap_is_dns_dn( dn ) ) {
return( ldap_explode_dns( dn ) );
}
p = dn-1;
do {
++p;
switch ( *p ) {
case '\\':
if ( *++p == '\0' )
p--;
break;
case '"':
else
break;
case ';':
case ',':
case '\0':
++count;
* sizeof( char *))) == NULL )
return( NULL );
} else if ( count >= 8 ) {
(count+1) * sizeof( char *)))
== NULL )
return( NULL );
}
endquote = 0;
if ( notypes ) {
for ( q = rdnstart;
q < p && *q != '='; ++q ) {
;
}
if ( q < p ) {
rdnstart = ++q;
}
if ( *rdnstart == '"' ) {
++rdnstart;
}
if ( *(p-1) == '"' ) {
endquote = 1;
--p;
}
}
len );
}
/*
* Don't forget to increment 'p' back to where
* it should be. If we don't, then we will
* never get past an "end quote."
*/
if ( endquote == 1 )
p++;
rdnstart = *p ? p + 1 : p;
++rdnstart;
}
break;
}
} while ( *p );
return( rdns );
}
int
{
}
char *strdup( char *s )
{
char *p;
return( NULL );
strcpy( p, s );
return( p );
}
#endif /* ultrix */
/*
* Convert a DNS domain name into an X.500 distinguished name.
* For example, "sales.wiz.com" -> "dc=sales,dc=wiz,dc=com"
*
* If an error is encountered zero is returned, otherwise a string
* distinguished name and the number of nameparts is returned.
* The caller should free the returned string if it is non-zero.
*/
char *
char *dns_name,
int *nameparts
)
{
char *dn = 0;
char *cp;
/* check for NULL string, empty name and name ending in '.' */
*nameparts = 0;
while (*dns_name) {
*cp++ = 'd';
*cp++ = 'c';
*cp++ = '=';
}
if (*dns_name == '.') {
dns_name++;
*cp++ = ',';
}
(*nameparts)++;
}
*cp = '\0';
}
}
return (dn);
}
char **
{
p = rdn-1;
do {
++p;
switch ( *p ) {
case '\\':
if ( *++p == '\0' )
p--;
break;
case '"':
else
break;
case '+':
case '\0':
++count;
return( NULL );
} else if ( count >= 8 ) {
(count+1) * sizeof( char *)))
== NULL )
return( NULL );
}
endquote = 0;
if ( notypes ) {
for ( q = rdnstart;
q < p && *q != '='; ++q ) {
;
}
if ( q < p ) {
rdnstart = ++q;
}
if ( *rdnstart == '"' ) {
++rdnstart;
}
if ( *(p-1) == '"' ) {
endquote = 1;
--p;
}
}
len );
}
/*
* Don't forget to increment 'p' back to where
* it should be. If we don't, then we will
* never get past an "end quote."
*/
if ( endquote == 1 )
p++;
rdnstart = *p ? p + 1 : p;
++rdnstart;
}
break;
}
} while ( *p );
return( rdncomps );
}