Ejemplo n.º 1
0
        public void PrintCDecodeFragmentation(PEREffectiveConstraint cns, StreamWriterLevel c, string varName, int lev,
            string arrName, long max, string prefix,
            string length, string curBlockSize, string nCount)
        {
            string i = "i1";
            c.P(lev); c.WriteLine("/* Fragmentation required since {0} is grater than 64K*/", max);
            c.WriteCodeBlock(lev,
            @"if (!BitStream_DecodeConstraintWholeNumber(pBitStrm, &{1}, 0, 0xFF))
            {{
            *pErrCode = ERR_INSUFFICIENT_DATA;
            return FALSE;
            }}
            while(({1} & 0xC0)==0xC0)
            {{
            if ({1} == 0xC4)
            {2} = 0x10000;
            else if ({1} == 0xC3)
            {2} = 0xC000;
            else if ({1} == 0xC2)
            {2} = 0x8000;
            else if ({1} == 0xC1)
            {2} = 0x4000;
            else {{
            *pErrCode = ERR_INCORRECT_PER_STREAM;
            return FALSE;
            }}
            if ({3}+{2}>{4})
            {{
            *pErrCode = ERR_INSUFFICIENT_DATA;
            return FALSE;
            }}

            ", i, length, curBlockSize, nCount,max);

            //            ((ISCCSizeable)pThis).PrintCDecodeItem(cns, c, prefix + arrName + "[" + i + "]", lev + 2);

            c.P(lev+1);
            c.WriteLine("if (!BitStream_ReadBits(pBitStrm, &{0}arr[{1}/8], {2})) {{", prefix, nCount, curBlockSize);
            c.P(lev + 2);
            c.WriteLine("*pErrCode = ERR_INSUFFICIENT_DATA;");
            c.P(lev + 2);
            c.WriteLine("return FALSE;");
            c.P(lev+1);
            c.WriteLine("}");

            c.WriteCodeBlock(lev,
            @"
            {3}+={2};

            if (!BitStream_DecodeConstraintWholeNumber(pBitStrm, &{1}, 0, 0xFF)) {{
            *pErrCode = ERR_INSUFFICIENT_DATA;
            return FALSE;
            }}
            }}
            if ( ({1} & 0x80)>0)
            {{
            asn1SccSint len2=0;
            {1}<<=8;
            if (!BitStream_DecodeConstraintWholeNumber(pBitStrm, &len2, 0, 0xFF)) {{
            *pErrCode = ERR_INSUFFICIENT_DATA;
            return FALSE;
            }}
            {1} |= len2;
            {1} &= 0x7FFF;
            }}

            if ({3}+{1}>{4})
            {{
            *pErrCode = ERR_INSUFFICIENT_DATA;
            return FALSE;
            }}
            ", i, length, curBlockSize, nCount,max);
            //            ((ISCCSizeable)pThis).PrintCDecodeItem(cns, c, prefix + arrName + "[" + i + "]", lev + 1);

            c.P(lev);
            c.WriteLine("if (!BitStream_ReadBits(pBitStrm, &{0}arr[{1}/8], {2})) {{", prefix, nCount, length);
            c.P(lev + 1);
            c.WriteLine("*pErrCode = ERR_INSUFFICIENT_DATA;");
            c.P(lev + 1);
            c.WriteLine("return FALSE;");
            c.P(lev);
            c.WriteLine("}");

            c.WriteCodeBlock(lev,
            @"
            {0}+=(long){1};", nCount, length);
            c.P(lev); c.WriteLine("{0}nCount = (long){1};", prefix, nCount);
        }