11 while(lb->wait && lb->rp != lb->wp){
15 lb->waitlast = &lb->wait;
17 if(r->ifcall.count < 5){
18 respond(r, "factotum: read request count too short");
22 lb->msg[lb->rp] = nil;
23 if(++lb->rp == nelem(lb->msg))
26 if(n < strlen(s)+1+1){
27 memmove(r->ofcall.data, s, n-5);
29 r->ofcall.data[n] = '\0';
30 /* look for first byte of UTF-8 sequence by skipping continuation bytes */
31 while(n>0 && (r->ofcall.data[--n]&0xC0)==0x80)
33 strcpy(r->ofcall.data+n, "...\n");
35 strcpy(r->ofcall.data, s);
36 strcat(r->ofcall.data, "\n");
38 r->ofcall.count = strlen(r->ofcall.data);
45 lbread(Logbuf *lb, Req *r)
47 if(lb->waitlast == nil)
48 lb->waitlast = &lb->wait;
50 lb->waitlast = (Req**)&r->aux;
56 lbflush(Logbuf *lb, Req *r)
60 for(l=&lb->wait; *l; l=(Req**)&(*l)->aux){
73 lbappend(Logbuf *lb, char *fmt, ...)
78 lbvappend(lb, fmt, arg);
83 lbvappend(Logbuf *lb, char *fmt, va_list arg)
87 s = smprint(fmt, arg);
89 sysfatal("out of memory");
91 free(lb->msg[lb->wp]);
93 if(++lb->wp == nelem(lb->msg))
118 lbvappend(&logbuf, fmt, arg);