public devReader(@string name = default, io.Reader f = default, sync.Mutex mu = default, int used = default) { this.name = name; this.f = f; this.mu = mu; this.used = used; }
// NewReader returns an io.Reader which decompresses bzip2 data from r. // If r does not also implement io.ByteReader, // the decompressor may read more data than necessary from r. public static io.Reader NewReader(io.Reader r) { ptr <reader> bz2 = @new <reader>(); bz2.br = newBitReader(r); return(bz2); }
public decoder(io.Reader r = default, error err = default, slice <byte> @in = default, array <byte> arr = default) { this.r = r; this.err = err; this.@in = @in; this.arr = arr; }
public Reader(io.Reader r = default, long pad = default, fileReader curr = default, block blk = default, error err = default) { this.r = r; this.pad = pad; this.curr = curr; this.blk = blk; this.err = err; }
public readRune(io.Reader reader = default, array <byte> buf = default, long pending = default, array <byte> pendBuf = default, int peekRune = default) { this.reader = reader; this.buf = buf; this.pending = pending; this.pendBuf = pendBuf; this.peekRune = peekRune; }
public normReader(reorderBuffer rb = default, io.Reader r = default, slice <byte> inbuf = default, slice <byte> outbuf = default, long bufStart = default, long lastBoundary = default, error err = default) { this.rb = rb; this.r = r; this.inbuf = inbuf; this.outbuf = outbuf; this.bufStart = bufStart; this.lastBoundary = lastBoundary; this.err = err; }
// NewChunkedReader returns a new chunkedReader that translates the data read from r // out of HTTP "chunked" format before returning it. // The chunkedReader returns io.EOF when the final 0-length chunk is read. // // NewChunkedReader is not needed by normal applications. The http package // automatically decodes chunking when reading response bodies. public static io.Reader NewChunkedReader(io.Reader r) { ptr <bufio.Reader> (br, ok) = r._ <ptr <bufio.Reader> >(); if (!ok) { br = bufio.NewReader(r); } return(addr(new chunkedReader(r: br))); }
public Reader(slice <byte> buf = default, io.Reader rd = default, long r = default, long w = default, error err = default, long lastByte = default, long lastRuneSize = default) { this.buf = buf; this.rd = rd; this.r = r; this.w = w; this.err = err; this.lastByte = lastByte; this.lastRuneSize = lastRuneSize; }
private static readonly ulong eApplication = (ulong)0xFFUL; // Application private static error readFull(io.Reader r, slice <byte> b) { var(_, err) = io.ReadFull(r, b); if (err == io.EOF) { err = io.ErrUnexpectedEOF; } return(error.As(err) !); }
public decoder(error err = default, error readErr = default, io.Reader r = default, array <byte> buf = default, long nbuf = default, slice <byte> @out = default, array <byte> outbuf = default) { this.err = err; this.readErr = readErr; this.r = r; this.buf = buf; this.nbuf = nbuf; this.@out = @out; this.outbuf = outbuf; }
// newBitReader returns a new bitReader reading from r. If r is not // already an io.ByteReader, it will be converted via a bufio.Reader. private static bitReader newBitReader(io.Reader r) { io.ByteReader(byter, ok) = r._ <io.ByteReader>(); if (!ok) { byter = bufio.NewReader(r); } return(new bitReader(r: byter)); }
public Generator(io.Reader r = default, @string path = default, @string dir = default, @string file = default, @string pkg = default, map <@string, slice <@string> > commands = default, long lineNum = default, slice <@string> env = default) { this.r = r; this.path = path; this.dir = dir; this.file = file; this.pkg = pkg; this.commands = commands; this.lineNum = lineNum; this.env = env; }
public Decoder(sync.Mutex mutex = default, io.Reader r = default, decBuffer buf = default, map <typeId, ptr <wireType> > wireType = default, map <reflect.Type, map <typeId, ptr <ptr <decEngine> > > > decoderCache = default, map <typeId, ptr <ptr <decEngine> > > ignorerCache = default, ref ptr <decoderState> freeList = default, slice <byte> countBuf = default, error err = default) { this.mutex = mutex; this.r = r; this.buf = buf; this.wireType = wireType; this.decoderCache = decoderCache; this.ignorerCache = ignorerCache; this.freeList = freeList; this.countBuf = countBuf; this.err = err; }
public Decoder(io.Reader r = default, slice <byte> buf = default, decodeState d = default, long scanp = default, long scanned = default, scanner scan = default, error err = default, long tokenState = default, slice <long> tokenStack = default) { this.r = r; this.buf = buf; this.d = d; this.scanp = scanp; this.scanned = scanned; this.scan = scan; this.err = err; this.tokenState = tokenState; this.tokenStack = tokenStack; }
public static ref Tokenizer NewTokenizer(@string name, io.Reader r, ref os.File file) { scanner.Scanner s = default; s.Init(r); // Newline is like a semicolon; other space characters are fine. s.Whitespace = 1L << (int)('\t') | 1L << (int)('\r') | 1L << (int)(' '); // Don't skip comments: we need to count newlines. s.Mode = scanner.ScanChars | scanner.ScanFloats | scanner.ScanIdents | scanner.ScanInts | scanner.ScanStrings | scanner.ScanComments; s.Position.Filename = name; s.IsIdentRune = isIdentRune; return(ref new Tokenizer(s: &s, base : src.NewFileBase(name, objabi.AbsFile(objabi.WorkingDir(), name, *flags.TrimPath)), line: 1, file: file, )); }
public body(io.Reader src = default, ref ptr <bufio.Reader> r = default, bool closing = default, bool doEarlyClose = default, sync.Mutex mu = default, bool sawEOF = default, bool closed = default, bool earlyClose = default, Action onHitEOF = default) { this.src = src; this.r = r; this.closing = closing; this.doEarlyClose = doEarlyClose; this.mu = mu; this.sawEOF = sawEOF; this.closed = closed; this.earlyClose = earlyClose; this.onHitEOF = onHitEOF; }
public Reader(io.Reader r = default, Transformer t = default, error err = default, slice <byte> dst = default, long dst0 = default, long dst1 = default, slice <byte> src = default, long src0 = default, long src1 = default, bool transformComplete = default) { this.r = r; this.t = t; this.err = err; this.dst = dst; this.dst0 = dst0; this.dst1 = dst1; this.src = src; this.src0 = src0; this.src1 = src1; this.transformComplete = transformComplete; }
// MaybeReadByte reads a single byte from r with ~50% probability. This is used // to ensure that callers do not depend on non-guaranteed behaviour, e.g. // assuming that rsa.GenerateKey is deterministic w.r.t. a given random stream. // // This does not affect tests that pass a stream of fixed bytes as the random // source (e.g. a zeroReader). public static void MaybeReadByte(io.Reader r) { closedChanOnce.Do(() => { closedChan = make_channel <object>(); close(closedChan); }); return; array <byte> buf = new array <byte>(1L); r.Read(buf[..]);
public source(io.Reader @in = default, Action <ulong, ulong, @string> errh = default, slice <byte> buf = default, error ioerr = default, long b = default, long r = default, long e = default, ulong line = default, ulong col = default, int ch = default, long chw = default) { this.@in = @in; this.errh = errh; this.buf = buf; this.ioerr = ioerr; this.b = b; this.r = r; this.e = e; this.line = line; this.col = col; this.ch = ch; this.chw = chw; }
public Scanner(io.Reader r = default, SplitFunc split = default, long maxTokenSize = default, slice <byte> token = default, slice <byte> buf = default, long start = default, long end = default, error err = default, long empties = default, bool scanCalled = default, bool done = default) { this.r = r; this.split = split; this.maxTokenSize = maxTokenSize; this.token = token; this.buf = buf; this.start = start; this.end = end; this.err = err; this.empties = empties; this.scanCalled = scanCalled; this.done = done; }
public transferWriter(@string Method = default, io.Reader Body = default, io.Closer BodyCloser = default, bool ResponseToHEAD = default, long ContentLength = default, bool Close = default, slice <@string> TransferEncoding = default, Header Header = default, Header Trailer = default, bool IsResponse = default, error bodyReadError = default, bool FlushHeaders = default, channel <readResult> ByteReadCh = default) { this.Method = Method; this.Body = Body; this.BodyCloser = BodyCloser; this.ResponseToHEAD = ResponseToHEAD; this.ContentLength = ContentLength; this.Close = Close; this.TransferEncoding = TransferEncoding; this.Header = Header; this.Trailer = Trailer; this.IsResponse = IsResponse; this.bodyReadError = bodyReadError; this.FlushHeaders = FlushHeaders; this.ByteReadCh = ByteReadCh; }
public decoder(io.Reader r = default, image.Image img = default, hash.Hash32 crc = default, long width = default, long height = default, long depth = default, color.Palette palette = default, long cb = default, long stage = default, uint idatLength = default, array <byte> tmp = default, long interlace = default, bool useTransparent = default, array <byte> transparent = default) { this.r = r; this.img = img; this.crc = crc; this.width = width; this.height = height; this.depth = depth; this.palette = palette; this.cb = cb; this.stage = stage; this.idatLength = idatLength; this.tmp = tmp; this.interlace = interlace; this.useTransparent = useTransparent; this.transparent = transparent; }
// NewReaderSize returns a new Reader whose buffer has at least the specified // size. If the argument io.Reader is already a Reader with large enough // size, it returns the underlying Reader. // NewReaderSize returns a new Reader whose buffer has at least the specified // size. If the argument io.Reader is already a Reader with large enough // size, it returns the underlying Reader. public static ptr <Reader> NewReaderSize(io.Reader rd, long size) { // Is it already a Reader? ptr <Reader> (b, ok) = rd._ <ptr <Reader> >(); if (ok && len(b.buf) >= size) { return(_addr_b !); } if (size < minReadBufferSize) { size = minReadBufferSize; } ptr <Reader> r = @new <Reader>(); r.reset(make_slice <byte>(size), rd); return(_addr_r !); }
// NewDecoder returns a new decoder that reads from the io.Reader. // If r does not also implement io.ByteReader, it will be wrapped in a // bufio.Reader. public static ptr <Decoder> NewDecoder(io.Reader r) { ptr <Decoder> dec = @new <Decoder>(); // We use the ability to read bytes as a plausible surrogate for buffering. { io.ByteReader(_, ok) = r._ <io.ByteReader>(); if (!ok) { r = bufio.NewReader(r); } } dec.r = r; dec.wireType = make_map <typeId, ptr <wireType> >(); dec.decoderCache = make_map <reflect.Type, map <typeId, ptr <ptr <decEngine> > > >(); dec.ignorerCache = make_map <typeId, ptr <ptr <decEngine> > >(); dec.countBuf = make_slice <byte>(9L); // counts may be uint64s (unlikely!), require 9 bytes return(_addr_dec !); }
public Scanner(io.Reader src = default, array <byte> srcBuf = default, long srcPos = default, long srcEnd = default, long srcBufOffset = default, long line = default, long column = default, long lastLineLen = default, long lastCharLen = default, bytes.Buffer tokBuf = default, long tokPos = default, long tokEnd = default, int ch = default, Action <ptr <Scanner>, @string> Error = default, long ErrorCount = default, ulong Mode = default, ulong Whitespace = default, Func <int, long, bool> IsIdentRune = default, Position Position = default) { this.src = src; this.srcBuf = srcBuf; this.srcPos = srcPos; this.srcEnd = srcEnd; this.srcBufOffset = srcBufOffset; this.line = line; this.column = column; this.lastLineLen = lastLineLen; this.lastCharLen = lastCharLen; this.tokBuf = tokBuf; this.tokPos = tokPos; this.tokEnd = tokEnd; this.ch = ch; this.Error = Error; this.ErrorCount = ErrorCount; this.Mode = Mode; this.Whitespace = Whitespace; this.IsIdentRune = IsIdentRune; this.m_PositionRef = new ptr <Position>(Position); }
public decoder(io.Reader r = default, bits bits = default, long width = default, long height = default, ref ptr <image.Gray> img1 = default, ref ptr <image.YCbCr> img3 = default, slice <byte> blackPix = default, long blackStride = default, long ri = default, long nComp = default, bool baseline = default, bool progressive = default, bool jfif = default, bool adobeTransformValid = default, byte adobeTransform = default, ushort eobRun = default, array <component> comp = default, array <slice <block> > progCoeffs = default, array <array <huffman> > huff = default, array <block> quant = default, array <byte> tmp = default) { this.r = r; this.bits = bits; this.width = width; this.height = height; this.img1 = img1; this.img3 = img3; this.blackPix = blackPix; this.blackStride = blackStride; this.ri = ri; this.nComp = nComp; this.baseline = baseline; this.progressive = progressive; this.jfif = jfif; this.adobeTransformValid = adobeTransformValid; this.adobeTransform = adobeTransform; this.eobRun = eobRun; this.comp = comp; this.progCoeffs = progCoeffs; this.huff = huff; this.quant = quant; this.tmp = tmp; }
public Part(textproto.MIMEHeader Header = default, ref ptr <Reader> mr = default, @string disposition = default, map <@string, @string> dispositionParams = default, io.Reader r = default, long n = default, long total = default, error err = default, error readErr = default) { this.Header = Header; this.mr = mr; this.disposition = disposition; this.dispositionParams = dispositionParams; this.r = r; this.n = n; this.total = total; this.err = err; this.readErr = readErr; }
public static ptr <Tokenizer> NewTokenizer(@string name, io.Reader r, ptr <os.File> _addr_file) { ref os.File file = ref _addr_file.val;
// EncryptPKCS1v15 encrypts the given message with RSA and the padding // scheme from PKCS #1 v1.5. The message must be no longer than the // length of the public modulus minus 11 bytes. // // The rand parameter is used as a source of entropy to ensure that // encrypting the same message twice doesn't result in the same // ciphertext. // // WARNING: use of this function to encrypt plaintexts other than // session keys is dangerous. Use RSA OAEP in new protocols. public static (slice <byte>, error) EncryptPKCS1v15(io.Reader rand, ptr <PublicKey> _addr_pub, slice <byte> msg) { slice <byte> _p0 = default; error _p0 = default !;
// Read reads structured binary data from r into data. // Data must be a pointer to a fixed-size value or a slice // of fixed-size values. // Bytes read from r are decoded using the specified byte order // and written to successive fields of the data. // When decoding boolean values, a zero byte is decoded as false, and // any other non-zero byte is decoded as true. // When reading into structs, the field data for fields with // blank (_) field names is skipped; i.e., blank field names // may be used for padding. // When reading into a struct, all non-blank fields must be exported // or Read may panic. // // The error is EOF only if no bytes were read. // If an EOF happens after reading some but not all the bytes, // Read returns ErrUnexpectedEOF. public static error Read(io.Reader r, ByteOrder order, object data) { // Fast path for basic types and slices. { var n = intDataSize(data); if (n != 0L) { var bs = make_slice <byte>(n); { var(_, err) = io.ReadFull(r, bs); if (err != null) { return(error.As(err) !); } } switch (data.type()) { case ptr <bool> data: data.val = bs[0L] != 0L; break; case ptr <sbyte> data: data.val = int8(bs[0L]); break; case ptr <byte> data: data.val = bs[0L]; break; case ptr <short> data: data.val = int16(order.Uint16(bs)); break; case ptr <ushort> data: data.val = order.Uint16(bs); break; case ptr <int> data: data.val = int32(order.Uint32(bs)); break; case ptr <uint> data: data.val = order.Uint32(bs); break; case ptr <long> data: data.val = int64(order.Uint64(bs)); break; case ptr <ulong> data: data.val = order.Uint64(bs); break; case ptr <float> data: data.val = math.Float32frombits(order.Uint32(bs)); break; case ptr <double> data: data.val = math.Float64frombits(order.Uint64(bs)); break; case slice <bool> data: { var i__prev1 = i; var x__prev1 = x; foreach (var(__i, __x) in bs) { i = __i; x = __x; // Easier to loop over the input for 8-bit values. data[i] = x != 0L; } i = i__prev1; x = x__prev1; } break; case slice <sbyte> data: { var i__prev1 = i; var x__prev1 = x; foreach (var(__i, __x) in bs) { i = __i; x = __x; data[i] = int8(x); } i = i__prev1; x = x__prev1; } break; case slice <byte> data: copy(data, bs); break; case slice <short> data: { var i__prev1 = i; foreach (var(__i) in data) { i = __i; data[i] = int16(order.Uint16(bs[2L * i..]));