summary refs log tree commit diff
path: root/crypto/src/asn1/LimitedInputStream.cs
blob: 62486aa7780bf6c43862b34dffd8628d4ca633b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.IO;

using Org.BouncyCastle.Utilities.IO;

namespace Org.BouncyCastle.Asn1
{
    internal abstract class LimitedInputStream
        : BaseInputStream
    {
        protected readonly Stream _in;
		private int _limit;

        internal LimitedInputStream(
            Stream	inStream,
			int		limit)
        {
            this._in = inStream;
			this._limit = limit;
        }

	    internal virtual int GetRemaining()
	    {
	        // TODO: maybe one day this can become more accurate
	        return _limit;
	    }

		protected virtual void SetParentEofDetect(bool on)
        {
            if (_in is IndefiniteLengthInputStream)
            {
                ((IndefiniteLengthInputStream)_in).SetEofOn00(on);
            }
        }
    }
}