コード例 #1
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeBoolean(ByteStream* pByteStrm, const char* elementTag, flag* value, int *pErrCode)
{
	char tmp[256];
	flag hasExtTag = (elementTag != NULL && (strlen(elementTag)>0));
	memset(tmp, 0x0, sizeof(tmp));

	if (hasExtTag)
		if (!Xer_DecodeComplexElementStart(pByteStrm, elementTag, NULL, pErrCode))
			return FALSE;

	if (!Xer_LA_NextElementTag(pByteStrm, tmp))
		return FALSE;
	
	if (strcmp(tmp,"true")==0) {
		*value = TRUE;
		if (!Xer_DecodePrimitiveElement(pByteStrm,"true", tmp, pErrCode))
			return FALSE;
	} else {
		*value = FALSE;
		if (!Xer_DecodePrimitiveElement(pByteStrm,"false", tmp, pErrCode))
			return FALSE;
	}


	if (hasExtTag)
		if (!Xer_DecodeComplexElementEnd(pByteStrm, elementTag, pErrCode))
			return FALSE;
	return TRUE;
}
コード例 #2
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeOctetString(ByteStream* pByteStrm, const char* elementTag, byte value[], long* nCount, int *pErrCode)
{
	char tmp[1024];
	int len=0;
	int i;
	int j=0;
	memset(tmp,0x0, sizeof(tmp));
	if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode))
		return FALSE;

	len = strlen(tmp);

	for(i=0; i<len; i++) {
		if (isspace(tmp[i]))
			continue;
		tmp[j++] = tmp[i];
	}

	len = j;

	for(i=0; i<len; i++) {
		byte nibble;
		if (!CharToNibble(tmp[i], &nibble))
			return FALSE;
		if (i%2 ==0) {
			value[i/2] = nibble<<4;
		} else {
			value[i/2] |= nibble;
		}
	}
	if (nCount != NULL)
		*nCount = len/2 + len%2;

	return TRUE;
}
コード例 #3
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeReal(ByteStream* pByteStrm, const char* elementTag, double* value, int *pErrCode)
{
	char tmp[256];
	memset(tmp,0x0, sizeof(tmp));
	if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode))
		return FALSE;
	*value = atof(tmp);
	return TRUE;
}
コード例 #4
0
ファイル: xer.c プロジェクト: ttsiodras/asn1scc
flag Xer_DecodePosInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccUint* value, int *pErrCode)
{
    char tmp[256];
    memset(tmp, 0x0, sizeof(tmp));
    if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode))
        return FALSE;
    *value = strtoull(tmp, NULL, 10); 
    return TRUE;
}
コード例 #5
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeEnumerated(ByteStream* pByteStrm, const char* elementTag, char* value, int *pErrCode)
{
	char tmp[256];
	flag hasExtTag = (elementTag != NULL && (strlen(elementTag)>0));
	memset(tmp, 0x0, sizeof(tmp));

	if (hasExtTag)
		if (!Xer_DecodeComplexElementStart(pByteStrm, elementTag, NULL, pErrCode))
			return FALSE;

	if (!Xer_LA_NextElementTag(pByteStrm, value))
		return FALSE;

	if (!Xer_DecodePrimitiveElement(pByteStrm, value, tmp, pErrCode))
		return FALSE;

	if (hasExtTag)
		if (!Xer_DecodeComplexElementEnd(pByteStrm, elementTag, pErrCode))
			return FALSE;

	return TRUE;
}
コード例 #6
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeBitString(ByteStream* pByteStrm, const char* elementTag, byte value[], long* nCount, int *pErrCode)
{
	char tmp[2048];
	int len=0;
	int i;
	int bytes;
	int j=0;

	memset(tmp,0x0, sizeof(tmp));
	if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode))
		return FALSE;

	len = strlen(tmp);
	for(i=0; i<len; i++) {
		if (isspace(tmp[i]))
			continue;
		tmp[j++] = tmp[i];
	}
	len = j;

	bytes = len/8;
	if (len % 8)
		bytes++;

	memset(value, 0x0, bytes);


	for(i=0; i<len; i++) {
		byte curVal = tmp[i] - '0';
		int curBit = 7 - i%8;
		value[i/8] |= curVal<<curBit;
	}
	if (nCount != NULL)
		*nCount = len;

	return TRUE;
}
コード例 #7
0
ファイル: xer.c プロジェクト: poppe34/GRIP_STACK
flag Xer_DecodeString(ByteStream* pByteStrm, const char* elementTag, char* value, int *pErrCode)
{
	return Xer_DecodePrimitiveElement(pByteStrm, elementTag, value, pErrCode);
}