~ft/mcfs

ref: d4879b4b179f892b55fd1fd6adae62ffb14aad8c mcfs/ass.c -rw-r--r-- 667 bytes
d4879b4b — Sigrid Solveig Haflínudóttir ivf2raw: fix wrong timestamps 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#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;
}