shithub: mcfs

Download patch

ref: bc6befef0360c5bbfe32f85fb1e7908bc222f840
parent: 72ed7dd00d9460a3711822cafaad3d0a87254db9
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Dec 14 07:23:59 EST 2020

ebml: remove the trace

--- a/ebml.c
+++ b/ebml.c
@@ -335,7 +335,6 @@
 			if(trackdump != Nodump) /* skip it entirely if no dump required */
 				continue;
 		}else if(id == 0xae){ /* track entry */
-			fprint(2, "track %d | type %d | want %d\n", e.tracknum, e.tracktype, trackdump);
 			if(e.tracknum > 0){
 				if(trackdump == Nodump)
 					trackinfo(&out, &e);
--- a/main.c
+++ b/main.c
@@ -3,6 +3,12 @@
 #include <bio.h>
 #include "common.h"
 
+enum
+{
+	Outbufsz = 256*1024,
+	Inbufsz = 256*1024,
+};
+
 Biobuf stderr, out;
 int dflag, trackdump;
 
@@ -16,10 +22,15 @@
 void
 main(int argc, char **argv)
 {
-	Biobuf *f;
+	u8int d[4], *outbuf, *inbuf;
 	char *s, *status;
-	u8int d[4];
+	Biobuf f;
+	int fd;
 
+	fmtinstall('H', encodefmt);
+	fmtinstall('T', isotypefmt);
+	fmtinstall('P', srttsfmt);
+
 	dflag = 0;
 	trackdump = Nodump;
 	ARGBEGIN{
@@ -39,41 +50,42 @@
 		usage();
 	}ARGEND
 
-	f = nil;
+	if((outbuf = malloc(Outbufsz)) == nil)
+		sysfatal("memory");
+	if((inbuf = malloc(Inbufsz)) == nil)
+		sysfatal("memory");
+
+	fd = 0;
 	if(argc == 1)
-		f = Bopen(*argv, OREAD);
-	else if(argc == 0)
-		f = Bfdopen(0, OREAD);
-	else
+		fd = open(*argv, OREAD);
+	else if(argc != 0)
 		usage();
 
-	if(f == nil)
+	if(Binits(&f, fd, OREAD, inbuf, Inbufsz) != 0)
 		sysfatal("%r");
+	if(Binits(&out, 1, OWRITE, outbuf, Outbufsz) != 0)
+		sysfatal("%r");
+	if(Binit(&stderr, 2, OWRITE) != 0)
+		sysfatal("%r");
 
-	fmtinstall('H', encodefmt);
-	fmtinstall('T', isotypefmt);
-	fmtinstall('P', srttsfmt);
-	Binit(&out, 1, OWRITE);
-	Binit(&stderr, 2, OWRITE);
-
 	status = nil;
-	if(Bread(f, d, 4) != 4){
+	if(Bread(&f, d, 4) != 4){
 		Bprint(&stderr, "unknown format\n");
 		status = "unknown format";
-	}else if(Bungetc(f) < 0 || Bungetc(f) < 0 || Bungetc(f) < 0 || Bungetc(f) < 0){
+	}else if(Bungetc(&f) < 0 || Bungetc(&f) < 0 || Bungetc(&f) < 0 || Bungetc(&f) < 0){
 		Bprint(&stderr, "seek back failed: %r\n");
 		status = "seek failed";
 	}else if(memcmp(d, "\x1a\x45\xdf\xa3", 4) == 0){
-		if(ebmlrun(f) != 0){
+		if(ebmlrun(&f) != 0){
 			Bprint(&stderr, "embl: %r\n");
 			status = "ebml failed";
 		}
-	}else if(isorun(f) != 0){
+	}else if(isorun(&f) != 0){
 		Bprint(&stderr, "iso: %r\n");
 		status = "iso failed";
 	}
 
-	Bterm(f);
+	Bterm(&f);
 	Bterm(&out);
 	Bterm(&stderr);