1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 02:19:00 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2004-01-02 03:15:16 +08:00
|
|
|
* Copyright 1998-2004 The OpenLDAP Foundation.
|
2003-11-27 02:19:00 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2001-01-21 01:49:05 +08:00
|
|
|
*/
|
2003-11-27 02:19:00 +08:00
|
|
|
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
|
1998-08-09 08:43:13 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and that due credit is given
|
|
|
|
* to the University of Michigan at Ann Arbor. The name of the University
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission. This software
|
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
2003-11-27 02:19:00 +08:00
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was originally developed by the University of Michigan
|
|
|
|
* (as part of U-MICH LDAP).
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* globals.c - initialization code for global data
|
|
|
|
*/
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
|
|
|
|
#include <ac/stdlib.h>
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
#include <ac/string.h>
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#include "slurp.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
Globals *sglob;
|
2004-09-10 03:07:46 +08:00
|
|
|
static Globals glob;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
int ldap_syslog = 0;
|
2002-05-16 18:51:45 +08:00
|
|
|
#ifdef LOG_DEBUG
|
1998-08-09 08:43:13 +08:00
|
|
|
int ldap_syslog_level = LOG_DEBUG;
|
2002-05-16 18:51:45 +08:00
|
|
|
#else
|
|
|
|
int ldap_syslog_level = 0;
|
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
int ldap_debug = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the globals
|
|
|
|
*/
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
Globals *
|
|
|
|
init_globals( void )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
|
|
|
Globals *g;
|
|
|
|
|
2004-09-10 03:07:46 +08:00
|
|
|
g = &glob;
|
|
|
|
|
|
|
|
g->wake_sds[0] = -1;
|
|
|
|
g->wake_sds[1] = -1;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2003-03-03 19:47:16 +08:00
|
|
|
#ifdef HAVE_NT_SERVICE_MANAGER
|
|
|
|
g->slapd_configfile = ".\\slapd.conf";
|
|
|
|
g->slurpd_rdir = ".\\replica";
|
|
|
|
#else
|
1998-08-09 08:43:13 +08:00
|
|
|
g->slapd_configfile = SLAPD_DEFAULT_CONFIGFILE;
|
2003-03-03 19:47:16 +08:00
|
|
|
g->slurpd_rdir = DEFAULT_SLURPD_REPLICA_DIR "/replica";
|
|
|
|
#endif
|
2004-09-10 03:07:46 +08:00
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
g->no_work_interval = DEFAULT_NO_WORK_INTERVAL;
|
|
|
|
g->slurpd_shutdown = 0;
|
|
|
|
g->num_replicas = 0;
|
|
|
|
g->replicas = NULL;
|
|
|
|
g->slapd_replogfile[ 0 ] = '\0';
|
|
|
|
g->slurpd_replogfile[ 0 ] = '\0';
|
|
|
|
g->slurpd_status_file[ 0 ] = '\0';
|
|
|
|
g->one_shot_mode = 0;
|
1999-09-05 04:24:40 +08:00
|
|
|
g->no_detach = 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
g->myname = NULL;
|
2003-03-03 19:47:16 +08:00
|
|
|
g->serverName = NULL;
|
1998-08-09 08:43:13 +08:00
|
|
|
g->srpos = 0L;
|
2003-12-03 00:57:34 +08:00
|
|
|
g->version = 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( St_init( &(g->st)) < 0 ) {
|
|
|
|
fprintf( stderr, "Cannot initialize status data\n" );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( Rq_init( &(g->rq)) < 0 ) {
|
|
|
|
fprintf( stderr, "Cannot initialize queue\n" );
|
1999-08-04 02:14:24 +08:00
|
|
|
exit( EXIT_FAILURE );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
2000-01-09 02:42:11 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
|
1998-08-09 08:43:13 +08:00
|
|
|
g->default_srvtab = SRVTAB;
|
2000-01-09 02:42:11 +08:00
|
|
|
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
return g;
|
|
|
|
}
|