include "styxconv.m"; styxconv := load Styxconv Styxconv->PATH; init: fn(); styxconv: fn(to: ref Sys->FD, from: ref Sys->FD, pid: chan of int);
Init must be called before any other function in the module.
The function styxconv takes two file descriptors. From must be a connection to a file server that serves the original, older version of Styx. To is a connection, perhaps a pipe, to something that requires the current protocol; Sys->mount for instance (see sys-bind(2)). Styxconv is spawned by the caller, to create a process that copies messages between from and to, converting as required as it goes. Its process ID is the only message sent on channel pidc; it must be received by styxconv's caller. See the example below.
cvstyx(fd: ref Sys->FD): ref Sys->FD { styxconv := load Styxconv Styxconv->PATH; if(styxconv == nil) return nil; p := array[2] of ref Sys->FD; if(sys->pipe(p) < 0) return nil; styxconv->init(); pidc := chan of int; spawn styxconv->styxconv(p[1], fd, pidc); <-pidc; return p[0]; }
STYXCONV(2 ) | Rev: Sun Feb 22 17:41:21 GMT 2009 |