????//??????б?????????????????????????????????ú??????б???
void encode(MyBinaryString *msg?? TciValue value)
{
TciType type;
TciTypeClassType kind;
printf(" In function encode() ");
tci_assert(value != NULL?? "Illegal value");
type = tciGetType(value);
tci_assert(type != NULL?? "Illegal type");
kind = tciGetTypeClass(type);
switch(kind) {
case TCI_OCTETSTRING_TYPE:{
String ostring;
ostring = tciGetOStringValue(value);
tci_assert(ostring?? "Illegal octet string value");
/* encode octet string */
encode_octetstring(msg?? ostring);
}
break;
case TCI_RECORD_TYPE:
case TCI_SET_TYPE:
case TCI_RECORD_OF_TYPE:
case TCI_SET_OF_TYPE:
case TCI_ANYTYPE_TYPE:
case TCI_UNION_TYPE:
case TCI_UNIVERSAL_CHAR_TYPE:
case TCI_UNIVERSAL_CHARSTRING_TYPE:
case TCI_VERDICT_TYPE:
case TCI_INTEGER_TYPE:
case TCI_FLOAT_TYPE:
case TCI_CHAR_TYPE:
case TCI_BITSTRING_TYPE:
case TCI_CHARSTRING_TYPE:
case TCI_ENUMERATED_TYPE:
case TCI_ADDRESS_TYPE:
case TCI_BOOLEAN_TYPE:
case TCI_HEXSTRING_TYPE:
case TCI_OBJID_TYPE:
{
tci_assert(0?? "Unsupported type kind in Encoder");
break;
}
default:
{
tci_assert(0?? "Unkonw type kind in Encoder");
break;
}
}//end of swich
printf(" Leave function encode() ");
}
????//??????????????????????TciValue???б?????????
BinaryString tciEncode(TciValue value)
{
MyBinaryString msg;
TciType type;
unsigned long length;
int i;
printf(" In function tciEncode() ");
//initialize
msg.allocated = 0;
msg.string.data = NULL;
msg.string.bits = 0;
msg.string.aux = NULL;
//Lookups type identifier of the specified value.
//Returns the type of the specified value
//Returns NULL in case of error.
type = tciGetType(value);
tci_assert_wret(type != NULL?? "Illegal type"?? msg.string);
//start encoding
encode(&msg?? value);
printf(" In function tciEncode() Encoding finishes and we get the following result: ");
printf("code len: %ld "??msg.string.bits);
encode_printing(msg.string);
//check if encoding is successed
tci_assert(msg.string.bits%8==0?? "Encode failed: the packets length must be multiples of byte.");
printf(" Leave function tciEncode() ");
return msg.string;
}