//
// aegis - project change supervisor
// Copyright (C) 1999, 2003-2006, 2008, 2012, 2014 Peter Miller
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see
// .
//
#include
#include
input_822wrap::~input_822wrap()
{
trace(("input_822wrap::~input_822wrap(this = %p)\n{\n", this));
deeper->pullback_transfer(this);
trace(("}\n"));
}
input_822wrap::input_822wrap(const input::pointer &a_deeper) :
deeper(a_deeper),
pos(0),
column(0)
{
trace(("input_822wrap::input_822wrap(this = %p)\n{\n", this));
trace(("}\n"));
}
input_822wrap::pointer
input_822wrap::create(const input::pointer &a_deeper)
{
return pointer(new input_822wrap(a_deeper));
}
ssize_t
input_822wrap::read_inner(void *data, size_t len)
{
trace(("input_822wrap::read_inner(this = %p)\n{\n", this));
unsigned char *cp = (unsigned char *)data;
unsigned char *end = cp + len;
while (cp < end)
{
int c = deeper->getch();
if (c < 0)
break;
if (c == '\n' && column > 0)
{
c = deeper->getch();
if (c != ' ' && c != '\t')
{
if (c >= 0)
deeper->ungetc(c);
c = '\n';
}
}
*cp++ = c;
if (c == '\n')
{
//
// Line buffered, because we don't want to get
// too far ahead of ourselves, in case the header
// finishes and the binary data starts.
//
column = 0;
break;
}
column++;
}
size_t nbytes = (cp - (unsigned char *)data);
pos += nbytes;
trace(("return %ld;\n", (long)nbytes));
trace(("}\n"));
return nbytes;
}
off_t
input_822wrap::ftell_inner(void)
{
return pos;
}
nstring
input_822wrap::name(void)
{
return deeper->name();
}
off_t
input_822wrap::length(void)
{
return -1;
}
void
input_822wrap::keepalive(void)
{
deeper->keepalive();
}
bool
input_822wrap::is_remote(void)
const
{
return deeper->is_remote();
}
// vim: set ts=8 sw=4 et :