]> git.sur5r.net Git - openldap/blob - servers/slurpd/globals.c
lots of cleanup; few improvements; fix RDN selection bug when creating connection...
[openldap] / servers / slurpd / globals.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2004 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1996 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25 /* ACKNOWLEDGEMENTS:
26  * This work was originally developed by the University of Michigan
27  * (as part of U-MICH LDAP).
28  */
29
30 /*
31  * globals.c - initialization code for global data
32  */
33
34 #include "portable.h"
35
36 #include <stdio.h>
37
38 #include <ac/stdlib.h>
39 #include <ac/string.h>
40
41 #include "slurp.h"
42 #include "globals.h"
43
44 Globals          *sglob;
45 static Globals glob;
46
47 int ldap_syslog = 0;
48 #ifdef LOG_DEBUG
49 int ldap_syslog_level = LOG_DEBUG;
50 #else
51 int ldap_syslog_level = 0;
52 #endif
53 int ldap_debug = 0;
54
55 /*
56  * Initialize the globals
57  */
58 Globals *
59 init_globals( void )
60 {
61     Globals *g;
62
63     g = &glob;
64
65         g->wake_sds[0] = -1;
66         g->wake_sds[1] = -1;
67
68 #ifdef HAVE_NT_SERVICE_MANAGER
69     g->slapd_configfile = ".\\slapd.conf";
70     g->slurpd_rdir = ".\\replica";
71 #else
72     g->slapd_configfile = SLAPD_DEFAULT_CONFIGFILE;
73     g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica";
74 #endif
75
76     g->no_work_interval = DEFAULT_NO_WORK_INTERVAL;
77     g->slurpd_shutdown = 0;
78     g->num_replicas = 0;
79     g->replicas = NULL;
80     g->slapd_replogfile[ 0 ] = '\0';
81     g->slurpd_replogfile[ 0 ] = '\0';
82     g->slurpd_status_file[ 0 ] = '\0';
83     g->one_shot_mode = 0;
84     g->no_detach = 0;
85     g->myname = NULL;
86     g->serverName = NULL;
87     g->srpos = 0L;
88     g->version = 0;
89     if ( St_init( &(g->st)) < 0 ) {
90         fprintf( stderr, "Cannot initialize status data\n" );
91         exit( EXIT_FAILURE );
92     }
93     ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
94     if ( Rq_init( &(g->rq)) < 0 ) {
95         fprintf( stderr, "Cannot initialize queue\n" );
96         exit( EXIT_FAILURE );
97     }
98 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
99     g->default_srvtab = SRVTAB;
100 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
101
102     return g;
103 }