Hello, 9fans
In writing a program I met a problem on finding window size.
cat /dev/wctl
shows something like this:
hebe% cat /dev/wctl
456 91 1214 603 current visible
hebe%
Need DEL key to stop. I want to get this info without manual intervention.
I tried a experimental code:
#include <u.h>
#include <libc.h>
void
main(void)
{ char buf[256];
int fd,n;
fd = open("/dev/wctl",OREAD);
print("%d\n",fd);
//n = readn(fd,buf,1);//NG. buffer too small
//n = readn(fd,buf,48);//NG. truncated
//n = readn(fd,buf,56);//NG. truncated
//n = readn(fd,buf,70);//NG. truncated
n = readn(fd,buf,71);//OK, n=71
//n = readn(fd,buf,111);//OK. n=71
//n = readn(fd,buf,117);//OK. n=71
//n = readn(fd,buf,128);//NG. hungup
/* I donn't know the reasnalbe value m for readn(fd,buf,m) */
if(n < 0){
print("%r\n");
}
buf[n] = 0;
print("n=%d\n%s\n",n,buf);
close(fd);
exits(nil);
}
I don't know whether m in readn(fd,buf,m) depends on something or not.
If depends. then how to know getting OK value?
Kenji Arisawa