lib/dgr.c
/** Initialize DGR. DGR options are specified via the configuration
 * file. This function should typically be called once near the
 * beginning of a DGR program. */
Initialize DGR. DGR options are specified via the configuration
file. This function should typically be called once near the
beginning of a DGR program.
Initialize DGR . DGR options are specified via the configuration file . This function should typically be called once near the beginning of a DGR program .
void dgr_init(void)
{
	const char* mode = kuhl_config_get("dgr.mode");
	dgr_mode = 1;
	dgr_disabled = 1;
	if(dgr_list_size > 0)
		dgr_free();
	if(mode != NULL)
	{
		if(strcmp(mode, "master") == 0)
		{
			dgr_mode = 1;
			dgr_disabled = 0;
			dgr_init_master();
		}
		else if(strcmp(mode, "slave") == 0)
		{
			dgr_mode = 0;
			dgr_disabled = 0;
			dgr_init_slave();
			dgr_update(0,1); 
		}
		else if(strlen(mode) > 0)
		{
			msg(MSG_ERROR, "dgr.mode must be 'slave' or 'master' but you set it to '%s'", mode);
		}
	}
	if(dgr_disabled)
		msg(MSG_DEBUG, "DGR is disabled.\n");
	static int atexit_registered = 0;
	if(atexit_registered == 0)
	{
		atexit(dgr_exit);
		atexit_registered = 1;
	}
}
void dgr_init ( void ) { const char * mode = kuhl_config_get ( " " ) ; dgr_mode = 1 ; dgr_disabled = 1 ; if ( dgr_list_size > 0 ) dgr_free ( ) ; if ( mode != NULL ) { if ( strcmp ( mode , " " ) == 0 ) { dgr_mode = 1 ; dgr_disabled = 0 ; dgr_init_master ( ) ; } else if ( strcmp ( mode , " " ) == 0 ) { dgr_mode = 0 ; dgr_disabled = 0 ; dgr_init_slave ( ) ; dgr_update ( 0 , 1 ) ; } else if ( strlen ( mode ) > 0 ) { msg ( MSG_ERROR , " " , mode ) ; } } if ( dgr_disabled ) msg ( MSG_DEBUG , " \n " ) ; static int atexit_registered = 0 ; if ( atexit_registered == 0 ) { atexit ( dgr_exit ) ; atexit_registered = 1 ; } }
Initialize DGR.
Initialize DGR .
// if there already is a list, free it. // get anything that is already sent to us.