/*****************************************************************************
 * Copyright (C) Gemalto M2M GmbH
 *****************************************************************************
 * Project: IMC-RIL-Driver
 *****************************************************************************
 * Author : Wireless Modules RD SW A2
 *****************************************************************************
 * $Workfile: Y:/z_ms-d/src/working/Quinn/RilDrv/parse.h $
 * $Revision: /main/ms-d/11 $
 *     $Date: 2013-09-25 15:21:40 $
 *   $Author: pmackent $
 *****************************************************************************
 * Target:
 *  Microsoft Windows Mobile 5.0
 *****************************************************************************
 * Description:
 *  Gemalto IMC RIL
 *****************************************************************************
 *
 * $Log: Y:/z_ms-d/src/working/Quinn/RilDrv/parse.h$ 
 * 
 * /main/ms-d/11   2013-09-25 15:21:40   pmackent 
 * New methods for signal strength display in 3G networks (IPIS100091577)
 *
 * /main/ms-d/10   2013-04-12 09:21:52   pmackent
 * Adaptions for PXS8 2.910
 *
 * /main/ms-d/9   2013-03-05 11:29:53   pmackent
 * Workaround for unclear UCS2/GSM coding in +STK URC
 *
 * /main/ms-d/8   2013-01-14 10:33:46   pmackent
 * Allow update of multiple NV items
 *
 * /main/ms-d/7   2012-02-08 15:16:06   ctna0256
 * Add Intel-style SAT
 *
 * /main/ms-d/5   2008-08-22 10:25:03   ctna0256
 * Set Cinterion copyright text
 *
 * /main/ms-d/4   2008-08-21 09:35:01   ctna0256
 * Prepared for new disclaimer handling
 *
 * /main/ms-d/3   2007-01-09 14:36:09   mp49210
 * Change NITZ-URC to UCS2
 *
 * /main/ms-d/2   2006-12-29 13:09:56   mp49210
 * Workaround for upper/lower case problem with AT+CLCK
 *
 * /main/ms-d/1   2006-10-25 16:51:15   wm36264
 * First transformation from classic RIL
 *
*/

//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Gemalto M2M GmbH
// Copyright (C) 2006-2008 Siemens AG
// Copyright (C) 2003 Intrinsyc Europe Ltd.
//
// Version: 1.0
// Date:    dummy
//
//////////////////////////////////////////////////////////////////////////////

/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation
--*/

#pragma once

//
struct LISTVALUEMAP {
    UINT nValue;
    DWORD dwFlag;
};

//
//
struct LISTSTRINGMAP {
    LPCSTR szString;
    DWORD dwFlag;
};


BOOL MatchStringBeginning(const LPCSTR szString, const LPCSTR szMatch, LPCSTR& rszPointer);
BOOL MatchAltStringBeginning(const LPCSTR szString, const LPCSTR szMatch, const LPCSTR szMatchAlt, LPCSTR& rszPointer, BOOL *pWhich);
BOOL MatchStringEnd(const LPCSTR szString, const LPCSTR szMatch, LPCSTR& rszPointer);
BOOL MatchStringAnywhere(const LPCSTR szString, const LPCSTR szMatch, LPCSTR& rszPointer);
BOOL ParseUInt(const LPCSTR szData, const BOOL fLeadingZerosAllowed, UINT& rnInt, LPCSTR& rszPointer);
BOOL ParseUIntHex(const LPCSTR szData, const BOOL fLeadingZerosAllowed, UINT& rnInt, LPCSTR& rszPointer);
BOOL ParseIntAsUInt(const LPCSTR szData, UINT& rnInit, LPCSTR& rszPointer, BOOL bSkipPlusSign = FALSE);
BOOL ParseUIntAndVerifyAbove(const LPCSTR szData, const BOOL fLeadingZerosAllowed, UINT nUpperBound, UINT& rnInt, LPCSTR& rszPointer);
BOOL ParseHexUInt(const LPCSTR szData, const BOOL fLeadingZerosAllowed, UINT& rnInt, LPCSTR& rszPointer);
BOOL ParseFixedPoint(const LPCSTR szData, DWORD &rdwFixedPoint, LPCSTR& rszPointer);
BOOL ParseIntRounded(const LPCSTR szData, INT& rnInit, LPCSTR& rszPointer);
BOOL ParseString(const LPCSTR szData, const LPSTR szOut, const UINT cbOut, LPCSTR& rszPointer);
BOOL ParseUnquotedString(const LPCSTR szData, const char chDelimiter, const LPSTR szOut, const UINT cbOut, LPCSTR& rszPointer);
BOOL ParseUnlimitedUnquotedString(const LPCSTR szData, const char chDelimiter, LPSTR& rszOut, UINT& rcbOut, LPCSTR& rszPointer);
BOOL ParseRange(const LPCSTR szData, RILRANGE& rrrRange, LPCSTR& rszPointer);
BOOL ParseRangesFromString(const LPCSTR szData, RILRANGE rgrrRange[], DWORD& rdwNumRanges, DWORD dwMaxRanges, LPCSTR& rszPointer);
BOOL ParseRangeList(const LPCSTR szData, const LISTVALUEMAP* const rglvmMapArray, const UINT nMapArrayLength, DWORD& rdwMask,
                    LPCSTR& rszPointer);
BOOL ParseStringList(const LPCSTR szData, const LISTSTRINGMAP* const rglsmMapArray, const UINT nMapArrayLength, DWORD& rdwMask,
                     LPCSTR& rszPointer);
BOOL ParseRspPrefix(const LPCSTR szData, LPCSTR& rszPointer);
BOOL ParseRspPostfix(const LPCSTR szData, LPCSTR& rszPointer);
BOOL ParseRspParamSeparator(const LPCSTR szData, LPCSTR& rszPointer);
BOOL FindRspPostfix(const LPCSTR szData, LPCSTR& rszPointer);
BOOL ParseGetLocation(const LPCSTR szRsp, UINT& rnLocation, LPCSTR& rszPointer); // in msg.cpp

BOOL FlagFromValue(UINT nValue, const LISTVALUEMAP* const rglsmMapArray, const UINT nMapArrayLength, DWORD& Flag);
BOOL FlagFromString(const LPCSTR szString, const LISTSTRINGMAP* const rglsmMapArray, const UINT nMapArrayLength, DWORD& Flag);

BOOL ValueFromFlag(UINT dwFlag, const LISTVALUEMAP* const rglsmMapArray, const UINT nMapArrayLength, UINT& Value);
BOOL StringFromFlag(UINT dwFlag, const LISTSTRINGMAP* const rglsmMapArray, const UINT nMapArrayLength, LPCSTR& szString);


BOOL ParseUnlimitedString(const LPCSTR szData, LPSTR& rszOut, UINT& rcbOut, LPCSTR& rszPointer);

BOOL EncodedStringSizeToUnicodeStringSize(ENCODING_TYPE enc, size_t cbIn, size_t &cbOut);
BOOL AppendQuotedEncodedString(ENCODING_TYPE enc, LPCWSTR pwszIn, LPSTR& pszOut, const LPSTR pszOutEnd, BOOL bAllowUnicode);
BOOL ParseEncodedString(ENCODING_TYPE enc, LPCSTR pszIn, const LPCSTR pszInEnd, LPWSTR pwszOut, const LPWSTR pwszOutEnd);
BOOL ParseQuotedEncodedString(ENCODING_TYPE enc, LPCSTR& pszIn, LPWSTR pwszOut, const LPWSTR pwszOutEnd);
BOOL ParseUCS2String(const LPCSTR szData, const LPWSTR pwszOut, const UINT cbOut, LPCSTR& rszPointer);
BOOL ParseGSMString(const LPCSTR szData, const LPWSTR pwszOut, const UINT cbOut, LPCSTR& rszPointer);
#ifdef RIL_NOTIFY_NITZ
BOOL ParseSystemTimeNITZ(LPSYSTEMTIME pTime, const WCHAR *wszTime);
#endif

BOOL IsInList(const WCHAR *wszList, const char *szItem, const WCHAR *wszSep);
BOOL IsInListWCHAR(const WCHAR *wszList, const WCHAR *wszItem, const WCHAR *wszSep);

