9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] wctl
@ 2023-05-09  3:31 有澤健治
  2023-05-09  6:11 ` umbraticus
  0 siblings, 1 reply; 6+ messages in thread
From: 有澤健治 @ 2023-05-09  3:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]

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

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-M60ccbc9ae01219d2e2f46c4f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 2141 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] wctl
  2023-05-09  3:31 [9fans] wctl 有澤健治
@ 2023-05-09  6:11 ` umbraticus
  2023-05-09  7:59   ` Richard Miller
  0 siblings, 1 reply; 6+ messages in thread
From: umbraticus @ 2023-05-09  6:11 UTC (permalink / raw)
  To: 9fans

; read -c 72 /dev/wctl

rio(4)

umbraticus

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-Ma0337129de0681f834f7e7c7
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] wctl
  2023-05-09  6:11 ` umbraticus
@ 2023-05-09  7:59   ` Richard Miller
  2023-05-09 13:01     ` 有澤健治
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Miller @ 2023-05-09  7:59 UTC (permalink / raw)
  To: 9fans

> ; read -c 72 /dev/wctl

Or, if your chosen flavour of Plan 9 doesn't have the 'read -c'
option, one of these will do:

dd -if /dev/wctl -bs 72 -count 1 -quiet 1
syscall -o read 0 buf 72 </dev/wctl >[2]/dev/null


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-Mdd9f3de6c6653fc343ffc333
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] wctl
  2023-05-09  7:59   ` Richard Miller
@ 2023-05-09 13:01     ` 有澤健治
  2023-05-09 15:04       ` sirjofri
  0 siblings, 1 reply; 6+ messages in thread
From: 有澤健治 @ 2023-05-09 13:01 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

Thanks for umbraticus and Richard.

The value 72 is experimentally OK.
However I am not convinced yet.
I can't find the value in the manual.

Kenji Arisawa

2023年5月9日(火) 17:00 Richard Miller <9fans@hamnavoe.com>:

> > ; read -c 72 /dev/wctl
> 
> Or, if your chosen flavour of Plan 9 doesn't have the 'read -c'
> option, one of these will do:
> 
> dd -if /dev/wctl -bs 72 -count 1 -quiet 1
> syscall -o read 0 buf 72 </dev/wctl >[2]/dev/null
> 

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-M429a1a214f0fb13d9c461eda
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 1995 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] wctl
  2023-05-09 13:01     ` 有澤健治
@ 2023-05-09 15:04       ` sirjofri
  2023-05-09 21:17         ` 有澤健治
  0 siblings, 1 reply; 6+ messages in thread
From: sirjofri @ 2023-05-09 15:04 UTC (permalink / raw)
  To: 9fans


09.05.2023 15:04:07 有澤健治 <karisawa@gmail.com>:

> Thanks for umbraticus and Richard.
>
> The value 72 is experimentally OK.
> However I am not convinced yet.
> I can't find the value in the manual.

Not experimentally. According to rio(4), it's 4 values padded to 12 chars, plus the window state as two strings, also padded to 12. If you do the math: 6*12=72.

sirjofri

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-M653f4f77683fc542820c5944
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] wctl
  2023-05-09 15:04       ` sirjofri
@ 2023-05-09 21:17         ` 有澤健治
  0 siblings, 0 replies; 6+ messages in thread
From: 有澤健治 @ 2023-05-09 21:17 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

Thanks. sirjofri

OK. I have understood!
I have misunderstood the meaning "padded".
Sorry for may poor english.

2023年5月10日(水) 0:06 sirjofri <sirjofri+ml-9fans@sirjofri.de>:

>
> 09.05.2023 15:04:07 有澤健治 <karisawa@gmail.com>:
>
> > Thanks for umbraticus and Richard.
> >
> > The value 72 is experimentally OK.
> > However I am not convinced yet.
> > I can't find the value in the manual.
> 
> Not experimentally. According to rio(4), it's 4 values padded to 12 chars,
> plus the window state as two strings, also padded to 12. If you do the
> math: 6*12=72.
> 
> sirjofri

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-M43294eac9d9b73dec4e91cc7
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 2241 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-09 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09  3:31 [9fans] wctl 有澤健治
2023-05-09  6:11 ` umbraticus
2023-05-09  7:59   ` Richard Miller
2023-05-09 13:01     ` 有澤健治
2023-05-09 15:04       ` sirjofri
2023-05-09 21:17         ` 有澤健治

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).