#include <u.h>#include <libc.h>#include <bio.h>#include "common.h"#include "packet.h" static intsanitize(uchar *s, int sz){ uchar *o, *i; for(o = i = s; sz > 0;){ if(*i == '\r'){ if(sz <= 1 || i[1] != '\n') *o++ = '\n'; i++; }else *o++ = *i++; sz--; } return o-s;} intasspacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts, int key){ int i; USED(ts, key); if(ctx->frid == 0) Bwrite(out, ctx->codec.priv.data, sanitize(ctx->codec.priv.data, ctx->codec.priv.sz)); for(i = 0; i < np; i++, p++){ Bwrite(out, p->data, sanitize(p->data, p->sz)); Bwrite(out, "\n", 1); } ctx->frid++; Bflush(out); return 0;}
#include <u.h>
#include <libc.h>
#include <bio.h>
#include "common.h"
#include "packet.h"
static int
sanitize(uchar *s, int sz)
{
uchar *o, *i;
for(o = i = s; sz > 0;){
if(*i == '\r'){
if(sz <= 1 || i[1] != '\n')
*o++ = '\n';
i++;
}else
*o++ = *i++;
sz--;
}
return o-s;
}
int
asspacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts, int key)
{
int i;
USED(ts, key);
if(ctx->frid == 0)
Bwrite(out, ctx->codec.priv.data, sanitize(ctx->codec.priv.data, ctx->codec.priv.sz));
for(i = 0; i < np; i++, p++){
Bwrite(out, p->data, sanitize(p->data, p->sz));
Bwrite(out, "\n", 1);
}
ctx->frid++;
Bflush(out);
return 0;
}