2 * Copyright (c) 1996 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
14 * args.c - process command-line arguments, and set appropriate globals.
22 #include <ac/string.h>
24 #include <ac/unistd.h>
36 fprintf( stderr, "usage: %s\t[-d debug-level] [-s syslog-level]\n", name );
37 fprintf( stderr, "\t\t[-f slapd-config-file] [-r replication-log-file]\n" );
39 fprintf( stderr, "\t\t[-t tmp-dir] [-o] [-k srvtab-file]\n" );
40 #else /* HAVE_KERBEROS */
41 fprintf( stderr, "\t\t[-t tmp-dir] [-o]\n" );
42 #endif /* HAVE_KERBEROS */
48 * Interpret argv, and fill in any appropriate globals.
60 if ( (g->myname = strrchr( argv[0], '/' )) == NULL ) {
61 g->myname = strdup( argv[0] );
63 g->myname = strdup( g->myname + 1 );
66 while ( (i = getopt( argc, argv, "hd:f:r:t:k:o" )) != EOF ) {
69 case 'd': /* turn on debugging */
70 if ( optarg[0] == '?' ) {
71 printf( "Debug levels:\n" );
72 printf( "\tLDAP_DEBUG_TRACE\t%d\n",
74 printf( "\tLDAP_DEBUG_PACKETS\t%d\n",
76 printf( "\tLDAP_DEBUG_ARGS\t\t%d\n",
78 printf( "\tLDAP_DEBUG_CONNS\t%d\n",
80 printf( "\tLDAP_DEBUG_BER\t\t%d\n",
82 printf( "\tLDAP_DEBUG_FILTER\t%d\n",
84 printf( "\tLDAP_DEBUG_CONFIG\t%d\n",
86 printf( "\tLDAP_DEBUG_ACL\t\t%d\n",
88 printf( "\tLDAP_DEBUG_ANY\t\t%d\n",
92 ldap_debug = atoi( optarg );
95 #else /* LDAP_DEBUG */
96 case 'd': /* can't enable debugging - not built with debug code */
97 fprintf( stderr, "must compile with LDAP_DEBUG for debugging\n" );
99 #endif /* LDAP_DEBUG */
100 case 'f': /* slapd config file */
101 g->slapd_configfile = strdup( optarg );
103 case 'r': /* slapd replog file */
104 strcpy( g->slapd_replogfile, optarg );
107 case 't': /* dir to use for our copies of replogs */
108 g->slurpd_rdir = strdup( optarg );
110 case 'k': /* name of kerberos srvtab file */
112 g->default_srvtab = strdup( optarg );
113 #else /* HAVE_KERBEROS */
114 fprintf( stderr, "must compile with KERBEROS to use -k option\n" );
115 #endif /* HAVE_KERBEROS */
121 g->one_shot_mode = 1;
129 if ( g->one_shot_mode && !rflag ) {
130 fprintf( stderr, "If -o flag is given, -r flag must also be given.\n" );
135 /* Set location/name of our private copy of the slapd replog file */
136 sprintf( g->slurpd_replogfile, "%s/%s", g->slurpd_rdir,
137 DEFAULT_SLURPD_REPLOGFILE );
139 /* Set location/name of the slurpd status file */
140 sprintf( g->slurpd_status_file, "%s/%s", g->slurpd_rdir,
141 DEFAULT_SLURPD_STATUS_FILE );
144 openlog( g->myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
146 openlog( g->myname, OPENLOG_OPTIONS );