#include "p_apps.h"
#include "gdiconst.h"

extern PXCHAR _pCommandLine;	// set options command line

BOOLEAN _SetByteVal(PXCHAR pDst, PCCHAR cLabel, UCHAR iMax);

BOOLEAN _SetBooleanVal(PCCHAR cLabel)
{
	DCHAR iLen;

	iLen = p_strlen_c(cLabel);
	if (!p_memcmp_c2x(_pCommandLine, cLabel, iLen))
	{
		return TRUE;
	}
	return FALSE;
}

BOOLEAN SetHttpOptions(PXCHAR pCommandLine)
{
	XCHAR iVal;

	_pCommandLine = pCommandLine;

	if (Task_bSupervisor)
	{
		if (_SetBooleanVal(_cUseGKLabel))
		{
			Sys_bUseService = TRUE; 
			return TRUE;
		}

#ifdef CALL_SIP
		if (_SetBooleanVal(_cFaststartLabel))
		{
			Sys_iCallType |= FAST_START_OR; 
			return TRUE;
		}

		if (_SetBooleanVal(_cSipPrackLabel))
		{
			Sys_iCallType |= SIP_PRACK_OR; 
			return TRUE;
		}
#endif

#ifdef CALL_IAX2
		if (_SetBooleanVal(_cRemoteDialplanLabel))
		{
			Sys_iCallType |= REMOTE_DIALPLAN_OR; 
			return TRUE;
		}
#endif
	}

	if (_SetBooleanVal(_cVlan))
	{
		VLAN_bEnable = TRUE; 
		return TRUE;
	}

	if (_SetBooleanVal(_cDigitMapLabel))
	{
		Sys_bUseDigitMap = TRUE; 
		return TRUE;
	}
	if (_SetBooleanVal(_cHighrateLabel))
	{
		Dsp_iOptions |= USE_HIGH_RATE_OR;
		return TRUE;
	}
	if (_SetBooleanVal(_cVadLabel))
	{
		Dsp_iOptions |= USE_VAD_OR;
		return TRUE;
	}
	if (_SetBooleanVal(_cAgcLabel))
	{
		Dsp_iOptions |= USE_AGC_OR;
		return TRUE;
	}
	if (_SetBooleanVal(_cAecLabel))
	{
		Dsp_iOptions |= USE_AEC_OR;
		return TRUE;
	}
	if (_SetBooleanVal(_cFwdAlwaysLabel))
	{
		Sys_iForwardType |= FORWARD_ALWAYS_OR; 
		return TRUE;
	}
	if (_SetBooleanVal(_cFwdBusyLabel))
	{
		Sys_iForwardType |= FORWARD_BUSY_OR; 
		return TRUE;
	}
	if (_SetBooleanVal(_cFwdNoAnswerLabel))
	{
		Sys_iForwardType |= FORWARD_NOANSWER_OR; 
		return TRUE;
	}
	if (_SetBooleanVal(_cFwdPowerOffLabel))
	{
		Sys_iForwardType |= FORWARD_POWEROFF_OR; 
		return TRUE;
	}

	if (_SetBooleanVal(_cCallWaitingLabel))
	{
		Sys_iForwardType |= CALL_WAITING_OR; 
		return TRUE;
	}

	iVal = Sys_iTimeZone & TIMEZONE_DAYLIGHT_OR;
	if (_SetByteVal(&Sys_iTimeZone, _cTimeZoneLabel, TIME_ZONE_MAX))
	{
		Sys_iTimeZone += iVal;
		return TRUE;
	}
	if (_SetBooleanVal(_cDaylightLabel))
	{
		Sys_iTimeZone |= TIMEZONE_DAYLIGHT_OR; 
		return TRUE;
	}

	return FALSE;
}
