9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: roger peppe <rogpeppe@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] acme(4) and addr=dot
Date: Sat,  6 Mar 2010 13:11:14 +0000	[thread overview]
Message-ID: <df49a7371003060511x3852b8b3lf91b0b224e0af507@mail.gmail.com> (raw)
In-Reply-To: <b3b4f6f31003051937g6d3821cam7f078870390c128a@mail.gmail.com>

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

the address is lost as soon as the ctl file is closed
(personally, i think this is not ideal behaviour).

under p9p i use the attached code to retrieve
the current value of acme's dot for a particular
window.

i couldn't figure out a way to do it reliably
in a shell script.

[-- Attachment #2: acmedot.c --]
[-- Type: application/octet-stream, Size: 979 bytes --]

#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9pclient.h>
#include <auth.h>
#include <thread.h>

void
threadmain(int argc, char **argv)
{
	char *id;
	CFsys *fs;
	CFid *addr, *ctl;
	char buf[100];
	int n;

	id = getenv("winid");
	if(id == nil){
		sysfatal("acmedot: not run inside acme window");
	}
	fs = nsamount("acme", nil);
	if(fs == nil){
		sysfatal("acmedot: %r");
	}

	snprint(buf, sizeof(buf), "acme/%s/addr", id);
	addr = fsopen(fs, buf, OREAD);
	if(addr == nil){
		sysfatal("acmedot: cannot open %s: %r", buf);
	}

	snprint(buf, sizeof(buf), "acme/%s/ctl", id);
	ctl = fsopen(fs, buf, ORDWR);
	if(ctl == nil){
		sysfatal("acmedot: cannot open %s: %r", buf);
	}

	strcpy(buf, "addr=dot");
	if(fswrite(ctl, buf, strlen(buf)) != strlen(buf)){
		sysfatal("acmedot: cannot set addr: %r");
	}

	n = fsread(addr, buf, sizeof(buf));
	if(n < 0){
		sysfatal("acmedot: cannot read addr: %r");
	}
	fsclose(ctl);
	fsclose(addr);
	fsunmount(fs);

	write(1, buf, n);
}

  reply	other threads:[~2010-03-06 13:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-06  3:37 Micah Stetson
2010-03-06 13:11 ` roger peppe [this message]
2010-03-06 15:13 ` David Leimbach
2010-03-06 15:16   ` erik quanstrom
2010-03-06 16:21     ` David Leimbach
2010-03-06 16:48       ` erik quanstrom
2010-03-06 19:52         ` David Leimbach
2010-03-06 18:34   ` roger peppe
2010-03-06 18:41 ` Eoghan Sherry
2010-03-06 18:54   ` Micah Stetson
2010-03-06 18:55   ` ron minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df49a7371003060511x3852b8b3lf91b0b224e0af507@mail.gmail.com \
    --to=rogpeppe@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).