]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
Clean up
[openldap] / servers / slapd / configinfo.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1995 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21
22 #include <ac/string.h>
23 #include <ac/socket.h>
24
25 #include "slap.h"
26
27 #if defined( SLAPD_CONFIG_DN )
28
29 /*
30  * no mutex protection in here - take our chances!
31  */
32
33 int
34 config_info(
35         Entry **entry, const char **text )
36 {
37         Entry           *e;
38         char            buf[BUFSIZ];
39         struct berval   val;
40         struct berval   *vals[2];
41         int             i, j;
42
43         vals[0] = &val;
44         vals[1] = NULL;
45
46         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
47
48         e->e_attrs = NULL;
49         e->e_dn = ch_strdup( SLAPD_CONFIG_DN );
50         e->e_ndn = ch_strdup( SLAPD_CONFIG_DN );
51         (void) dn_normalize( e->e_ndn );
52         e->e_private = NULL;
53
54         val.bv_val = "top";
55         val.bv_len = sizeof("top")-1;
56         attr_merge( e, "objectClass", vals );
57
58         val.bv_val = "LDAPsubentry";
59         val.bv_len = sizeof("LDAPsubentry")-1;
60         attr_merge( e, "objectClass", vals );
61
62         val.bv_val = "extensibleObject";
63         val.bv_len = sizeof("extensibleObject")-1;
64         attr_merge( e, "objectClass", vals );
65
66         {
67                 char *rdn = ch_strdup( SLAPD_CONFIG_DN );
68                 val.bv_val = strchr( rdn, '=' );
69
70                 if( val.bv_val != NULL ) {
71                         *val.bv_val = '\0';
72                         val.bv_len = strlen( ++val.bv_val );
73
74                         attr_merge( e, rdn, vals );
75                 }
76
77                 free( rdn );
78         }
79
80         for ( i = 0; i < nbackends; i++ ) {
81                 strcpy( buf, backends[i].be_type );
82                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
83                         strcat( buf, " : " );
84                         strcat( buf, backends[i].be_suffix[j] );
85                 }
86                 val.bv_val = buf;
87                 val.bv_len = strlen( buf );
88                 attr_merge( e, "database", vals );
89         }
90
91         *entry = e;
92         return LDAP_SUCCESS;
93 }
94
95 #endif /* slapd_config_dn */