]> git.sur5r.net Git - openldap/blob - servers/slurpd/globals.c
ITS#2851
[openldap] / servers / slurpd / globals.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2003 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
46 int ldap_syslog = 0;
47 #ifdef LOG_DEBUG
48 int ldap_syslog_level = LOG_DEBUG;
49 #else
50 int ldap_syslog_level = 0;
51 #endif
52 int ldap_debug = 0;
53
54 /*
55  * Initialize the globals
56  */
57 Globals *
58 init_globals( void )
59 {
60     Globals *g;
61
62     g = ( Globals * ) malloc( sizeof( Globals ));
63     if ( g == NULL ) {
64         return NULL;
65     }
66
67 #ifdef HAVE_NT_SERVICE_MANAGER
68     g->slapd_configfile = ".\\slapd.conf";
69     g->slurpd_rdir = ".\\replica";
70 #else
71     g->slapd_configfile = SLAPD_DEFAULT_CONFIGFILE;
72     g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica";
73 #endif
74     g->no_work_interval = DEFAULT_NO_WORK_INTERVAL;
75     g->slurpd_shutdown = 0;
76     g->num_replicas = 0;
77     g->replicas = NULL;
78     strcpy( g->slurpd_status_file, DEFAULT_SLURPD_STATUS_FILE );
79     g->slapd_replogfile[ 0 ] = '\0';
80     g->slurpd_replogfile[ 0 ] = '\0';
81     g->slurpd_status_file[ 0 ] = '\0';
82     g->one_shot_mode = 0;
83     g->no_detach = 0;
84     g->myname = NULL;
85     g->serverName = NULL;
86     g->srpos = 0L;
87     if ( St_init( &(g->st)) < 0 ) {
88         fprintf( stderr, "Cannot initialize status data\n" );
89         exit( EXIT_FAILURE );
90     }
91     ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
92     if ( Rq_init( &(g->rq)) < 0 ) {
93         fprintf( stderr, "Cannot initialize queue\n" );
94         exit( EXIT_FAILURE );
95     }
96 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
97     g->default_srvtab = SRVTAB;
98 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
99
100     return g;
101 }