예제 #1
0
void parse_ini(char* program)
{
	char section[MAX_PATH+1];

	if(ini==NULL)	/* no initialization file */
		return;

	/* Read the root section of the sbbsexec.ini file */
	log_level=iniGetLogLevel(ini,program,"LogLevel",log_level);
	if(iniGetBool(ini,program,"Debug",FALSE))
		log_level=LOG_DEBUG;
	yield_interval=iniGetFloat(ini,program,"YieldInterval",yield_interval);
	hangup_supported=iniGetBool(ini,program,"CanDisconnect",hangup_supported);

	lprintf(LOG_INFO,"Parsed %s section of %s"
		,program==ROOT_SECTION ? "root" : program
		,ini_fname);

	/* [UART] section */
	if(program==ROOT_SECTION)
		SAFECOPY(section,"UART");
	else
		SAFEPRINTF(section,"%s.UART",program);

	virtualize_uart=iniGetBool(ini,section,"Virtualize",virtualize_uart);
	switch(iniGetInteger(ini,section,"ComPort",0)) {
		case 1:	/* COM1 */
			uart_irq		=UART_COM1_IRQ;
			uart_io_base	=UART_COM1_IO_BASE;
			break;
		case 2:	/* COM2 */
			uart_irq		=UART_COM2_IRQ;
			uart_io_base	=UART_COM2_IO_BASE;
			break;
		case 3:	/* COM3 */
			uart_irq		=UART_COM3_IRQ;
			uart_io_base	=UART_COM3_IO_BASE;
			break;
		case 4:	/* COM4 */
			uart_irq		=UART_COM4_IRQ;
			uart_io_base	=UART_COM4_IO_BASE;
			break;
	}
	uart_irq=(BYTE)iniGetShortInt(ini,section,"IRQ",uart_irq);
	uart_io_base=iniGetShortInt(ini,section,"Address",uart_io_base);

	lprintf(LOG_INFO,"Parsed %s section of %s"
		,section
		,ini_fname);
}
예제 #2
0
void parse_ini_file(const char* ini_fname)
{
	FILE* fp;
	char* section;
	str_list_t	list=NULL;

	if((fp=fopen(ini_fname,"r"))!=NULL) {
		lprintf(LOG_INFO,"Reading %s",ini_fname);
		list=iniReadFile(fp);
		fclose(fp);
	}

	/* Root section */
	pause_on_exit			= iniGetBool(list,ROOT_SECTION,"PauseOnExit",FALSE);
	log_level				= iniGetLogLevel(list,ROOT_SECTION,"LogLevel",log_level);

	if(iniGetBool(list,ROOT_SECTION,"Debug",FALSE))
		log_level=LOG_DEBUG;
	
	/* [COM] Section */
	section="COM";
	iniGetExistingWord(list, section, "Device", NULL, com_dev);
	com_baudrate    = iniGetLongInt(list, section, "BaudRate", com_baudrate);
	com_hangup	    = iniGetBool(list, section, "Hangup", com_hangup);
	hangup_attempts = iniGetInteger(list, section, "HangupAttempts", hangup_attempts);
	dcd_timeout     = iniGetInteger(list, section, "DCDTimeout", dcd_timeout);
	dcd_ignore      = iniGetBool(list, section, "IgnoreDCD", dcd_ignore);
	dtr_delay		= iniGetLongInt(list, section, "DTRDelay", dtr_delay);
	mdm_null	    = iniGetBool(list, section, "NullModem", mdm_null);

	/* [Modem] Section */
	section="Modem";
	iniGetExistingWord(list, section, "Init", "", mdm_init);
	iniGetExistingWord(list, section, "AutoAnswer", "", mdm_autoans);
	iniGetExistingWord(list, section, "Cleanup", "", mdm_cleanup);
	iniGetExistingWord(list, section, "EnableCallerID", "", mdm_cid);
	iniGetExistingWord(list, section, "Answer", "", mdm_answer);
	iniGetExistingWord(list, section, "Ring", "", mdm_ring);
	mdm_timeout     = iniGetInteger(list, section, "Timeout", mdm_timeout);
	mdm_reinit		= iniGetInteger(list, section, "ReInit", mdm_reinit);
	mdm_cmdretry	= iniGetInteger(list, section, "CmdRetry", mdm_cmdretry);
	mdm_manswer		= iniGetBool(list,section,"ManualAnswer", mdm_manswer);

	/* [TCP] Section */
	section="TCP";
	iniGetExistingWord(list, section, "Host", NULL, host);
	port					= iniGetShortInt(list, section, "Port", port);
	tcp_nodelay				= iniGetBool(list,section,"NODELAY", tcp_nodelay);

	/* [Telnet] Section */
	section="Telnet";
	telnet					= iniGetBool(list,section,"Enabled", telnet);
	debug_telnet			= iniGetBool(list,section,"Debug", debug_telnet);
	telnet_advertise_cid	= iniGetBool(list,section,"AdvertiseLocation", telnet_advertise_cid);
	iniGetExistingWord(list, section, "TermType", NULL, termtype);
	iniGetExistingWord(list, section, "TermSpeed", NULL, termspeed);

	/* [Ident] Section */
	section="Ident";
	ident					= iniGetBool(list,section,"Enabled", ident);
	ident_port				= iniGetShortInt(list, section, "Port", ident_port);
	ident_interface			= iniGetIpAddress(list, section, "Interface", ident_interface);
	iniGetExistingWord(list, section, "Response", NULL, ident_response);

}