Ejemplo n.º 1
0
/**
 * Encodes a value to teamcode
 * @param value The value to encode
 * @param code The teamcode (pointer)
 * @param minCiffers Number of chars for the teamcode
 */
static void
NumberToTeamCode(fixed value, TCHAR *code, int minCiffers)
{
  int maxCif = 0;
  int curCif = 0;

  if (minCiffers > 0)	{
    maxCif = minCiffers - 1;
    curCif = maxCif;
  }

  fixed rest = value;
  while (positive(rest) || curCif >= 0) {
    int cifVal = (int)pow(36.0, curCif);
    int partSize = (int)(rest / cifVal);
    fixed partVal(partSize * cifVal);
    int txtPos = maxCif - curCif;

    if (partSize < 10) {
      rest -= partVal;
      code[txtPos] = (unsigned char)('0' + partSize);
      curCif--;
    } else if (partSize < 36) {
      rest -= partVal;
      code[txtPos] = (unsigned char)('A' + partSize - 10);
      curCif--;
    } else {
      curCif++;
      maxCif = curCif;
    }

    if (rest < fixed_one)
      rest = fixed_zero;
  }
}
Ejemplo n.º 2
0
CHeaderFieldPart& CWspHeaderReader::SetNewStringPartL(RHeaderField& aHeader, TInt aPartIndex, TPtrC8 aValue) const
	{
	RString partStr = iStrPool.OpenStringL(aValue);
	CleanupClosePushL(partStr);
	THTTPHdrVal partVal(partStr);
	CHeaderFieldPart& part = SetNewPartL(aHeader, aPartIndex, partVal);
	CleanupStack::PopAndDestroy(&partStr);
	return part;
	}
Ejemplo n.º 3
0
CHeaderFieldPart& CWspHeaderReader::SetFStringPartL(RHeaderField& aHeader, TInt aPartIndex, RStringF aStrVal) const
	{
	// Check if a string was found
	if( aStrVal.DesC().Length() == 0 )
		User::Leave(KErrCorrupt);

	THTTPHdrVal partVal(aStrVal);
	CHeaderFieldPart& part = SetNewPartL(aHeader, aPartIndex, partVal);
	return part;
	}
Ejemplo n.º 4
0
void CWspDefaultHdrReader::DecodeHeaderL(RHeaderField& aHeader)
	{
	// Get and store the header field name
	TPtrC8 headerField(aHeader.Name().DesC());

	// Decode the header as a text-string
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);

	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.FindF(headerField);
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		// Check that the length of the data is at least 1
		if( rawData.Length() < 1 )
			User::Leave(KErrCorrupt);

		// Check if the data is an empty string which should only have a NULL terminator
		// otherwise extract the text-string from the primitive decoder
		TUint8 firstByte = rawData[0];
		TWspPrimitiveDecoder wspDecoder(rawData);
		TPtrC8 buffer;
		if( firstByte == 0 )
			buffer.Set(KNullDesC8());
		else
			User::LeaveIfError(wspDecoder.String(buffer));

		// Create a header part from the decoded buffer and add the part to the header field
		RStringF partStr = iStrPool.OpenFStringL(buffer);
		CleanupClosePushL(partStr);
		THTTPHdrVal partVal(partStr);
		CHeaderFieldPart* part = CHeaderFieldPart::NewL(partVal);
		CleanupStack::PushL(part);
		aHeader.SetPartL(part, ii);
		CleanupStack::Pop(part);
		CleanupStack::PopAndDestroy(&partStr);

		++ii;
		startPos += (separatorPos + headerField.Length() + 1);
		} while( separatorPos != KErrNotFound );
	}
Ejemplo n.º 5
0
CHeaderFieldPart& CWspHeaderReader::SetNewDatePartL(RHeaderField& aHeader, TInt aPartIndex, TDateTime& aDate) const
	{
	THTTPHdrVal partVal(aDate);
	CHeaderFieldPart& part = SetNewPartL(aHeader, aPartIndex, partVal);
	return part;
	}
Ejemplo n.º 6
0
CHeaderFieldPart& CWspHeaderReader::SetNewIntegerPartL(RHeaderField& aHeader, TInt aPartIndex, TInt aValue) const
	{
	THTTPHdrVal partVal(aValue);
	CHeaderFieldPart& part = SetNewPartL(aHeader, aPartIndex, partVal);
	return part;
	}