コード例 #1
0
UInt8List* MtpDataPacket::getAUInt8() {
    UInt8List* result = new UInt8List;
    int count = getUInt32();
    for (int i = 0; i < count; i++)
        result->push_back(getUInt8());
    return result;
}
コード例 #2
0
ファイル: MtpDataPacket.cpp プロジェクト: MIPS/frameworks-av
UInt8List* MtpDataPacket::getAUInt8() {
    uint32_t count;
    if (!getUInt32(count))
        return NULL;
    UInt8List* result = new UInt8List;
    for (uint32_t i = 0; i < count; i++) {
        uint8_t value;
        if (!getUInt8(value)) {
            delete result;
            return NULL;
        }
        result->push(value);
    }
    return result;
}
コード例 #3
0
ファイル: FUBase64.cpp プロジェクト: Marlinc/0ad
	FCOLLADA_EXPORT void encode(const UInt8List& input, UInt8List& output)
	{
		output.clear();
		if (input.size() == 0) return;

		const uint8* inputBuffer = &input.at(0);
		size_t p_inputbufferLength = input.size();

		output.resize(CalculateRecquiredEncodeOutputBufferSize(input.size()), 0);
		uint8* outputBufferString = &output.at(0);

		size_t inputBufferIndex = 0;
		size_t outputBufferIndex = 0;

		while (inputBufferIndex < p_inputbufferLength)
		{
			if (p_inputbufferLength - inputBufferIndex <= 2)
			{
				EncodeByteTriple(inputBuffer + inputBufferIndex, p_inputbufferLength - inputBufferIndex, outputBufferString + outputBufferIndex);
				break;
			}
			else
			{
				EncodeByteTriple(inputBuffer + inputBufferIndex, 3, outputBufferString + outputBufferIndex);
				inputBufferIndex += 3;
				outputBufferIndex += 4;
			}
		}
	}
コード例 #4
0
ファイル: FUBase64.cpp プロジェクト: Marlinc/0ad
	FCOLLADA_EXPORT void decode(const UInt8List& input, UInt8List& output)
	{
		size_t inputBufferIndex  = 0;
		size_t outputBufferIndex = 0;

		const uint8* inputBufferString = &input.at(0);
		size_t inputbufferLength = input.size();

		output.clear();
		output.resize(CalculateRecquiredDecodeOutputBufferSize(inputBufferString, inputbufferLength), 0);
		uint8* outputBuffer = &output.at(0);

		uint8 byteQuartet[4];

		while (inputBufferIndex < inputbufferLength)
		{
			for (int i = 0; i < 4; ++i)
			{
				byteQuartet[i] = inputBufferString[inputBufferIndex];

				// Ignore all characters except the ones in BASE64_ALPHABET
				if ((byteQuartet[i] >= 48 && byteQuartet[i] <=  57) ||
					(byteQuartet[i] >= 65 && byteQuartet[i] <=  90) ||
					(byteQuartet[i] >= 97 && byteQuartet[i] <= 122) ||
					 byteQuartet[i] == '+' || byteQuartet[i] == '/' || byteQuartet[i] == '=')
				{}
				else
				{
					// Invalid character
					--i;
				}

				++inputBufferIndex;
			}

			outputBufferIndex += DecodebyteQuartet(byteQuartet, outputBuffer + outputBufferIndex);
		}
	}