9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] /sys/lib/libauth/newns.c patch to add `.' command, handle quoting.
@ 2003-02-27 16:30 Dan Cross
  0 siblings, 0 replies; only message in thread
From: Dan Cross @ 2003-02-27 16:30 UTC (permalink / raw)
  To: 9fans; +Cc: 9trouble

A while back I mentioned that I had modified newns.c to add a ``.''
command to source namespace commands from other files.  I also changed
splitargs() within newns.c to call tokenize instead of doing it's own
tokenization; this allows it to correctly deal with quoted tokens (like
#rune, as returned by ns).  I think these changes are handy enough to
share; I'm using them all over the place now.  In particular, I added
the following to the end of my /lib/namespace:

. /lib/local.namespace

This allows me to easily make custom changes to my namespace without
a maintenance hassle; usually, one wants to add something, not take
it away, from a common core.  This makes doing that pretty trivial,
as I can just add local customizations to /lib/local.namespace and
have them apply to all hosts on my network (note: the name is
local.namespace instead of namespace.local to avoid clashes if you
added a host named, ``local'' to your network; newns() still looks
for /lib/namespace.$sysname, and uses that to override /lib/namespace
if it exists).  Note that at the end of /lib/local.namespace, I have:

. /lib/$sysname.namespace

To pick up system dependent namespace changes.  This is preferable
to /lib/namespace.$sysname since it allows me to add a delta to my
common namespace, instead of overriding it completely.

It'd be nice to see this stuff go onto sources.

	- Dan C.

All diffs are in diff -e format.  The diff for /lib/namespace is trivial:

term% diff -e /n/sources/plan9/lib/namespace /lib/namespace
28a
# site dependent
. /lib/local.namespace

.
term%

And the changes to newns.c are:

241a
		if(q && q < arg)
			arg = q;
		q = utfrune(p, L'.');
.
213c
	if (n == (maxargsplus1 - 1))
		return 0;
	return n;
.
210c
		if (!argbuf)
.
197,208c
	n = tokenize(p, argv, maxargsplus1);
	for (i = 0; i < n; i++) {
		q = argv[i];
		argv[i] = argbuf;
.
195c
	int i, n;
.
192c
splitargs(char *p, char *argv[], char *argbuf, int maxargsplus1)
.
136c
	if(strcmp(argv0, ".") == 0 && argc == 1){
		Biobuf *spec;
		spec = Bopen(argv[0], OREAD);
		if(spec == nil){
			werrstr("can't open %s: %r", argv[0]);
			return;
		}
		nsfile(spec, rpc);
		Bterm(spec);
	}else if(strcmp(argv0, "bind") == 0 && argc == 2)
.
74,79d
69c
		argc = splitargs(cmd, argv, argbuf, NARG + 1);
.
61a
	nsfile(spec, rpc);
	Bterm(spec);
	if(rpc){
		close(rpc->afd);
		auth_freerpc(rpc);
	}
	return 0;
}

static void
nsfile(Biobuf *spec, AuthRpc *rpc)
{
	int argc;
	char *cmd, *argv[NARG + 1], argbuf[MAXARG*NARG];

.
27d
25d
16a
static void nsfile(Biobuf *, AuthRpc *);
.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-27 16:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 16:30 [9fans] /sys/lib/libauth/newns.c patch to add `.' command, handle quoting Dan Cross

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).