* June 2000 sfs Added control utilities
*/
/*---
- ldap_int_create_control
+ ldap_create_control
Internal function to create an LDAP control from the encoded BerElement.
---*/
int
-ldap_int_create_control(
- const char *requestOID,
+ldap_create_control(
+ LDAP_CONST char *requestOID,
BerElement *ber,
int iscritical,
LDAPControl **ctrlp )
return LDAP_PARAM_ERROR;
}
- if ( ber_flatten( ber, &bvalp ) == LBER_ERROR ) {
+ ctrl = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
+ if ( ctrl == NULL ) {
return LDAP_NO_MEMORY;
}
- ctrl = (LDAPControl *) LBER_MALLOC( sizeof(LDAPControl) );
- if ( ctrl == NULL ) {
- ber_bvfree( bvalp );
+ if ( ber_flatten( ber, &bvalp ) == LBER_ERROR ) {
+ LDAP_FREE( ctrl );
return LDAP_NO_MEMORY;
}
ctrl->ldctl_value = *bvalp;
- LDAP_FREE( bvalp );
+ ber_memfree( bvalp );
ctrl->ldctl_oid = LDAP_STRDUP( requestOID );
ctrl->ldctl_iscritical = iscritical;
- if ( ctrl->ldctl_oid == NULL ) {
- LBER_FREE( ctrl );
+ if ( requestOID != NULL && ctrl->ldctl_oid == NULL ) {
+ ldap_control_free( ctrl );
return LDAP_NO_MEMORY;
}
}
LDAP_CONST char *
-ldap_syntax2name( LDAP_SYNTAX * syn )
+ldap_syntax2name( LDAPSyntax * syn )
{
return( syn->syn_oid );
}
LDAP_CONST char *
-ldap_matchingrule2name( LDAP_MATCHING_RULE * mr )
+ldap_matchingrule2name( LDAPMatchingRule * mr )
{
return( choose_name( mr->mr_names, mr->mr_oid ) );
}
LDAP_CONST char *
-ldap_attributetype2name( LDAP_ATTRIBUTE_TYPE * at )
+ldap_attributetype2name( LDAPAttributeType * at )
{
return( choose_name( at->at_names, at->at_oid ) );
}
LDAP_CONST char *
-ldap_objectclass2name( LDAP_OBJECT_CLASS * oc )
+ldap_objectclass2name( LDAPObjectClass * oc )
{
return( choose_name( oc->oc_names, oc->oc_oid ) );
}
}
static int
-print_extensions(safe_string *ss, LDAP_SCHEMA_EXTENSION_ITEM **extensions)
+print_extensions(safe_string *ss, LDAPSchemaExtensionItem **extensions)
{
- LDAP_SCHEMA_EXTENSION_ITEM **ext;
+ LDAPSchemaExtensionItem **ext;
if ( extensions ) {
print_whsp(ss);
}
char *
-ldap_syntax2str( const LDAP_SYNTAX * syn )
+ldap_syntax2str( const LDAPSyntax * syn )
{
safe_string * ss;
char * retstring;
}
char *
-ldap_matchingrule2str( const LDAP_MATCHING_RULE * mr )
+ldap_matchingrule2str( const LDAPMatchingRule * mr )
{
safe_string * ss;
char * retstring;
}
char *
-ldap_objectclass2str( const LDAP_OBJECT_CLASS * oc )
+ldap_objectclass2str( const LDAPObjectClass * oc )
{
safe_string * ss;
char * retstring;
}
char *
-ldap_attributetype2str( const LDAP_ATTRIBUTE_TYPE * at )
+ldap_attributetype2str( const LDAPAttributeType * at )
{
safe_string * ss;
char * retstring;
}
static int
-add_extension(LDAP_SCHEMA_EXTENSION_ITEM ***extensions,
+add_extension(LDAPSchemaExtensionItem ***extensions,
char * name, char ** values)
{
int n;
- LDAP_SCHEMA_EXTENSION_ITEM **tmp, *ext;
+ LDAPSchemaExtensionItem **tmp, *ext;
- ext = LDAP_CALLOC(1, sizeof(LDAP_SCHEMA_EXTENSION_ITEM));
+ ext = LDAP_CALLOC(1, sizeof(LDAPSchemaExtensionItem));
if ( !ext )
return 1;
ext->lsei_name = name;
if ( !*extensions ) {
*extensions =
- LDAP_CALLOC(2, sizeof(LDAP_SCHEMA_EXTENSION_ITEM *));
+ LDAP_CALLOC(2, sizeof(LDAPSchemaExtensionItem *));
if ( !*extensions )
return 1;
n = 0;
for ( n=0; (*extensions)[n] != NULL; n++ )
;
tmp = LDAP_REALLOC(*extensions,
- (n+2)*sizeof(LDAP_SCHEMA_EXTENSION_ITEM *));
+ (n+2)*sizeof(LDAPSchemaExtensionItem *));
if ( !tmp )
return 1;
*extensions = tmp;
}
static void
-free_extensions(LDAP_SCHEMA_EXTENSION_ITEM **extensions)
+free_extensions(LDAPSchemaExtensionItem **extensions)
{
- LDAP_SCHEMA_EXTENSION_ITEM **ext;
+ LDAPSchemaExtensionItem **ext;
if ( extensions ) {
for ( ext = extensions; *ext != NULL; ext++ ) {
}
void
-ldap_syntax_free( LDAP_SYNTAX * syn )
+ldap_syntax_free( LDAPSyntax * syn )
{
LDAP_FREE(syn->syn_oid);
LDAP_VFREE(syn->syn_names);
LDAP_FREE(syn);
}
-LDAP_SYNTAX *
+LDAPSyntax *
ldap_str2syntax( const char * s, int * code, const char ** errp, const int flags )
{
int kind;
char * sval;
int seen_name = 0;
int seen_desc = 0;
- LDAP_SYNTAX * syn;
+ LDAPSyntax * syn;
char ** ext_vals;
if ( !s ) {
}
*errp = s;
- syn = LDAP_CALLOC(1,sizeof(LDAP_SYNTAX));
+ syn = LDAP_CALLOC(1,sizeof(LDAPSyntax));
if ( !syn ) {
*code = LDAP_SCHERR_OUTOFMEM;
}
void
-ldap_matchingrule_free( LDAP_MATCHING_RULE * mr )
+ldap_matchingrule_free( LDAPMatchingRule * mr )
{
LDAP_FREE(mr->mr_oid);
LDAP_VFREE(mr->mr_names);
LDAP_FREE(mr);
}
-LDAP_MATCHING_RULE *
+LDAPMatchingRule *
ldap_str2matchingrule( const char * s, int * code, const char ** errp, const int flags )
{
int kind;
int seen_desc = 0;
int seen_obsolete = 0;
int seen_syntax = 0;
- LDAP_MATCHING_RULE * mr;
+ LDAPMatchingRule * mr;
char ** ext_vals;
const char * savepos;
}
*errp = s;
- mr = LDAP_CALLOC(1,sizeof(LDAP_MATCHING_RULE));
+ mr = LDAP_CALLOC(1,sizeof(LDAPMatchingRule));
if ( !mr ) {
*code = LDAP_SCHERR_OUTOFMEM;
}
void
-ldap_attributetype_free(LDAP_ATTRIBUTE_TYPE * at)
+ldap_attributetype_free(LDAPAttributeType * at)
{
LDAP_FREE(at->at_oid);
LDAP_VFREE(at->at_names);
LDAP_FREE(at);
}
-LDAP_ATTRIBUTE_TYPE *
+LDAPAttributeType *
ldap_str2attributetype( const char * s, int * code, const char ** errp, const int flags )
{
int kind;
int seen_substr = 0;
int seen_syntax = 0;
int seen_usage = 0;
- LDAP_ATTRIBUTE_TYPE * at;
+ LDAPAttributeType * at;
char ** ext_vals;
const char * savepos;
}
*errp = s;
- at = LDAP_CALLOC(1,sizeof(LDAP_ATTRIBUTE_TYPE));
+ at = LDAP_CALLOC(1,sizeof(LDAPAttributeType));
if ( !at ) {
*code = LDAP_SCHERR_OUTOFMEM;
}
void
-ldap_objectclass_free(LDAP_OBJECT_CLASS * oc)
+ldap_objectclass_free(LDAPObjectClass * oc)
{
LDAP_FREE(oc->oc_oid);
LDAP_VFREE(oc->oc_names);
LDAP_FREE(oc);
}
-LDAP_OBJECT_CLASS *
+LDAPObjectClass *
ldap_str2objectclass( const char * s, int * code, const char ** errp, const int flags )
{
int kind;
int seen_kind = 0;
int seen_must = 0;
int seen_may = 0;
- LDAP_OBJECT_CLASS * oc;
+ LDAPObjectClass * oc;
char ** ext_vals;
const char * savepos;
}
*errp = s;
- oc = LDAP_CALLOC(1,sizeof(LDAP_OBJECT_CLASS));
+ oc = LDAP_CALLOC(1,sizeof(LDAPObjectClass));
if ( !oc ) {
*code = LDAP_SCHERR_OUTOFMEM;