/*-------------------------------------------------------------------------
   Options function copy right information

   Copyright (C) 2006-2008. Lin, Rongrong <woody@palmmicro.com>
                            Tang, Li      <tangli@palmmicro.com>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This software is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-------------------------------------------------------------------------*/

#include "type.h"
#include "ar168.h"
#include "core.h"
#include "apps.h"

UCHAR Sys_pMacAddress[HW_ALEN];			// mac address, 6 bytes
UCHAR Sys_iIpType;						// ip type, 1 byte 0[static] 1[dhcp]
UCHAR Sys_pIpAddress[IP_ALEN];			// ip address, 4 bytes
UCHAR Sys_pSubnetMask[IP_ALEN];			// subnet mask, 4 bytes
UCHAR Sys_pRouterIp[IP_ALEN];			// router ip, 4 bytes
UCHAR Sys_pDnsIp[IP_ALEN];				// dns ip, 4 bytes
UCHAR Sys_pDnsIp2[IP_ALEN];				// dns ip 2, 4 bytes
UCHAR Sys_pLogIp[IP_ALEN];				// sys log ip, 4 bytes
BOOLEAN Sys_bRegister;
UCHAR Sys_iIlbcFrame;
UCHAR Sys_iSpeakerVol;
UCHAR Sys_iHandsetVol;

void OptionsGetString(PCHAR pStr, USHORT sOffset, UCHAR iMaxLen)
{
	UCHAR iLen;

	iLen = iMaxLen - 1;
	OptionsGetBuf(pStr, sOffset, iLen);
	pStr[iLen] = 0;
}

USHORT OptionsGetShort(USHORT sOffset)
{
	UCHAR pBuf[2];

	OptionsGetBuf(pBuf, sOffset, 2);
	return PCHAR2USHORT(pBuf);
}

void OptionsWriteBuf(PCHAR pBuf, USHORT sOffset, UCHAR iLen)
{
	UCHAR pData[255];
	if (iLen)
	{
		memcpy(pData, pBuf, iLen);
		BufSeek(sOffset);
		BufWrite(pData, iLen);
	}
}

void OptionsWriteByte(USHORT sOffset, UCHAR iVal)
{
	BufSeek(sOffset);
	BufWrite(&iVal, 1);
}
