Added an option to add s at line end as there is no other (obvious) way of sending raw data to, for example, a printer. Notes: Wed Jun 16 13:22:39 EDT 2004 rsc You could do this with aux/clog | sed 's/$/ /g' > /dev/lpt1data I don't think clog is sufficiently specific to writing to devices requiring CRs in order to make this change. Russ Reference: /n/sources/patch/sorry/clogldr01 Date: Wed Jun 16 19:23:29 CES 2004 Reviewed-by: rsc --- /sys/src/cmd/aux/clog.c Wed Jun 16 19:23:29 2004 +++ /sys/src/cmd/aux/clog.c Wed Jun 16 19:23:29 2004 @@ -2,7 +2,7 @@ #include #include -char *argv0; +static char *delim = "\n"; int openlog(char *name) @@ -21,6 +21,12 @@ } void +usage (char *argv0) +{ + fprint(2, "usage: %s [-r] console logfile\n", argv0); +} + +void main(int argc, char **argv) { Biobuf in; @@ -28,30 +34,37 @@ char *p, *t; char buf[8192]; - argv0 = argv[0]; - if(argc < 3){ - fprint(2, "usage: %s console logfile \n", argv0); + ARGBEGIN { + case 'r': + delim = "\r\n"; + break; + default: + usage(argv0); + exits("usage"); + } ARGEND + if(argc < 2){ + usage(argv0); exits("usage"); } - fd = open(argv[1], OREAD); + fd = open(argv[0], OREAD); if(fd < 0){ - fprint(2, "%s: can't open %s: %r\n", argv0, argv[1]); + fprint(2, "%s: can't open %s: %r\n", argv0, argv[0]); exits("open"); } Binit(&in, fd, OREAD); - fd = openlog(argv[2]); + fd = openlog(argv[1]); 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){ + if(fprint(fd, "%s: %s%s", t, p, delim) < 0){ close(fd); fd = openlog(argv[2]); - fprint(fd, "%s: %s\n", t, p); + fprint(fd, "%s: %s%s", t, p, delim); } } else if(Blinelen(&in) == 0) // true eof break;