ostream-crlf.c revision 9cbaab4518c2bf1c88d4078856786c64d1d3d794
/* Copyright (c) 2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "istream.h"
#include "ostream-internal.h"
#include "ostream-crlf.h"
#define IOVBUF_COUNT 64
struct crlf_ostream {
int last_cr;
};
{
}
{
}
{
}
{
if (set)
else
}
{
}
{
}
{
}
{
if (ret > 0) {
iov++;
}
}
return ret;
}
static ssize_t
{
const unsigned char *data;
struct const_iovec new_iov;
int last_cr;
t_push();
sizeof(struct const_iovec *) * IOVBUF_COUNT,
(size_t)-1);
for (i = start = 0;; i++) {
if (i != len) {
if (data[i] != '\n')
continue;
if (i > 0) {
continue;
} else {
if (last_cr)
continue;
}
/* need to insert CR */
}
if (i != start) {
}
start = i;
if (i != len) {
new_iov_size++;
}
t_pop();
return ret;
}
buffer_set_used_size(buf, 0);
new_iov_count = 0;
new_iov_size = 0;
}
if (i == len)
break;
}
if (len != 0)
}
t_pop();
return ret;
}
static ssize_t
{
const unsigned char *data;
struct const_iovec new_iov;
t_push();
sizeof(struct const_iovec *) * IOVBUF_COUNT,
(size_t)-1);
for (i = start = 0;; i++) {
continue;
if (i != start) {
}
start = i+1;
if (new_iov_count == IOVBUF_COUNT) {
t_pop();
return ret;
}
buffer_set_used_size(buf, 0);
new_iov_count = 0;
new_iov_size = 0;
}
if (i == len)
break;
}
}
t_pop();
return ret;
}
static off_t
{
struct const_iovec iov;
if (ret == 0)
return sent;
if (ret <= 0)
return sent;
}
}
static struct crlf_ostream *
{
struct crlf_ostream *cstream;
return cstream;
}
{
struct crlf_ostream *cstream;
}
{
struct crlf_ostream *cstream;
}