lpwrite
印字する。
lpwrite()
{
register int c;
while ((c=cpass())>=0)
lpcanon(c);
}
cpass
1バイトずつシステムコールで渡されたデータを取ってくる。
u_baseがバッファのアドレス
/* * Pick up and return the next character from the user's * write call at location u_base; * update u_base, u_count, and u_offset. Return -1 * when u_count is exhausted. u_base is in the user's * address space unless u_segflg is set. */ cpass() { register c; if(u.u_count == 0) return(-1); if(u.u_segflg) c = *u.u_base; else if((c=fubyte(u.u_base)) < 0) { u.u_error = EFAULT; return(-1); } u.u_count--; if(++u.u_offset[1] == 0) u.u_offset[0]++; u.u_base++; return(c&0377); }
elseの書き方が変。
アドレスだがsegflgを見ないと分からない。
cpass()
{
register c;
if(u.u_count == 0)
return(-1);
if(u.u_segflg)
c = *u.u_base;
} else if((c=fubyte(u.u_base)) < 0) {
u.u_error = EFAULT;
return(-1);
}
u.u_count--;
if(++u.u_offset[1] == 0)
u.u_offset[0]++;
u.u_base++;
return(c&0377);
}