Пример #1
0
	// note: outbuf is always completely empty when we return
	public void writelines(string header, WvBuf outbuf)
	{
	    // force ending of previous partial line, if necessary
	    if (outbuf.used > 0 
		&& open_header != null && open_header != header)
	    {
		w(nl);
		open_header = null;
	    }
	    
	    // zero or more full lines (terminated by newlines)
	    int i;
	    while ((i = outbuf.strchr('\n')) > 0)
	    {
		if (open_header == null)
		    w(header);
		w(outbuf.get(i));
		open_header = null;
	    }
	    
	    // end-of-buffer partial line (ie. no newline terminator yet)
	    if (outbuf.used > 0)
	    {
		if (open_header == null)
		    w(header);
		w(outbuf.get(outbuf.used));
		open_header = header;
	    }
	}
Пример #2
0
	public override int write(WvBytes b)
	{
	    if (level > maxlevel)
		return b.len; // pretend it's written
	    
	    WvBuf outbuf = new WvBuf();
	    outbuf.put(b);
	    recv.writelines(wv.fmt("{0}<{1}>: ", name, levelstr(level)),
			    outbuf);
	    return b.len;
	}
Пример #3
0
	public void read(WvBuf b, int max)
	{
	    int got = read(b.alloc(max));
	    b.unalloc(max-got);
	}