NTSTATUS MobileCodeCalulate()

in Dmf/Modules.Library/Dmf_MobileBroadband.cpp [146:186]


NTSTATUS MobileCodeCalulate(
    _In_ const wchar_t* ProviderId,
    _In_ int StartPosition, 
    _In_ int CodeLength,
    _Out_ DWORD* Result
    )
/*++

Routine Description:

    Inline function for calculate the mobile related code.

Arguments:

    ProviderId - Pointer to provider Id const wchar array.
    StartPosition - The start index from which to start calculate.
    CodeLength - The desired length of mobile code.
    Result - The three digit number result to return.

Return Value:

    NTSTATUS

    --*/
{
    DWORD result = 0;
    for (int providerIdIndex = 0; providerIdIndex < CodeLength; providerIdIndex++) 
    {
        if (ProviderId[providerIdIndex + StartPosition] >= '0' && 
            ProviderId[providerIdIndex + StartPosition] <= '9')
        {
            result = result * 10 + (ProviderId[providerIdIndex + StartPosition] - '0');
        }
        else
        {
            return STATUS_INVALID_PARAMETER;
        }
    }
    *Result = result;
    return STATUS_SUCCESS;
}