diff options
| author | rsc <devnull@localhost> | 2005-02-13 05:58:45 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2005-02-13 05:58:45 +0000 |
| commit | 0f8ec41b0ae522b73085fa1662461e6351ba7e54 (patch) | |
| tree | 2d54cfd8208bdd903273ccc7df889677cf7fe8d5 /src/cmd/factotum/log.c | |
| parent | 7637c81af02c49ef508b946dfdec39f757a658d4 (diff) | |
| download | plan9port-0f8ec41b0ae522b73085fa1662461e6351ba7e54.tar.gz plan9port-0f8ec41b0ae522b73085fa1662461e6351ba7e54.zip | |
moving to auth
Diffstat (limited to 'src/cmd/factotum/log.c')
| -rw-r--r-- | src/cmd/factotum/log.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/src/cmd/factotum/log.c b/src/cmd/factotum/log.c deleted file mode 100644 index 6c2d69dd..00000000 --- a/src/cmd/factotum/log.c +++ /dev/null @@ -1,121 +0,0 @@ -#include "std.h" -#include "dat.h" - -void -lbkick(Logbuf *lb) -{ - char *s; - int n; - Req *r; - - while(lb->wait && lb->rp != lb->wp){ - r = lb->wait; - lb->wait = r->aux; - if(lb->wait == nil) - lb->waitlast = &lb->wait; - r->aux = nil; - if(r->ifcall.count < 5){ - respond(r, "factotum: read request count too short"); - continue; - } - s = lb->msg[lb->rp]; - lb->msg[lb->rp] = nil; - if(++lb->rp == nelem(lb->msg)) - lb->rp = 0; - n = r->ifcall.count; - if(n < strlen(s)+1+1){ - memmove(r->ofcall.data, s, n-5); - n -= 5; - r->ofcall.data[n] = '\0'; - /* look for first byte of UTF-8 sequence by skipping continuation bytes */ - while(n>0 && (r->ofcall.data[--n]&0xC0)==0x80) - ; - strcpy(r->ofcall.data+n, "...\n"); - }else{ - strcpy(r->ofcall.data, s); - strcat(r->ofcall.data, "\n"); - } - r->ofcall.count = strlen(r->ofcall.data); - free(s); - respond(r, nil); - } -} - -void -lbread(Logbuf *lb, Req *r) -{ - if(lb->waitlast == nil) - lb->waitlast = &lb->wait; - *(lb->waitlast) = r; - lb->waitlast = (Req**)&r->aux; - r->aux = nil; - lbkick(lb); -} - -void -lbflush(Logbuf *lb, Req *r) -{ - Req **l; - - for(l=&lb->wait; *l; l=(Req**)&(*l)->aux){ - if(*l == r){ - *l = r->aux; - r->aux = nil; - if(*l == nil) - lb->waitlast = l; - closereq(r); - break; - } - } -} - -void -lbappend(Logbuf *lb, char *fmt, ...) -{ - va_list arg; - - va_start(arg, fmt); - lbvappend(lb, fmt, arg); - va_end(arg); -} - -void -lbvappend(Logbuf *lb, char *fmt, va_list arg) -{ - char *s; - - s = smprint(fmt, arg); - if(s == nil) - sysfatal("out of memory"); - if(lb->msg[lb->wp]) - free(lb->msg[lb->wp]); - lb->msg[lb->wp] = s; - if(++lb->wp == nelem(lb->msg)) - lb->wp = 0; - lbkick(lb); -} - -Logbuf logbuf; - -void -logread(Req *r) -{ - lbread(&logbuf, r); -} - -void -logflush(Req *r) -{ - lbflush(&logbuf, r); -} - -void -flog(char *fmt, ...) -{ - va_list arg; - - va_start(arg, fmt); - lbvappend(&logbuf, fmt, arg); - va_end(arg); -} - |
