Пример #1
0
 /// <summary>
 /// Append bucket to brigade.
 /// </summary>
 public static void stream_bucket_append(UserFilterBucketBrigade brigade, UserFilterBucket bucket)
 {
     if (!bucket.data.IsEmpty)
     {
         brigade.bucket.EnsureWritable().Append(bucket.data);
     }
 }
Пример #2
0
        /// <summary>
        /// Prepend bucket to brigade.
        /// </summary>
        public static void stream_bucket_prepend(UserFilterBucketBrigade brigade, UserFilterBucket bucket)
        {
            if (!bucket.data.IsEmpty)
            {
                var blob = bucket.data.DeepCopy().EnsureWritable();
                blob.Append(brigade.bucket);

                brigade.bucket = new PhpString(blob);
            }
        }
Пример #3
0
        /// <summary>
        /// Return a bucket object from the brigade for operating on.
        /// </summary>
        /// <returns>Object or <c>NULL</c>.</returns>
        public static UserFilterBucket stream_bucket_make_writeable(UserFilterBucketBrigade brigade)
        {
            if (brigade == null || brigade.consumed >= brigade.bucket.Length)
            {
                return(null);
            }

            brigade.consumed = brigade.bucket.Length;

            return(new UserFilterBucket
            {
                data = brigade.bucket,
                datalen = brigade.bucket.Length,
            });
        }
Пример #4
0
        public sealed override TextElement /*PhpFilter.*/ Filter(IEncodingProvider enc, TextElement input, bool closing)
        {
            var @in = new UserFilterBucketBrigade()
            {
                bucket = input.ToPhpString()
            };
            var @out     = new UserFilterBucketBrigade();
            var consumed = new PhpAlias(0L);

            switch ((PhpFilters.FilterStatus)filter(@in, @out, consumed, closing))
            {
            case PhpFilters.FilterStatus.OK:
                return(new TextElement(@out.bucket, enc.StringEncoding));

            case PhpFilters.FilterStatus.MoreData:
                return(TextElement.Empty);

            case PhpFilters.FilterStatus.FatalError:
            default:
                // silently stop feeding this filter
                return(TextElement.Null);
            }
        }