Jeff Sickelimport libbiocd2d62814 years agoHistory
46 lines · 725 B · C
RawDownload
#include <fmt.h>#include "bio.h" Biobuf bout; voidbcat(Biobuf *b, char *name){	char buf[1000];	int n; 	while((n = Bread(b, buf, sizeof buf)) > 0){		if(Bwrite(&bout, buf, n) < 0)			fprint(2, "writing during %s: %r\n", name);	}	if(n < 0)		fprint(2, "reading %s: %r\n", name);	} intmain(int argc, char **argv){	int i;	Biobuf b, *bp;	Fmt fmt; 	Binit(&bout, 1, O_WRONLY);	Bfmtinit(&fmt, &bout);	fmtprint(&fmt, "hello, world\n");	Bfmtflush(&fmt); 	if(argc == 1){		Binit(&b, 0, O_RDONLY);		bcat(&b, "<stdin>");	}else{		for(i=1; i<argc; i++){			if((bp = Bopen(argv[i], O_RDONLY)) == 0){				fprint(2, "Bopen %s: %r\n", argv[i]);				continue;			}			bcat(bp, argv[i]);			Bterm(bp);		}	}	exit(0);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t