Plan 9 from Bell Labs’s /usr/web/sources/contrib/maht/limbo/cmd/cmd.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


implement Cmds;

include "sys.m";
	sys: Sys;
include "draw.m";
	Context: import Draw;

include "bufio.m";
	bufio : Bufio;
	Iobuf: import bufio;

include "cmd.m";


init(nil: ref Context, nil: list of string)
{
	sys = load Sys Sys->PATH;
	bufio = load Bufio Bufio->PATH;
}

new_cmd() : ref Cmd 
{
	n := array[15] of byte; # too lazy to find out proper length
	clone := sys->open("/cmd/clone", Sys->OREAD);
	if(clone == nil) raise "perhaps you didn't do bind -a \"#C\" /";
	n[sys->read(clone, n, len n -1)] = byte 0;

	ctl := sys->open("/cmd/" + string n + "/ctl", Sys->ORDWR);
	out := sys->open("/cmd/" + string n + "/data", Sys->OWRITE);
	in := sys->open("/cmd/" + string n + "/data", Sys->OREAD);

	return ref Cmd(nil, nil, clone, nil);
}

Cmd.wctl(c : self ref Cmd, msg : string)
{
	c.ctl.puts(msg + "\n");
	c.ctl.flush();
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.