Exemplo n.º 1
0
 public List<String> StripLines(InputStream text) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] chunk = new byte[8192];
    int count = 0;
    while ((count = text.read(chunk)) != -1) {
       out.write(chunk, 0, count);
    }
 public override object Deserialize(Stream inputStream)
 {
     Initialize();
     var input = new InputStream(inputStream);
     var reader = new CompactBinaryReader<InputStream>(input);
     return _deserializerStream.Deserialize(reader);
 }
Exemplo n.º 3
0
 public static void Main(string[] args)
 {
     InputStream input = new InputStream("source.c");
     BytecodeStream output = new BytecodeStream();
     Compiler compiler = new Compiler();
     compiler.Compile(input, output);
 }
Exemplo n.º 4
0
        public void Init(IStreamHost host)
        {
            this.host = host;
            this.image = host.CreateInputStream<ImageStream>("Stream In");

            this.width = host.CreateOutput<int>("Output 1");
        }
Exemplo n.º 5
0
        public void Init(IStreamHost host)
        {
            this.host = host;
            this.i1 = host.CreateInputStream<DoubleStream>("Stream In");

            this.o1 = host.CreateOutput<double>("Output 1");
        }
Exemplo n.º 6
0
 public override object Deserialize(Stream stream)
 {
     var input = new InputStream(stream);
     var reader = new CompactBinaryReader<InputStream>(input);
     return Bond.Deserialize<object>.From(reader);
     //return _deserializer.Deserialize(reader);
 }
 public void WriteData_NoWindowUpdate()
 {
     int invokeCount = 0;
     InputStream input = new InputStream(100, delta => { invokeCount++; });
     input.Write(new byte[50], 0, 50);
     Assert.Equal(0, invokeCount);
 }
Exemplo n.º 8
0
        private static string convertStreamToString(InputStream @is)
        {

            BufferedReader reader = new BufferedReader(new InputStreamReader(@is));
            StringBuilder sb = new StringBuilder();

            string line = null;
            try
            {
                while ((line = reader.ReadLine()) != null)
                {
                    sb.Append((line + "\n"));
                }
            }
            catch (IOException e)
            {
                Log.W("LOG", e.GetMessage());
            }
            finally
            {
                try
                {
                    @is.Close();
                }
                catch (IOException e)
                {
                    Log.W("LOG", e.GetMessage());
                }
            }
            return sb.ToString();
        }
Exemplo n.º 9
0
 public SslTransportHandler(ITransportLayerHandler next, IServerParameters serverParameters)
 {
     _next = next;
     _serverParameters = serverParameters;
     _inputStream = new InputStream(this);
     next.Callback = this;
 }
Exemplo n.º 10
0
 public SslTransportHandler(ITransportLayerHandler next, X509Certificate serverCertificate)
 {
     _next = next;
     _serverCertificate = serverCertificate;
     _inputStream = new InputStream(this);
     next.Callback = this;
 }
 public override object Deserialize(Stream inputStream)
 {
     Initialize();
     inputStream.Seek(0, SeekOrigin.Begin);
     var input = new InputStream(inputStream);
     var reader = new FastBinaryReader<InputStream>(input);
     return _deserializerStream.Deserialize(reader);
 }
Exemplo n.º 12
0
        public void Init(IStreamHost host)
        {
            this.host = host;
            this.image = host.CreateInputStream<ImageStream>("Stream In");

            this.frm = new Form();
            this.frm.Show();
            frm.Paint += new PaintEventHandler(frm_Paint);
        }
Exemplo n.º 13
0
 public SslTransportHandler(ITransportLayerHandler next, X509Certificate serverCertificate, SslProtocols protocols, bool clientCertificateRequired)
 {
     _protocols = protocols;
     _clientCertificateRequired = clientCertificateRequired;
     _next = next;
     _serverCertificate = serverCertificate;
     _inputStream = new InputStream(this);
     next.Callback = this;
 }
        public void WriteMoreThanCreditedData_NoException()
        {
            int invokeCount = 0;
            InputStream input = new InputStream(50, delta => { invokeCount++; });
            input.Write(new byte[100], 0, 100);
            Assert.Equal(0, invokeCount);

            int read = input.Read(new byte[1000], 0, 1000);
            Assert.Equal(100, read);
        }
Exemplo n.º 15
0
    public void CreateGhostObject(InputStream input)
    {
        // Create Ghost
        Transform p = (Transform)Instantiate(ghost, transform.localPosition, transform.localRotation);
        p.parent = GameObject.Find("/Ghosts").transform;
        p.gameObject.layer = LayerMask.NameToLayer("Ghost");

        InputStreamReaderWriter control = p.GetComponent<InputStreamReaderWriter>();
        control.input = input;
    }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a <code>PushbackInputStream</code>
 /// with a pushback buffer of the specified <code>size</code>,
 /// and saves its  argument, the input stream
 /// <code>in</code>, for later use.
 /// </summary>
 /// <remarks>
 /// Creates a <code>PushbackInputStream</code>
 /// with a pushback buffer of the specified <code>size</code>,
 /// and saves its  argument, the input stream
 /// <code>in</code>, for later use. Initially,
 /// there is no pushed-back byte  (the field
 /// <code>pushBack</code> is initialized to
 /// <code>-1</code>).
 /// </remarks>
 /// <param name="in">the input stream from which bytes will be read.</param>
 /// <param name="size">the size of the pushback buffer.</param>
 /// <exception>
 /// IllegalArgumentException
 /// if size is &lt;= 0
 /// </exception>
 /// <since>JDK1.1</since>
 public PushbackInputStream(InputStream @in, int size)
     : base(@in)
 {
     if (size <= 0)
     {
         throw new System.ArgumentException("size <= 0");
     }
     this.buf = new byte[size];
     this.pos = size;
 }
Exemplo n.º 17
0
    private void AddGhostData(InputStream input)
    {
        if(input == null
            || input.Count == 0)
        {
            return;
        }

        input.Trim();
        ghostData.Add(input);
    }
Exemplo n.º 18
0
		public override InputStream TryRead(InputStream stream, out LexicToken token)
		{
			token = null;
			Match match = regex.Match(stream.Content);
			if (match.Success)
			{
				token = GetToken(match.Value);
				return stream.Move(match.Value.Length);
			}
			return stream;
		}
Exemplo n.º 19
0
        public void Init(IStreamHost host)
        {
            this.host = host;
            this.testinputstream = host.CreateInputStream<IBaseStream>("Stream In");
            this.testoutputstream = host.CreateOutputStream<IBaseStream>("Stream Out");

            this.p1 = host.CreateParameter<double>("Param 1");
            this.p2 = host.CreateParameter<double>("Param 2");

            this.testoutdata = host.CreateOutput<double>("Out 1");
        }
        public void WriteAndReadData_WindowUpdate()
        {
            int invokeCount = 0;
            int aggregate = 0;
            InputStream input = new InputStream(100, delta => { invokeCount++; aggregate += delta; });

            input.Write(new byte[50], 0, 50);
            int read = input.Read(new byte[10], 0, 10);
            Assert.Equal(1, invokeCount);
            Assert.Equal(read, aggregate);
            Assert.Equal(10, aggregate);
        }
Exemplo n.º 21
0
        public override InputStream TryRead(InputStream stream, out LexicToken token)
        {
            token = null;

            if (stream.Content.StartsWith(str))
            {
                token = this.token;
                return stream.Move(str.Length);
            }

            return stream;
        }
Exemplo n.º 22
0
        public override InputStream TryRead(InputStream stream, out LexicToken token)
        {
            token = null;

            if (stream.Content[0] == c)
            {
                token = this.token;
                return stream.Move(1);
            }

            return stream;
        }
Exemplo n.º 23
0
 public void Lexer_returns_literals_and_skips_whitespace()
 {
     var inputStream = new InputStream<char, Token>(new Position<char>(0, new CharacterStream("1 2.3 'a' \"bef\"")), new TacoLexer().Produce);
     var tokens = inputStream.Range(0, 5).ToArray();
     Assert.That(tokens[0], Is.TypeOf<LiteralToken<int>>());
     Assert.That(tokens[0], Has.Property("Value").EqualTo(1));
     Assert.That(tokens[1], Is.TypeOf<LiteralToken<double>>());
     Assert.That(tokens[1], Has.Property("Value").EqualTo(2.3));
     Assert.That(tokens[2], Is.TypeOf<LiteralToken<char>>());
     Assert.That(tokens[2], Has.Property("Value").EqualTo('a'));
     Assert.That(tokens[3], Is.TypeOf<LiteralToken<string>>());
     Assert.That(tokens[3], Has.Property("Value").EqualTo("bef"));
     Assert.That(tokens[4], Is.Null);
 }
Exemplo n.º 24
0
        public void StreamPositionLengthTest()
        {
            const int _50MB = 50*1024*1024;

            var from1 = Random.Init<Containers>();
            var from2 = Random.Init<Containers>();
            var stream = new MemoryStream();

            var output = new OutputStream(stream, 11);
            var writer = new CompactBinaryWriter<OutputStream>(output);

            Assert.IsTrue(output.Position == 0);

            Serialize.To(writer, from1);

            var pos = output.Position;

            output.Flush();

            Assert.IsTrue(output.Position == pos);
            Assert.IsTrue(output.Position == stream.Length);

            output.Position = _50MB;

            Serialize.To(writer, from2);
            output.Flush();

            pos = output.Position;

            stream.Position = 0;

            var input = new InputStream(stream);
            var reader = new CompactBinaryReader<InputStream>(input);

            Assert.IsTrue(input.Position == stream.Position);
            Assert.IsTrue(input.Length == stream.Length);

            var to1 = Deserialize<Containers>.From(reader);
            Assert.IsTrue(from1.IsEqual<Containers>(to1));

            Assert.IsTrue(input.Length == stream.Length);

            input.Position = _50MB;

            var to2 = Deserialize<Containers>.From(reader);
            Assert.IsTrue(from2.IsEqual<Containers>(to2));

            Assert.IsTrue(input.Position == pos);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a newly
 /// created <code>SequenceInputStream</code>
 /// by remembering the two arguments, which
 /// will be read in order, first <code>s1</code>
 /// and then <code>s2</code>, to provide the
 /// bytes to be read from this <code>SequenceInputStream</code>.
 /// </summary>
 /// <remarks>
 /// Initializes a newly
 /// created <code>SequenceInputStream</code>
 /// by remembering the two arguments, which
 /// will be read in order, first <code>s1</code>
 /// and then <code>s2</code>, to provide the
 /// bytes to be read from this <code>SequenceInputStream</code>.
 /// </remarks>
 /// <param name="s1">the first input stream to read.</param>
 /// <param name="s2">the second input stream to read.</param>
 public SequenceInputStream(InputStream s1, InputStream s2)
 {
     System.Collections.Generic.List<InputStream> v = new System.Collections.Generic.List<InputStream>(2);
     v.Add(s1);
     v.Add(s2);
     e = v.GetEnumerator();
     try
     {
         nextStream();
     }
     catch (System.IO.IOException)
     {
         // This should never happen
         throw new System.Exception("panic");
     }
 }
		public override InputStream TryRead(InputStream stream, out LexicToken token)
		{
			token = null;

			foreach (var function in Functions)
			{
				if (stream.Content.StartsWith(function.Name))
				{
					FunctionCallToken functionToken = new FunctionCallToken { Method = function.Method };
					token = functionToken;

					return stream.Move(function.Name.Length);
				}
			}

			return stream;
		}
		public override InputStream TryRead(InputStream stream, out LexicToken token)
		{
			token = null;

			foreach (var parameterName in parameterNames)
			{
				if (stream.Content.StartsWith(parameterName))
				{
					ParameterToken paramToken = new ParameterToken(parameterName);
					token = paramToken;

					return stream.Move(parameterName.Length);
				}
			}

			return stream;
		}
Exemplo n.º 28
0
		public override InputStream TryRead(InputStream stream, out LexicToken token)
		{
			token = null;

			char firstChar = stream.Content[0];

			if (firstChar == ' ' ||
				firstChar == '\t' ||
				firstChar == '\n' ||
				firstChar == '\r')
			{
				token = new WhitespaceToken();
				return stream.Move(1);
			}

			return stream;
		}
		public override InputStream TryRead(InputStream stream, out LexicToken token)
		{
			token = null;

			foreach (var constant in Constants)
			{
				if (stream.Content.StartsWith(constant.Name))
				{
					NamedConstantToken constantToken = new NamedConstantToken(constant.Name, constant.Value);
					token = constantToken;

					return stream.Move(constant.Name.Length);
				}
			}

			return stream;
		}
Exemplo n.º 30
0
 public void Compile(InputStream input, BytecodeStream output)
 {
     // creating scanner from InputStream
     Scanner scanner = new Scanner(input);
     // creating builder for abstract syntax tree
     ProgramNodeBuilder builder = new ProgramNodeBuilder();
     // creating Parser
     Parser parser = new Parser();
     // parsing using scanner and builder, hence creating AST
     parser.Parse(scanner, builder);
     // creating target code generator
     RISCCodeGenerator generator = new RISCCodeGenerator(output);
     // retrieving abstract syntax tree from builder
     ProgramNode parseTree = builder.GetRootNode();
     // generating target code from AST and generator
     parseTree.Traverse(generator);
     Console.WriteLine("compilation complete");
 }
 /// <summary>Constructor.</summary>
 public SimpleCharStream(InputStream dstream, int startline, int startcolumn, int buffersize)
     : this(new InputStreamReader(dstream), startline, startcolumn, buffersize)
 {
 }
Exemplo n.º 32
0
        public IImage newImage(string fileName, ImageFormat format)
        {
            Bitmap.Config config = null;
            if (format == ImageFormat.RGB565)
            {
                config = Bitmap.Config.RGB_565;
            }
            else if (format == ImageFormat.ARGB4444)
            {
                config = Bitmap.Config.ARGB_4444;
            }
            else
            {
                config = Bitmap.Config.ARGB_8888;
            }

            var options = new BitmapFactory.Options();

            options.InPreferredConfig = config;


            InputStream @in = null;
            Bitmap      bitmap;

            try
            {
                @in    = assets.Open(assetsPrefix + fileName);
                bitmap = BitmapFactory.DecodeStream(@in, null, options);
                if (bitmap == null)
                {
                    throw new SystemException("Couldn't load bitmap from asset '" + fileName + "'");
                }
            }
            catch (IOException e)
            {
                throw new SystemException("Couldn't load bitmap from asset '" + fileName + "'");
            }
            finally
            {
                if (@in != null)
                {
                    try
                    {
                        @in.Close();
                    }
                    catch (IOException e)
                    {
                    }
                }
            }

            if (bitmap.GetConfig() == Bitmap.Config.RGB_565)
            {
                format = ImageFormat.RGB565;
            }
            else if (bitmap.GetConfig() == Bitmap.Config.ARGB_4444)
            {
                format = ImageFormat.ARGB4444;
            }
            else
            {
                format = ImageFormat.ARGB8888;
            }

            return(new AndroidImage(bitmap, format));
        }
Exemplo n.º 33
0
 public override bool EndOfBlock()
 {
     return(InputStream.PeekChar() == -1);
 }
 /// <summary>Constructor.</summary>
 public SimpleCharStream(InputStream dstream)
     : this(dstream, 1, 1, 4096)
 {
 }
Exemplo n.º 35
0
 public static long skipNative(InputStream @is, long howmuch)
 {
     return(@is.skip(howmuch));
 }
Exemplo n.º 36
0
 public virtual TLObject <bridge> deserializeResponse(InputStream @is, TLContext tlc) =>
 this.deserializeResponse(@is, tlc);
Exemplo n.º 37
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.peer     = StreamingUtils.readTLObject(stream, context);
     this.randomId = StreamingUtils.readLong(stream);
     this.data     = StreamingUtils.readTLBytes(stream, context);
 }
 /// <summary>Reinitialise.</summary>
 public virtual void ReInit(InputStream dstream)
 {
     ReInit(dstream, 1, 1, 4096);
 }
 /// <summary>Reinitialise.</summary>
 /// <exception cref="Java.IO.UnsupportedEncodingException"/>
 public virtual void ReInit(InputStream dstream, string encoding)
 {
     ReInit(dstream, encoding, 1, 1, 4096);
 }
Exemplo n.º 40
0
 /// <exception cref="System.IO.IOException"></exception>
 public override PackParser NewPackParser(InputStream @in)
 {
     throw new NotSupportedException();
 }
 public void InitStream(InputStream onlineSource)
 {
     _stream = onlineSource;
 }
Exemplo n.º 42
0
 /// <summary>Creates an Append executor.</summary>
 /// <param name="is">input stream to append.</param>
 /// <param name="path">path of the file to append.</param>
 public FSAppend(InputStream @is, string path)
 {
     this.@is  = @is;
     this.path = new Path(path);
 }
 /// <summary>Constructor.</summary>
 public SimpleCharStream(InputStream dstream, int startline, int startcolumn)
     : this(dstream, startline, startcolumn, 4096)
 {
 }
Exemplo n.º 44
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     base.photos = StreamingUtils.readTLVector(stream, context);
     base.users  = StreamingUtils.readTLVector(stream, context);
 }
Exemplo n.º 45
0
 public static int readBytesNative(InputStream @is, ref sbyte[] data, int offset, int length)
 {
     return(@is.read(data, offset, length));
 }
Exemplo n.º 46
0
 /// <summary>Initialize a tee input stream.</summary>
 /// <remarks>Initialize a tee input stream.</remarks>
 /// <param name="src">source stream to consume.</param>
 /// <param name="dst">
 /// destination to copy the source to as it is consumed. Typically
 /// this is a
 /// <see cref="NGit.Util.TemporaryBuffer">NGit.Util.TemporaryBuffer</see>
 /// .
 /// </param>
 public TeeInputStream(InputStream src, OutputStream dst)
 {
     this.src = src;
     this.dst = dst;
 }
Exemplo n.º 47
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.session_id = Long.valueOf(StreamingUtils.readLong(stream));
 }
 /// <summary>Constructor.</summary>
 /// <exception cref="Java.IO.UnsupportedEncodingException"/>
 public SimpleCharStream(InputStream dstream, string encoding)
     : this(dstream, encoding, 1, 1, 4096)
 {
 }
Exemplo n.º 49
0
        public static Lattice readSlf(InputStream stream)
        {
            Lattice          lattice          = new Lattice();
            LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(stream));
            int    num  = 0;
            int    num2 = 0;
            int    num3 = 0;
            int    num4 = 1;
            double num5 = 9.5;
            string text;

            while ((text = lineNumberReader.readLine()) != null)
            {
                string       text2        = text;
                object       obj          = "Node definitions";
                CharSequence charSequence = CharSequence.Cast(obj);
                if (String.instancehelper_contains(text2, charSequence))
                {
                    num2 = 0;
                    num  = 1;
                }
                else
                {
                    string text3 = text;
                    obj          = "Link definitions";
                    charSequence = CharSequence.Cast(obj);
                    if (String.instancehelper_contains(text3, charSequence))
                    {
                        num2 = 1;
                        num  = 0;
                    }
                    else if (!String.instancehelper_startsWith(text, "#"))
                    {
                        if (num != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 3 || !String.instancehelper_startsWith(array[0], "I=") || !String.instancehelper_startsWith(array[1], "t=") || !String.instancehelper_startsWith(array[2], "W="))
                            {
                                lineNumberReader.close();
                                string text4 = new StringBuilder().append("Unknown node definition: ").append(text).toString();

                                throw new IOException(text4);
                            }
                            int    num6      = Integer.parseInt(String.instancehelper_substring(array[0], 2));
                            long   beginTime = ByteCodeHelper.d2l(Double.parseDouble(String.instancehelper_substring(array[1], 2)) * 1000.0);
                            string text5     = String.instancehelper_substring(array[2], 2);
                            int    isFiller  = 0;
                            if (num6 == num3 || String.instancehelper_equals(text5, "!ENTER"))
                            {
                                text5    = "<s>";
                                isFiller = 1;
                            }
                            if (num6 == num4 || String.instancehelper_equals(text5, "!EXIT"))
                            {
                                text5    = "</s>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_equals(text5, "!NULL"))
                            {
                                text5    = "<sil>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_startsWith(text5, "["))
                            {
                                isFiller = 1;
                            }
                            Word word = new Word(text5, new Pronunciation[0], isFiller != 0);
                            Node node = lattice.addNode(Integer.toString(num6), word, beginTime, -1L);
                            if (String.instancehelper_equals(text5, "<s>"))
                            {
                                lattice.setInitialNode(node);
                            }
                            if (String.instancehelper_equals(text5, "</s>"))
                            {
                                lattice.setTerminalNode(node);
                            }
                        }
                        else if (num2 != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 5 || !String.instancehelper_startsWith(array[1], "S=") || !String.instancehelper_startsWith(array[2], "E=") || !String.instancehelper_startsWith(array[3], "a=") || !String.instancehelper_startsWith(array[4], "l="))
                            {
                                lineNumberReader.close();
                                string text6 = new StringBuilder().append("Unknown edge definition: ").append(text).toString();

                                throw new IOException(text6);
                            }
                            string text7         = String.instancehelper_substring(array[1], 2);
                            string text8         = String.instancehelper_substring(array[2], 2);
                            double acousticScore = Double.parseDouble(String.instancehelper_substring(array[3], 2));
                            double lmScore       = Double.parseDouble(String.instancehelper_substring(array[4], 2)) * num5;
                            lattice.addEdge((Node)lattice.nodes.get(text7), (Node)lattice.nodes.get(text8), acousticScore, lmScore);
                        }
                        else
                        {
                            if (String.instancehelper_startsWith(text, "start="))
                            {
                                string text9 = text;
                                object obj2  = "start=";
                                obj = "";
                                object obj3 = obj2;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence2 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num3         = Integer.parseInt(String.instancehelper_replace(text9, charSequence2, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "end="))
                            {
                                string text10 = text;
                                object obj4   = "end=";
                                object obj3   = "";
                                obj          = obj4;
                                charSequence = CharSequence.Cast(obj);
                                CharSequence charSequence3 = charSequence;
                                obj          = obj3;
                                charSequence = CharSequence.Cast(obj);
                                num4         = Integer.parseInt(String.instancehelper_replace(text10, charSequence3, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "lmscale="))
                            {
                                string text11 = text;
                                object obj5   = "lmscale=";
                                obj = "";
                                object obj3 = obj5;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence4 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num5         = Double.parseDouble(String.instancehelper_replace(text11, charSequence4, charSequence));
                            }
                        }
                    }
                }
            }
            Iterator iterator = lattice.nodes.values().iterator();

            while (iterator.hasNext())
            {
                Node     node2     = (Node)iterator.next();
                Iterator iterator2 = node2.getLeavingEdges().iterator();
                while (iterator2.hasNext())
                {
                    Edge edge = (Edge)iterator2.next();
                    if (node2.getEndTime() < 0L || node2.getEndTime() > edge.getToNode().getBeginTime())
                    {
                        node2.setEndTime(Math.max(edge.getToNode().getBeginTime(), node2.getBeginTime()));
                    }
                }
            }
            return(lattice);
        }
Exemplo n.º 50
0
 /// <param name="in">the patch to apply</param>
 /// <returns>this instance</returns>
 public virtual NGit.Api.ApplyCommand SetPatch(InputStream @in)
 {
     CheckCallable();
     this.@in = @in;
     return(this);
 }
Exemplo n.º 51
0
        /// <summary>
        /// Creates a new <code>JarInputStream</code> and reads the optional
        /// manifest. If a manifest is present, also attempts to verify
        /// the signatures if the JarInputStream is signed. </summary>
        /// <param name="in"> the actual input stream </param>
        /// <exception cref="IOException"> if an I/O error has occurred </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public JarInputStream(InputStream in) throws IOException
        public JarInputStream(InputStream @in) : this(@in, true)
        {
        }
Exemplo n.º 52
0
 public RandomAccessStreamReader([NotNull] InputStream stream)
     : this(stream, DefaultChunkLength)
 {
 }
Exemplo n.º 53
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.title = StreamingUtils.readTLString(stream);
     this.users = StreamingUtils.readTLIntVector(stream, context);
 }
Exemplo n.º 54
0
        bool PerformHandshake(InputStream buffer, bool encrypted)
        {
            if (!ValidateClient(buffer))
            {
                if (encrypted || _pProtocolHandler.ValidateHandshake)
                {
                    Logger.FATAL("Unable to validate client");
                    return(false);
                }
                else
                {
                    Logger.WARN("Client not validated");
                    _validationScheme = 0;
                }
            }
            _pOutputBuffer = Utils.GenerateRandomBytes(3072);
            _pOutputBuffer.Write(0, (uint)DateTime.Now.SecondsFrom1970());
            _pOutputBuffer.Write(0, (uint)0);
            var serverBytes = Encoding.ASCII.GetBytes(Defines.HTTP_HEADERS_SERVER_US);

            for (var i = 0; i < 10; i++)
            {
                var index = Utils.Random.Next(0, 3072 - Defines.HTTP_HEADERS_SERVER_US_LEN);
                Buffer.BlockCopy(serverBytes, 0, _pOutputBuffer, index, serverBytes.Length);
            }

            var _pOutputBufferWithOffset = new BufferWithOffset(_pOutputBuffer);
            var pInputBuffer             = new BufferWithOffset(buffer);
            var serverDHOffset           = GetDHOffset(_pOutputBufferWithOffset, _validationScheme);
            var clientDHOffset           = GetDHOffset(pInputBuffer, _validationScheme);
            var dhWrapper = new DHWrapper();
            var pubKeyIn  = new byte[128];

            Buffer.BlockCopy(buffer.GetBuffer(), (int)(buffer.Position + clientDHOffset), pubKeyIn, 0, 128);
            var sharedkey = dhWrapper.CreateSharedKey(pubKeyIn);
            var pubKeyOut = dhWrapper.PublicKey;

            Buffer.BlockCopy(pubKeyOut, 0, _pOutputBuffer, (int)serverDHOffset, 128);
            if (encrypted)
            {
                _pKeyIn  = new RC4_KEY();
                _pKeyOut = new RC4_KEY();
                Utils.InitRC4Encryption(sharedkey, pubKeyIn, pubKeyOut, _pKeyIn, _pKeyOut);
                var data = new byte[1536];
                Utils.RC4(data, _pKeyIn, 1536);
                Utils.RC4(data, _pKeyOut, 1536);
            }
            var serverDigestOffset = GetDigestOffset(_pOutputBufferWithOffset, _validationScheme);
            var pTempBuffer        = new byte[1536 - 32];

            Buffer.BlockCopy(_pOutputBuffer, 0, pTempBuffer, 0, (int)serverDigestOffset);
            Buffer.BlockCopy(_pOutputBuffer, (int)serverDigestOffset + 32, pTempBuffer, (int)serverDigestOffset, (int)(1536 - serverDigestOffset - 32));
            var pTempHash = HMACsha256(pTempBuffer, 1536 - 32, GenuineFmsKey, 36);

            Buffer.BlockCopy(pTempHash, 0, _pOutputBuffer, (int)serverDigestOffset, 32);
            var keyChallengeIndex = GetDigestOffset(pInputBuffer, _validationScheme);

            pInputBuffer.Offset += (int)keyChallengeIndex;
            pTempHash            = HMACsha256(pInputBuffer, 32, GenuineFmsKey, 68);
            Buffer.BlockCopy(_pOutputBuffer, 1536, pTempBuffer, 0, 1536 - 32);
            pTempBuffer = new HMACSHA256(pTempHash).ComputeHash(pTempBuffer, 0, 1536 - 32);
            Buffer.BlockCopy(pTempBuffer, 0, _pOutputBuffer, 1536 * 2 - 32, 32);
            OutputBuffer.WriteByte((byte)(encrypted ? 6 : 3));
            OutputBuffer.Write(_pOutputBuffer, 0, 3072);
            buffer.Recycle(true);
            if (!EnqueueForOutbound(OutputBuffer))
            {
                Logger.FATAL("Unable to signal outbound data");
                return(false);
            }
            _rtmpState = RTMPState.RTMP_STATE_SERVER_RESPONSE_SENT;
            return(true);
        }
Exemplo n.º 55
0
 /// <summary>Create a new transport to fetch objects from a streamed bundle.</summary>
 /// <remarks>
 /// Create a new transport to fetch objects from a streamed bundle.
 /// <p>
 /// The stream can be unbuffered (buffering is automatically provided
 /// internally to smooth out short reads) and unpositionable (the stream is
 /// read from only once, sequentially).
 /// <p>
 /// When the FetchConnection or the this instance is closed the supplied
 /// input stream is also automatically closed. This frees callers from
 /// needing to keep track of the supplied stream.
 /// </remarks>
 /// <param name="db">repository the fetched objects will be loaded into.</param>
 /// <param name="uri">
 /// symbolic name of the source of the stream. The URI can
 /// reference a non-existent resource. It is used only for
 /// exception reporting.
 /// </param>
 /// <param name="in">the stream to read the bundle from.</param>
 public TransportBundleStream(Repository db, URIish uri, InputStream @in) : base(db
                                                                                 , uri)
 {
     src = @in;
 }
Exemplo n.º 56
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="TnefReader"/> and
 /// optionally releases the managed resources.
 /// </summary>
 /// <remarks>
 /// Releases the unmanaged resources used by the <see cref="TnefReader"/> and
 /// optionally releases the managed resources.
 /// </remarks>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources;
 /// <c>false</c> to release only the unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     InputStream.Dispose();
 }
 /// <summary>Reinitialise.</summary>
 /// <exception cref="Java.IO.UnsupportedEncodingException"/>
 public virtual void ReInit(InputStream dstream, string encoding, int startline, int startcolumn, int buffersize)
 {
     ReInit(encoding == null ? new InputStreamReader(dstream) : new InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
 }
 /// <summary>Constructor.</summary>
 /// <exception cref="Java.IO.UnsupportedEncodingException"/>
 public SimpleCharStream(InputStream dstream, string encoding, int startline, int startcolumn, int buffersize)
     : this(encoding == null ? new InputStreamReader(dstream) : new InputStreamReader(dstream, encoding), startline, startcolumn, buffersize)
 {
 }
 /// <summary>Reinitialise.</summary>
 public virtual void ReInit(InputStream dstream, int startline, int startcolumn, int buffersize)
 {
     ReInit(new InputStreamReader(dstream), startline, startcolumn, buffersize);
 }
Exemplo n.º 60
0
 /// <exception cref="System.IO.IOException"></exception>
 public override ObjectId Insert(int objectType, long length, InputStream @in)
 {
     throw new NotSupportedException();
 }