[NeoStats-Devel] [Commits] r2728 - trunk/src
[email protected] Sun, 14 Aug 2005 08:32:17 +1000
| Newsgroups | gmane.comp.neostats.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: Mark
Date: Sun Aug 14 06:32:14 2005
New Revision: 2728
Modified:
trunk/src/conf.c
trunk/src/main.c
Log:
remove printf outputs in Win32
Modified: trunk/src/conf.c
==============================================================================
--- trunk/src/conf.c (original)
+++ trunk/src/conf.c Sun Aug 14 06:32:14 2005
@@ -45,7 +45,6 @@
static void *load_mods[NUM_MODULES];
static void cb_module( char *name );
-static void set_config_values( cfg_t *cfg );
static int cb_verify_chan( cfg_t *cfg, cfg_opt_t *opt );
static int cb_verify_numeric( cfg_t *cfg, cfg_opt_t *opt );
static int cb_verify_bind( cfg_t *cfg, cfg_opt_t *opt );
@@ -131,54 +130,49 @@
{"Modules|ModuleName", &cb_verify_file}
};
-/** @brief Load configuration file
+/** @brief ConfParseError
*
- * Parses the configuration file
+ * Report configuration parse error
*
- * @returns nothing
+ * @param err error value from parse
+ *
+ * @return none
*/
-int ConfLoad( void )
+static void ConfParseError( int err )
{
- cfg_t *cfg;
- int i, ret;
-
- /* Read in the Config File */
- printf ("Reading the Config File. Please wait ...\n");
- cfg = cfg_init (fileconfig, CFGF_NOCASE);
- for (i = 0; i < ARRAYLEN (arg_validate); i++) {
- cfg_set_validate_func (cfg, arg_validate[i].name, arg_validate[i].cb);
- }
- if ((ret = cfg_parse (cfg, CONFIG_NAME)) != 0) {
- printf ("***************************************************\n");
- printf ("* Error! *\n");
- printf ("* *\n");
- switch (ret) {
+#ifndef WIN32
+ printf( "***************************************************\n" );
+ printf( "* Error! *\n" );
+ printf( "* *\n" );
+ switch( err )
+ {
case CFG_FILE_ERROR:
- printf ("* Config file not found *\n");
+ printf( "* Config file not found *\n" );
break;
case CFG_PARSE_ERROR:
- printf ("* Config Parse Error *\n");
+ printf( "* Config Parse Error *\n" );
break;
default:
- printf ("* Unknown Error *\n");
+ printf( "* Unknown Error *\n" );
break;
- }
- printf ("* *\n");
- printf ("* NeoStats NOT Started *\n");
- printf ("***************************************************\n");
- cfg_free (cfg);
- return NS_FAILURE;
}
- set_config_values (cfg);
- cfg_free (cfg);
- printf ("Sucessfully loaded config file, booting NeoStats\n");
- printf ("If NeoStats does not connect, please check logs/neostats-<date>.log for further information\n");
- return NS_SUCCESS;
+ printf ( "* *\n" );
+ printf ( "* NeoStats NOT Started *\n" );
+ printf ( "***************************************************\n" );
+#endif /* WIN32 */
}
-void
-set_config_values (cfg_t *cfg)
+/** @brief set_config_values
+ *
+ * set initial NeoStats config based on config file
+ *
+ * @param cfg pointer to config struct
+ *
+ * @return NS_SUCCESS or NS_FAILURE
+ */
+
+static int set_config_values( cfg_t *cfg )
{
int i;
/* Server name has a default */
@@ -261,6 +255,41 @@
dlog( DEBUG6, "-----------------------------------------------" );
}
+/** @brief ConfLoad
+ *
+ * Load and parse configuration file
+ *
+ * @param none
+ *
+ * @return NS_SUCCESS or NS_FAILURE
+ */
+
+int ConfLoad( void )
+{
+ cfg_t *cfg;
+ int i, ret;
+
+#ifndef WIN32
+ printf( "Reading the Config File. Please wait ...\n" );
+#endif /* WIN32 */
+ cfg = cfg_init (fileconfig, CFGF_NOCASE);
+ for( i = 0; i < ARRAYLEN (arg_validate); i++ )
+ cfg_set_validate_func (cfg, arg_validate[i].name, arg_validate[i].cb);
+ if( ( ret = cfg_parse( cfg, CONFIG_NAME ) ) != 0 )
+ {
+ ConfParseError( ret );
+ cfg_free( cfg );
+ return NS_FAILURE;
+ }
+ set_config_values( cfg );
+ cfg_free( cfg );
+#ifndef WIN32
+ printf( "Sucessfully loaded config file, booting NeoStats\n" );
+ printf( "If NeoStats does not connect, please check logs/neostats-<date>.log for further information\n" );
+#endif /* WIN32 */
+ return NS_SUCCESS;
+}
+
/** @brief ConfLoadModules
*
* Load the modules that selected by the configuration file
@@ -305,7 +334,7 @@
* @return none
*/
-int cb_verify_chan( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_chan( cfg_t *cfg, cfg_opt_t *opt )
{
if( ValidateChannel( opt->values[0]->string ) == NS_FAILURE )
{
@@ -325,7 +354,7 @@
* @return none
*/
-int cb_verify_numeric( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_numeric( cfg_t *cfg, cfg_opt_t *opt )
{
long int num = opt->values[0]->number;
@@ -347,7 +376,7 @@
* @return none
*/
-int cb_verify_bind( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_bind( cfg_t *cfg, cfg_opt_t *opt )
{
OS_SOCKET s;
struct hostent *hp;
@@ -388,7 +417,7 @@
* @return none
*/
-int cb_verify_file( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_file( cfg_t *cfg, cfg_opt_t *opt )
{
char *file = opt->values[0]->string;
static char buf[MAXPATH];
@@ -426,7 +455,7 @@
* @return none
*/
-int cb_verify_log( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_log( cfg_t *cfg, cfg_opt_t *opt )
{
return CFG_SUCCESS;
}
@@ -441,7 +470,7 @@
* @return none
*/
-int cb_verify_mask( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_mask( cfg_t *cfg, cfg_opt_t *opt )
{
char *value = opt->values[0]->string;
if( strstr( value, "!" ) && !strstr( value, "@" ) )
@@ -462,7 +491,7 @@
* @return none
*/
-int cb_noload( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_noload( cfg_t *cfg, cfg_opt_t *opt )
{
if( opt->values[0]->boolean == cfg_true )
{
@@ -482,7 +511,7 @@
* @return none
*/
-int cb_verify_host( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_host( cfg_t *cfg, cfg_opt_t *opt )
{
if( ValidateHost( opt->values[0]->string ) == NS_FAILURE )
{
@@ -502,7 +531,7 @@
* @return none
*/
-int cb_verify_settime( cfg_t *cfg, cfg_opt_t *opt )
+static int cb_verify_settime( cfg_t *cfg, cfg_opt_t *opt )
{
long int time = opt->values[0]->number;
@@ -523,7 +552,7 @@
* @return none
*/
-void cb_module( char *name )
+static void cb_module( char *name )
{
int i;
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Sun Aug 14 06:32:14 2005
@@ -105,10 +105,12 @@
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%lu", (long)me.now);
}
+#ifndef WIN32
/** @brief get_options
*
* Processes command line options
* NeoStats core use only.
+ * Not used in Win32.
*
* @param argc count of command line parameters
* @param argv array of command line parameters
@@ -116,7 +118,6 @@
* @return NS_SUCCESS if succeeds, NS_FAILURE if not
*/
-#ifndef WIN32
static int get_options( int argc, char **argv )
{
int c;
@@ -171,7 +172,7 @@
/** @brief InitMe
*
- * init me structure
+ * init me structure and set pre config defaults
* NeoStats core use only.
*
* @param none
@@ -181,7 +182,6 @@
static int InitMe( void )
{
- /* set some defaults before we parse the config file */
os_memset( &me, 0, sizeof( me ) );
/* initialise version */
strlcpy( me.version, NEOSTATS_VERSION, VERSIONSIZE );
@@ -291,10 +291,12 @@
FiniIrcd();
}
-/** @brief InitCore
+#ifndef WIN32
+/** @brief print_copyright
*
* print copyright notice
* NeoStats core use only.
+ * Not used on Win32
*
* @param none
*
@@ -310,6 +312,7 @@
printf( "Mark Hetherington ([email protected])\n" );
printf( "-----------------------------------------------\n\n" );
}
+#endif /* !WIN32 */
/** @brief main
*
@@ -338,6 +341,11 @@
/* get our commandline options */
if( get_options( argc, argv ) != NS_SUCCESS )
return EXIT_FAILURE;
+ /* keep quiet if we are told to : ) */
+ if( !nsconfig.quiet )
+ print_copyright();
+ /* make sure any files we create are not group/world readable (password info?) */
+ umask(077);
#endif /* !WIN32 */
#if 0
/* Change to the working Directory */
@@ -349,11 +357,6 @@
}
#endif
-#ifndef WIN32
- /* make sure any files we create are not group/world readable (password info?) */
- umask(077);
-#endif
-
/* Init run level to NeoStats core */
RunModule[0] = &ns_module;
/* before we do anything, make sure logging is setup */
@@ -361,9 +364,6 @@
return EXIT_FAILURE;
/* our crash trace variables */
SET_SEGV_LOCATION();
- /* keep quiet if we are told to : ) */
- if( !nsconfig.quiet )
- print_copyright();
/* init the major subsystems and config first */
/* prepare to catch errors */
InitSignals();
@@ -376,6 +376,8 @@
/* initialize Lang Subsystem */
ircsnprintf( dbpath, MAXPATH, "%s/data/lang.db", NEO_PREFIX );
LANGinit( 1, dbpath, NULL );
+#endif /* !WIN32 */
+#ifndef WIN32
#ifndef DEBUG
/* if we are compiled with debug, or forground switch was specified, DONT FORK */
if( !nsconfig.foreground )
@@ -450,7 +452,7 @@
InitUpdate();
Connect();
#ifdef WIN32
- return 0;
+ return EXIT_SUCCESS;
#else /* WIN32 */
do_reconnect();
/* We should never reach here but the compiler does not realise and may
@@ -472,12 +474,10 @@
*/
static void do_reconnect( void )
{
- if( nsconfig.r_time > 0 ) {
+ if( nsconfig.r_time > 0 )
nlog( LOG_NOTICE, "Reconnecting to the server in %d seconds (Attempt %i)", nsconfig.r_time, attempts );
- }
- else {
+ else
nlog( LOG_NOTICE, "Reconnect time is zero, shutting down" );
- }
do_exit( NS_EXIT_RECONNECT, NULL );
}