]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
Don't include portable.h. Headers can and should assume portable.h
[openldap] / servers / slapd / configinfo.c
1 /*
2  * Copyright (c) 1995 Regents of the University of Michigan.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of Michigan at Ann Arbor. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16
17 #include <ac/string.h>
18 #include <ac/socket.h>
19
20 #include "slap.h"
21 #include "ldapconfig.h"
22
23 #if defined( SLAPD_CONFIG_DN )
24
25 extern int              nbackends;
26 extern Backend          *backends;
27 extern char             *default_referral;
28
29 /*
30  * no mutex protection in here - take our chances!
31  */
32
33 void
34 config_info( Connection *conn, Operation *op )
35 {
36         Entry           *e;
37         char            buf[BUFSIZ];
38         struct berval   val;
39         struct berval   *vals[2];
40         int             i, j;
41
42         vals[0] = &val;
43         vals[1] = NULL;
44
45         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
46         /* initialize reader/writer lock */
47         entry_rdwr_init(e);
48
49         e->e_attrs = NULL;
50         e->e_dn = strdup( SLAPD_CONFIG_DN );
51
52         for ( i = 0; i < nbackends; i++ ) {
53                 strcpy( buf, backends[i].be_type );
54                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
55                         strcat( buf, " : " );
56                         strcat( buf, backends[i].be_suffix[j] );
57                 }
58                 val.bv_val = buf;
59                 val.bv_len = strlen( buf );
60                 attr_merge( e, "database", vals );
61         }
62
63         if ( default_referral != NULL ) {
64                 strcpy( buf, default_referral );
65                 val.bv_val = buf;
66                 val.bv_len = strlen( buf );
67                 attr_merge( e, "database", vals );
68         }
69
70         send_search_entry( &backends[0], conn, op, e, NULL, 0 );
71         send_ldap_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, 1 );
72
73         entry_free( e );
74 }
75
76 #endif /* slapd_config_dn */