2 * (c) Copyright 1992 by Panagiotis Tsirigotis
3 * (c) Sections Copyright 1998-2001 by Rob Braun
4 * All rights reserved. The file named COPYRIGHT specifies the terms
5 * and conditions for redistribution.
18 #include "internals.h" /* for enable_periodic_check() */
21 * $Id: options.c,v 1.7 2005/10/05 21:45:41 bbraun Exp $
26 char * filelog_option_arg ;
28 char * syslog_option_arg ;
30 unsigned logprocs_option_arg ;
31 int stayalive_option=0;
33 int inetd_compat = 0 ;
37 __attribute__ ((noreturn))
39 static void usage(void);
41 int opt_recognize( int argc, char *argv[] )
45 unsigned long long ullarg_1;
47 program_name = strrchr( argv[ 0 ], '/' ) ;
48 program_name = ( program_name == NULL ) ? argv[ 0 ] : program_name + 1 ;
50 for ( arg = 1 ; arg < argc ; arg++ )
51 if ( argv[ arg ][ 0 ] == '-' && argv[ arg ][ 1 ] != 0 )
53 if ( strcmp( &argv[ arg ][ 1 ], "d" ) == 0 )
55 else if ( strcmp( &argv[ arg ][ 1 ], "f" ) == 0 )
59 ps.ros.config_file = argv[ arg ];
61 else if ( strcmp( &argv[ arg ][ 1 ], "filelog" ) == 0 )
65 filelog_option_arg = ( argv[ arg ] ) ;
68 else if ( strcmp( &argv[ arg ][ 1 ], "syslog" ) == 0 )
72 syslog_option_arg = ( argv[ arg ] ) ;
75 else if ( strcmp( &argv[ arg ][ 1 ], "reuse" ) == 0 )
76 ; /* This is now a null option, kept for compatibility */
77 else if ( strcmp( &argv[ arg ][ 1 ], "limit" ) == 0 )
81 if ( parse_ull( argv[ arg ], 10, NUL, &ullarg_1 ) || ullarg_1 < 0 )
83 ps.ros.process_limit = (rlim_t)ullarg_1 ;
84 if( ps.ros.process_limit != ullarg_1 )
87 else if ( strcmp( &argv[ arg ][ 1 ], "pidfile" ) == 0 ) {
90 ps.ros.pid_file = (char *)new_string( argv[arg] );
92 else if ( strcmp( &argv[ arg ][ 1 ], "stayalive" )==0)
94 else if ( strcmp( &argv[ arg ][ 1 ], "dontfork" )==0) {
98 else if ( strcmp( &argv[ arg ][ 1 ], "logprocs" ) == 0 ) {
101 if ( parse_uint( argv[ arg ], 10, NUL, &uarg_1 ) || uarg_1 < 0 )
103 logprocs_option_arg = uarg_1 ;
104 logprocs_option = 1 ;
106 else if ( strcmp( &argv[ arg ][ 1 ], "shutdownprocs" ) == 0 )
110 Sprint(2, "The shutdownprocs option has been deprecated.\n");
112 else if ( strcmp( &argv[ arg ][ 1 ], "cc" ) == 0 ) {
115 if ( parse_int( argv[ arg ], 10, NUL, &arg_1 ) || arg_1 < 0 )
117 ps.ros.cc_interval = arg_1;
118 enable_periodic_check( arg_1 ) ;
120 else if ( strcmp( &argv[ arg ][ 1 ], "version" ) == 0 ) {
121 fprintf(stderr, "%s", program_version);
123 fprintf(stderr, " libwrap");
126 fprintf(stderr, " loadavg");
128 fprintf(stderr, "\n");
131 else if ( strcmp ( &argv[ arg ][ 1 ], "inetd_compat" ) == 0 )
137 if ( filelog_option + syslog_option > 1 )
140 if ( argc - arg != 0 )
145 static void usage(void)
147 Sprint( 2, "Usage: %s [-d] [-f config_file] [-filelog filename] [-syslog facility] [-reuse] [-limit proc_limit] [-pidfile filename] [-logprocs limit] [-shutdownprocs limit] [-cc interval]\n", program_name ) ;