]> git.sur5r.net Git - openldap/blob - servers/slurpd/globals.c
Changes:
[openldap] / servers / slurpd / globals.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1996 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 /*
19  * globals.c - initialization code for global data
20  */
21
22 #include "portable.h"
23
24 #include <stdio.h>
25
26 #include <ac/stdlib.h>
27 #include <ac/string.h>
28
29 #include "slurp.h"
30 #include "globals.h"
31
32 Globals          *sglob;
33
34 int ldap_syslog = 0;
35 #ifdef LOG_DEBUG
36 int ldap_syslog_level = LOG_DEBUG;
37 #else
38 int ldap_syslog_level = 0;
39 #endif
40 int ldap_debug = 0;
41
42 /*
43  * Initialize the globals
44  */
45 Globals *
46 init_globals( void )
47 {
48     Globals *g;
49
50     g = ( Globals * ) malloc( sizeof( Globals ));
51     if ( g == NULL ) {
52         return NULL;
53     }
54
55 #ifdef HAVE_NT_SERVICE_MANAGER
56     g->slapd_configfile = ".\\slapd.conf";
57     g->slurpd_rdir = ".\\replica";
58 #else
59     g->slapd_configfile = SLAPD_DEFAULT_CONFIGFILE;
60     g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica";
61 #endif
62     g->no_work_interval = DEFAULT_NO_WORK_INTERVAL;
63     g->slurpd_shutdown = 0;
64     g->num_replicas = 0;
65     g->replicas = NULL;
66     strcpy( g->slurpd_status_file, DEFAULT_SLURPD_STATUS_FILE );
67     g->slapd_replogfile[ 0 ] = '\0';
68     g->slurpd_replogfile[ 0 ] = '\0';
69     g->slurpd_status_file[ 0 ] = '\0';
70     g->one_shot_mode = 0;
71     g->no_detach = 0;
72     g->myname = NULL;
73     g->serverName = NULL;
74     g->srpos = 0L;
75     if ( St_init( &(g->st)) < 0 ) {
76         fprintf( stderr, "Cannot initialize status data\n" );
77         exit( EXIT_FAILURE );
78     }
79     ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
80     if ( Rq_init( &(g->rq)) < 0 ) {
81         fprintf( stderr, "Cannot initialize queue\n" );
82         exit( EXIT_FAILURE );
83     }
84 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
85     g->default_srvtab = SRVTAB;
86 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
87
88     return g;
89 }