]> git.sur5r.net Git - openldap/blob - servers/slurpd/globals.c
9c7911ffd5aa73cab0eb0e0f57dd25ca5e9fdfb8
[openldap] / servers / slurpd / globals.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright (c) 1996 Regents of the University of Michigan.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that this notice is preserved and that due credit is given
8  * to the University of Michigan at Ann Arbor. The name of the University
9  * may not be used to endorse or promote products derived from this
10  * software without specific prior written permission. This software
11  * is provided ``as is'' without express or implied warranty.
12  */
13
14 /*
15  * globals.c - initialization code for global data
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21
22 #include <ac/stdlib.h>
23 #include <ac/string.h>
24
25 #include "slurp.h"
26 #include "globals.h"
27
28 Globals          *sglob;
29
30 int ldap_syslog = 0;
31 int ldap_syslog_level = LOG_DEBUG;
32 int ldap_debug = 0;
33
34
35 /*
36  * Initialize the globals
37  */
38 Globals *
39 init_globals( void )
40 {
41     Globals *g;
42
43     g = ( Globals * ) malloc( sizeof( Globals ));
44     if ( g == NULL ) {
45         return NULL;
46     }
47
48     g->slapd_configfile = SLAPD_DEFAULT_CONFIGFILE;
49     g->no_work_interval = DEFAULT_NO_WORK_INTERVAL;
50     g->slurpd_shutdown = 0;
51     g->num_replicas = 0;
52     g->replicas = NULL;
53     g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica";
54     strcpy( g->slurpd_status_file, DEFAULT_SLURPD_STATUS_FILE );
55     g->slapd_replogfile[ 0 ] = '\0';
56     g->slurpd_replogfile[ 0 ] = '\0';
57     g->slurpd_status_file[ 0 ] = '\0';
58     g->one_shot_mode = 0;
59     g->no_detach = 0;
60     g->myname = NULL;
61     g->srpos = 0L;
62     if ( St_init( &(g->st)) < 0 ) {
63         fprintf( stderr, "Cannot initialize status data\n" );
64         exit( EXIT_FAILURE );
65     }
66     ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
67     if ( Rq_init( &(g->rq)) < 0 ) {
68         fprintf( stderr, "Cannot initialize queue\n" );
69         exit( EXIT_FAILURE );
70     }
71 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
72     g->default_srvtab = SRVTAB;
73 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
74
75     return g;
76 }