by <luca.scamoni@sys-net.it>.
#endif /* LOG_LOCAL4 */
static int check_config = 0;
+static int version = 0;
static void
usage( char *name )
"\t-t\t\tCheck configuration file and exit\n"
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
"\t-u user\t\tUser (id or name) to run as\n"
+ "\t-V\t\tprint version info (-VV only)\n"
#endif
);
}
#endif
while ( (i = getopt( argc, argv,
- "c:d:f:h:s:n:t"
+ "c:d:f:h:s:n:t:V"
#if LDAP_PF_INET6
"46"
#endif
case 't':
check_config++;
break;
+ case 'V':
+ version++;
+ break;
default:
usage( argv[0] );
ldif_debug = slap_debug;
#endif
-#ifdef NEW_LOGGING
- LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 );
-#else
- Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 );
-#endif
+ if ( version ) {
+ fprintf( stderr, "%s\n", Versionstr );
+ if ( version > 1 ) goto stop;
+ }
if( serverName == NULL ) {
if ( (serverName = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) {
openlog( serverName, OPENLOG_OPTIONS );
#endif
+#ifdef NEW_LOGGING
+ LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "%s", Versionstr, 0, 0 );
+#endif
+
if( !check_config && slapd_daemon_init( urls ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
version.c: Makefile
@-$(RM) $@
- $(MKVERSION) slurpd > $@
+ $(MKVERSION) -s -n Versionstr slurpd > $@
version.o: version.c $(OBJS) $(SLURPD_L)
g->myname = strdup( g->myname + 1 );
}
- while ( (i = getopt( argc, argv, "d:f:n:or:t:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "d:f:n:or:t:V" )) != EOF ) {
switch ( i ) {
case 'd': /* set debug level and 'do not detach' flag */
g->no_detach = 1;
snprintf(g->slurpd_rdir, sz,
"%s" LDAP_DIRSEP "replica", optarg);
} break;
+ case 'V':
+ (g->version)++;
+ break;
default:
usage( g->myname );
return( -1 );
g->myname = NULL;
g->serverName = NULL;
g->srpos = 0L;
+ g->version = 0;
if ( St_init( &(g->st)) < 0 ) {
fprintf( stderr, "Cannot initialize status data\n" );
exit( EXIT_FAILURE );
/* Default name of kerberos srvtab file */
char *default_srvtab;
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
+ /* Non-zero if we shall print the version */
+ int version;
} Globals;
#define MAIN_RETURN(x) return(x)
#endif
+#ifndef HAVE_MKVERSION
+const char Versionstr[] =
+ OPENLDAP_PACKAGE " " OPENLDAP_VERSION " Standalone LDAP Replicator (slurpd)";
+#endif
+
#ifdef HAVE_NT_SERVICE_MANAGER
void WINAPI ServiceMain( DWORD argc, LPTSTR *argv )
#else
goto stop;
}
+ if ( sglob->version ) {
+ fprintf(stderr, "%s\n", Versionstr);
+ if (sglob->version > 1 ) {
+ rc = 1;
+ goto stop;
+ }
+ }
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( SLURPD, INFO, "%s\n", Versionstr, 0, 0 );
+#else
+ Debug ( LDAP_DEBUG_ANY, "%s\n", Versionstr, 0, 0 );
+#endif
+
/*
* Read slapd config file and initialize Re (per-replica) structs.
*/
void start_lwp_scheduler LDAP_P(( void ));
#endif
+/*main.c */
+extern const char Versionstr[];
+
#endif /* _PROTO_SLURP */