/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2008 The OpenLDAP Foundation.
+ * Copyright 2008-2009 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
enum {
NDB_ATLEN = 1,
NDB_ATSET,
- NDB_INDEX
+ NDB_INDEX,
+ NDB_ATBLOB
};
static ConfigTable ndbcfg[] = {
"DESC 'Attribute to index' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString )", NULL, NULL },
+ { "attrblob", "attr", 2, 2, 0, ARG_MAGIC|NDB_ATBLOB,
+ (void *)ndb_cf_gen, "( OLcfgDbAt:6.12 NAME 'olcNdbAttrBlob' "
+ "DESC 'Attribute to treat as a BLOB' "
+ "EQUALITY caseIgnoreMatch "
+ "SYNTAX OMsDirectoryString )", NULL, NULL },
+ { "directory", "dir", 2, 2, 0, ARG_IGNORED,
+ NULL, "( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
+ "DESC 'Dummy keyword' "
+ "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ NULL, NULL, 0, 0, 0, ARG_IGNORED,
NULL, NULL, NULL, NULL }
};
"MUST ( olcDbHost $ olcDbName $ olcDbConnect ) "
"MAY ( olcDbUser $ olcDbPass $ olcDbPort $ olcDbSocket $ "
"olcDbFlag $ olcDbConnections $ olcNdbAttrLen $ "
- "olcDbIndex $ olcNdbAttrSet ) )",
+ "olcDbIndex $ olcNdbAttrSet $ olcNdbAttrBlob ) )",
Cft_Database, ndbcfg },
{ NULL, Cft_Abstract, NULL }
};
}
break;
+ case NDB_ATBLOB:
+ if ( ni->ni_attrblobs ) {
+ for ( ln = ni->ni_attrblobs; ln; ln=ln->ln_next ) {
+ ai = (NdbAttrInfo *)ln->ln_data;
+ value_add_one( &c->rvalue_vals, &ai->na_name );
+ }
+ } else {
+ rc = 1;
+ }
+ break;
+
}
return rc;
} else if ( c->op == LDAP_MOD_DELETE ) { /* FIXME */
switch( c->type ) {
case NDB_INDEX:
if ( c->valx == -1 ) {
- int i;
/* delete all */
case NDB_ATSET:
ber_str2bv( c->argv[1], 0, 0, &bv );
- bva = ndb_str2bvarray( c->argv[2], strlen( c->argv[2] ), ',' );
+ bva = ndb_str2bvarray( c->argv[2], strlen( c->argv[2] ), ',', NULL );
rc = ndb_aset_get( ni, &bv, bva, &oci );
- ch_free( bva );
+ ber_bvarray_free( bva );
if ( rc ) {
if ( rc == LDAP_ALREADY_EXISTS ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
for ( l2 = &ni->ni_attrsets; *l2; l2 = &(*l2)->ln_next );
*l2 = ln;
break;
+
+ case NDB_ATBLOB:
+ ber_str2bv( c->argv[1], 0, 0, &bv );
+ ai = ndb_ai_get( ni, &bv );
+ if ( !ai ) {
+ snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: invalid attr %s",
+ c->log, c->argv[1] );
+ Debug( LDAP_DEBUG_ANY, "%s\n", c->cr_msg, 0, 0 );
+ return -1;
+ }
+ for ( ln = ni->ni_attrblobs; ln; ln = ln->ln_next ) {
+ if ( ln->ln_data == (void *)ai ) {
+ snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: attr blob already set for %s",
+ c->log, c->argv[1] );
+ Debug( LDAP_DEBUG_ANY, "%s\n", c->cr_msg, 0, 0 );
+ return -1;
+ }
+ }
+ ai->na_flag |= NDB_INFO_ATBLOB;
+ ln = (ListNode *)ch_malloc( sizeof(ListNode));
+ ln->ln_data = ai;
+ ln->ln_next = NULL;
+ for ( l2 = &ni->ni_attrblobs; *l2; l2 = &(*l2)->ln_next );
+ *l2 = ln;
+ break;
+
}
return 0;
}