Esempio n. 1
0
/* MAIN - Dyn DNS update entry point.*/
int inadyn_main(int argc, char* argv[])
{
	int restart = 0;
	BOOL os_handler_installed = FALSE;
	RC_TYPE rc = RC_OK;
	DYN_DNS_CLIENT *p_dyndns = NULL;

	do
	{
		/* create DYN_DNS_CLIENT object	*/
		rc = dyn_dns_construct(&p_dyndns);
		if (rc != RC_OK)
		{
			break;
		}

		/* install signal handler */
		if (!os_handler_installed)
		{
			rc = os_install_signal_handler(p_dyndns);
			if (rc != RC_OK)
			{
				logit(LOG_WARNING, MODULE_TAG  "Failed installing OS signal handler: %s", errorcode_get_name(rc));
				break;
			}
			os_handler_installed = TRUE;
		}

		rc = dyn_dns_main(p_dyndns, argc, argv);
		if (rc == RC_RESTART)
		{
			restart = 1;

			/* do some cleanup if restart requested */
			rc = dyn_dns_destruct(p_dyndns);
			if (rc != RC_OK)
			{
				logit(LOG_WARNING, MODULE_TAG "Failed cleaning up before restart: %s, ignoring...", errorcode_get_name(rc));
			}
		}
		else
		{
			/* Error, or OK.  In either case exit outer loop. */
			restart = 0;
		}
	}
	while (restart);

	if (rc != RC_OK)
	{
		logit(LOG_WARNING, MODULE_TAG "Failed %sstarting daemon: %s", restart ? "re" : "", errorcode_get_name(rc));
	}

	/* Cleanup */
	dyn_dns_destruct(p_dyndns);
	os_close_dbg_output();

	return (int)rc;
}
Esempio n. 2
0
/* MAIN - Dyn DNS update entry point.*/
int inadyn_main(int argc, char* argv[])
{
	RC_TYPE rc = RC_OK;
	DYN_DNS_CLIENT *p_dyndns = NULL;
	
	do
	{
		/* create DYN_DNS_CLIENT object	*/
		rc = dyn_dns_construct(&p_dyndns);
		if (rc != RC_OK)
		{
			break;
		}    
		rc = dyn_dns_main(p_dyndns, argc, argv);
	}
	while(0);

	/* end of program */
	if (rc != 0)
	{
		print_help_page();
		/* log error*/	
		DBG_PRINTF((LOG_WARNING,"W:" MODULE_TAG "Main: Error '%s' (0x%x).\n", errorcode_get_name(rc), rc));
	}
	
	/* destroy DYN_DNS_CLIENT object*/
	rc = dyn_dns_destruct(p_dyndns);
	if (rc != RC_OK)
	{
		DBG_PRINTF((LOG_WARNING,"W:" MODULE_TAG "Main: Error '%s' (0x%x) in dyn_dns_destruct().\n", errorcode_get_name(rc), rc));
	}
	 

	os_close_dbg_output();
	return (int) rc;

}