Back to index

openldap  2.4.31
Enumerations | Functions | Variables
config.cpp File Reference
#include "portable.h"
#include "lutil.h"
#include "back-ndb.h"
#include "config.h"

Go to the source code of this file.

Enumerations

enum  { NDB_ATLEN = 1, NDB_ATSET, NDB_INDEX, NDB_ATBLOB }

Functions

static int ndb_cf_gen (ConfigArgs *c)
int ndb_back_init_cf (BackendInfo *bi)

Variables

static ConfigDriver ndb_cf_gen
static ConfigTable ndbcfg []
static ConfigOCs ndbocs []

Enumeration Type Documentation

anonymous enum
Enumerator:
NDB_ATLEN 
NDB_ATSET 
NDB_INDEX 
NDB_ATBLOB 

Definition at line 32 of file config.cpp.


Function Documentation

Definition at line 328 of file config.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int ndb_cf_gen ( ConfigArgs c) [static]

Definition at line 130 of file config.cpp.

{
       struct ndb_info *ni = (struct ndb_info *)c->be->be_private;
       int i, rc;
       NdbAttrInfo *ai;
       NdbOcInfo *oci;
       ListNode *ln, **l2;
       struct berval bv, *bva;

       if ( c->op == SLAP_CONFIG_EMIT ) {
              char buf[BUFSIZ];
              rc = 0;
              bv.bv_val = buf;
              switch( c->type ) {
              case NDB_ATLEN:
                     if ( ni->ni_attrlens ) {
                            for ( ln = ni->ni_attrlens; ln; ln=ln->ln_next ) {
                                   ai = (NdbAttrInfo *)ln->ln_data;
                                   bv.bv_len = snprintf( buf, sizeof(buf),
                                          "%s %d", ai->na_name.bv_val,
                                                 ai->na_len );
                                   value_add_one( &c->rvalue_vals, &bv );
                            }
                     } else {
                            rc = 1;
                     }
                     break;

              case NDB_ATSET:
                     if ( ni->ni_attrsets ) {
                            char *ptr, *end = buf+sizeof(buf);
                            for ( ln = ni->ni_attrsets; ln; ln=ln->ln_next ) {
                                   oci = (NdbOcInfo *)ln->ln_data;
                                   ptr = lutil_strcopy( buf, oci->no_name.bv_val );
                                   *ptr++ = ' ';
                                   for ( i=0; i<oci->no_nattrs; i++ ) {
                                          if ( end - ptr < oci->no_attrs[i]->na_name.bv_len+1 )
                                                 break;
                                          if ( i )
                                                 *ptr++ = ',';
                                          ptr = lutil_strcopy(ptr,
                                                 oci->no_attrs[i]->na_name.bv_val );
                                   }
                                   bv.bv_len = ptr - buf;
                                   value_add_one( &c->rvalue_vals, &bv );
                            }
                     } else {
                            rc = 1;
                     }
                     break;

              case NDB_INDEX:
                     if ( ni->ni_attridxs ) {
                            for ( ln = ni->ni_attridxs; ln; ln=ln->ln_next ) {
                                   ai = (NdbAttrInfo *)ln->ln_data;
                                   value_add_one( &c->rvalue_vals, &ai->na_name );
                            }
                     } else {
                            rc = 1;
                     }
                     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 */
              rc = 0;
              switch( c->type ) {
              case NDB_INDEX:
                     if ( c->valx == -1 ) {

                            /* delete all */

                     } else {

                     }
                     break;
              }
              return rc;
       }

       switch( c->type ) {
       case NDB_ATLEN:
              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_attrlens; ln; ln = ln->ln_next ) {
                     if ( ln->ln_data == (void *)ai ) {
                            snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: attr len already set for %s",
                                   c->log, c->argv[1] );
                            Debug( LDAP_DEBUG_ANY, "%s\n", c->cr_msg, 0, 0 );
                            return -1;
                     }
              }
              ai->na_len = atoi( c->argv[2] );
              ai->na_flag |= NDB_INFO_ATLEN;
              ln = (ListNode *)ch_malloc( sizeof(ListNode));
              ln->ln_data = ai;
              ln->ln_next = NULL;
              for ( l2 = &ni->ni_attrlens; *l2; l2 = &(*l2)->ln_next );
              *l2 = ln;
              break;
              
       case NDB_INDEX:
              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_attridxs; ln; ln = ln->ln_next ) {
                     if ( ln->ln_data == (void *)ai ) {
                            snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: attr index 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_INDEX;
              ln = (ListNode *)ch_malloc( sizeof(ListNode));
              ln->ln_data = ai;
              ln->ln_next = NULL;
              for ( l2 = &ni->ni_attridxs; *l2; l2 = &(*l2)->ln_next );
              *l2 = ln;
              break;

       case NDB_ATSET:
              ber_str2bv( c->argv[1], 0, 0, &bv );
              bva = ndb_str2bvarray( c->argv[2], strlen( c->argv[2] ), ',', NULL );
              rc = ndb_aset_get( ni, &bv, bva, &oci );
              ber_bvarray_free( bva );
              if ( rc ) {
                     if ( rc == LDAP_ALREADY_EXISTS ) {
                            snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                   "%s: attrset %s already defined",
                                   c->log, c->argv[1] );
                     } else {
                            snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                   "%s: invalid attrset %s (%d)",
                                   c->log, c->argv[1], rc );
                     }
                     Debug( LDAP_DEBUG_ANY, "%s\n", c->cr_msg, 0, 0 );
                     return -1;
              }
              ln = (ListNode *)ch_malloc( sizeof(ListNode));
              ln->ln_data = oci;
              ln->ln_next = NULL;
              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;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 29 of file config.cpp.

ConfigTable ndbcfg[] [static]

Definition at line 39 of file config.cpp.

ConfigOCs ndbocs[] [static]
Initial value:
 {
       {
              "( OLcfgDbOc:6.2 "
              "NAME 'olcNdbConfig' "
              "DESC 'NDB backend configuration' "
              "SUP olcDatabaseConfig "
              "MUST ( olcDbHost $ olcDbName $ olcDbConnect ) "
              "MAY ( olcDbUser $ olcDbPass $ olcDbPort $ olcDbSocket $ "
              "olcDbFlag $ olcDbConnections $ olcNdbAttrLen $ "
              "olcDbIndex $ olcNdbAttrSet $ olcNdbAttrBlob ) )",
                     Cft_Database, ndbcfg },
       { NULL, Cft_Abstract, NULL }
}

Definition at line 115 of file config.cpp.