Introduction
Introduction Statistics Contact Development Disclaimer Help
tit is time - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 778df25e996f8344a917fc5d3cf1b962ab728ada
parent 819822c98db971219e5b54ce5f85101c173c1cda
Author: rsc <devnull@localhost>
Date: Wed, 16 Jun 2004 23:51:51 +0000
it is time
Diffstat:
A src/cmd/auxclog.c | 63 +++++++++++++++++++++++++++++…
1 file changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/src/cmd/auxclog.c b/src/cmd/auxclog.c
t@@ -0,0 +1,63 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+char *argv0;
+
+int
+openlog(char *name)
+{
+ int fd;
+
+ fd = open(name, OWRITE);
+ if(fd < 0)
+ fd = create(name, OWRITE, DMAPPEND|0666);
+ if(fd < 0){
+ fprint(2, "%s: can't open %s: %r\n", argv0, name);
+ return -1;
+ }
+ seek(fd, 0, 2);
+ return fd;
+}
+
+void
+main(int argc, char **argv)
+{
+ Biobuf in;
+ int fd;
+ char *p, *t;
+ char buf[8192];
+
+ argv0 = argv[0];
+ if(argc < 3){
+ fprint(2, "usage: %s console logfile \n", argv0);
+ exits("usage");
+ }
+
+ fd = open(argv[1], OREAD);
+ if(fd < 0){
+ fprint(2, "%s: can't open %s: %r\n", argv0, argv[1]);
+ exits("open");
+ }
+ Binit(&in, fd, OREAD);
+
+ fd = openlog(argv[2]);
+
+ for(;;){
+ if(p = Brdline(&in, '\n')){
+ p[Blinelen(&in)-1] = 0;
+ t = ctime(time(0));
+ t[19] = 0;
+ if(fprint(fd, "%s: %s\n", t, p) < 0){
+ close(fd);
+ fd = openlog(argv[2]);
+ fprint(fd, "%s: %s\n", t, p);
+ }
+ } else if(Blinelen(&in) == 0) // true eof
+ break;
+ else {
+ Bread(&in, buf, sizeof buf);
+ }
+ }
+ exits(0);
+}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.