// void AllocBlockAttributes( uint ulBlockMask); public override void AllocAttributes(uint ulBlockMask) { DDlAttribute pDDlAttr = null; if ((ulBlockMask & BLOCK_PARAM) != 0) { pDDlAttr = new DDlAttribute("BlockParams", BLOCK_PARAM_ID, DDL_ATTR_DATA_TYPE.DDL_ATTR_DATA_TYPE_MEMBER_LIST, false); attrList.Add(pDDlAttr); } }
public unsafe static int parse_attr_type_size(ref DDlAttribute pAttr, ref byte[] binChunk, uint size, uint uiOffset) { // byte *leave_pointer; /* chunk ptr for early exit */ //int rc; //byte* chunkp1 = NULL; uint *length = null; uint tag, len; /* parsed tag */ // uint typesize; /* size of tag item (2-byte int) */ UInt64 LL; TYPE_SIZE vartype; //ASSERT_DBG(binChunk && size); fixed(byte *chunkp1 = &binChunk[uiOffset]) { byte **chunkp = &chunkp1; length = &size; /*Parse the tag to know the type of the variable, as per the spec this can't be a conditional*/ Common.DDL_PARSE_TAG(chunkp, length, &tag, &len); vartype.type = (ushort)tag; switch (tag) { case Attribute.BOOLEAN_T: vartype.size = (ushort)Attribute.BOOLEAN_SIZE; break; case Attribute.INTEGER: case Attribute.UNSIGNED: /* The length of an item is encoded * with a first byte of zero, and then the following byte(s) encode the * length. If the first byte of the chunk is non-zero, then there is * no length encoded, and the default value of 1 is returned. */ if (len > *length) { return(Common.DDL_ENCODING_ERROR); } *length -= len; if ((0 == len) || (**chunkp != 0)) { vartype.size = (ushort)Attribute.DEFAULT_SIZE; } else /*Parse the length*/ { /* * Skip the zero, and parse the size. */ (*chunkp)++; (len)--; Common.DDL_PARSE_INTEGER(chunkp, &len, &LL); vartype.size = (ushort)LL; } break; case Attribute.FLOATG_PT: if (len > *length) { return(Common.DDL_ENCODING_ERROR); } *length -= len; vartype.size = (ushort)Attribute.FLOAT_SIZE; break; case Attribute.DOUBLE_FLOAT: if (len > *length) { return(Common.DDL_ENCODING_ERROR); } *length -= len; vartype.size = (ushort)Attribute.DOUBLE_SIZE; break; case Attribute.ENUMERATED: case Attribute.BIT_ENUMERATED: case Attribute.INDEX: if (len > *length) { return(Common.DDL_ENCODING_ERROR); } *length -= len; if ((0 == len) || (**chunkp) != 0) { vartype.size = (ushort)Attribute.DEFAULT_SIZE; } else /*Parse the length*/ { /* * Skip the zero, and parse the size. */ (*chunkp)++; (len)--; Common.DDL_PARSE_INTEGER(chunkp, &len, &LL); vartype.size = (ushort)LL; } break; case Attribute.ASCII: /*These four cases don't have explicit length tag for size*/ case Attribute.PACKED_ASCII: case Attribute.PASSWORD: case Attribute.BITSTRING: Common.DDL_PARSE_INTEGER(chunkp, length, &LL); vartype.size = (ushort)LL; break; case Attribute.HART_DATE_FORMAT: vartype.size = (ushort)Attribute.DATE_SIZE; break; //FF case TIME: //FF vartype.size = (ushort) TIME_SIZE; //FF break; case Attribute.TIME_VALUE: vartype.size = (ushort)Attribute.TIME_VALUE_SIZE; break; //FF case DATE_AND_TIME: //FF vartype.size = (ushort) DATE_AND_TIME_SIZE; //FF break; //FF case DURATION: /* DURATION */ //FF vartype.size = (ushort) DURATION_SIZE; //FF break; //FF case EUC: //FF DDL_PARSE_INTEGER(chunkp,length,&typesize); //FF vartype.size = (ushort)typesize; //FF break; //FF case OCTETSTRING: //TODO: These are undefined at this time //FF case VISIBLESTRING: // case BOOLEAN_T: default: return(Common.DDL_ENCODING_ERROR); //break; }/*End Switch tag*/ pAttr.pVals = new VALUES(); // PAW start debugging // pAttr->pVals->typeSize = vartype;// PAW 20/03/09 revised to stop corruption pAttr.pVals.typeSize.size = (ushort)vartype.size; pAttr.pVals.typeSize.type = (ushort)vartype.type; // PAW 20/03/09 end } return(Common.SUCCESS); } /*End parse_attr_type_size*/