netlog()

netlog()

概要

引数

  • f -- Fs
  • mask
  • fmt

実装

  227: void
  228: netlog(Fs *f, int mask, char *fmt, ...)
  229: {
  230:         char buf[128], *t, *fp;
  231:         int i, n;
  232:         va_list arg;
  233: 
  234:         if(!(f->alog->logmask & mask))
  235:                 return;
  236: 
  237:         if(f->alog->opens == 0)
  238:                 return;
  239: 
  240:         va_start(arg, fmt);
  241:         n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf;
  • 詳細はvseprint()?を参照
  242:         va_end(arg);
  243: 
  244:         lock(f->alog);
  245:         i = f->alog->len + n - Nlog;
  246:         if(i > 0){
  247:                 f->alog->len -= i;
  248:                 f->alog->rptr += i;
  249:                 if(f->alog->rptr >= f->alog->end)
  250:                         f->alog->rptr = f->alog->buf + (f->alog->rptr - f->alog->end);
  251:         }
  252:         t = f->alog->rptr + f->alog->len;
  253:         fp = buf;
  254:         f->alog->len += n;
  255:         while(n-- > 0){
  256:                 if(t >= f->alog->end)
  257:                         t = f->alog->buf + (t - f->alog->end);
  258:                 *t++ = *fp++;
  259:         }
  260:         unlock(f->alog);
  261: 
  262:         wakeup(f->alog);
  263: }