info-sather
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Show me how, please


From: Sather User
Subject: Show me how, please
Date: Fri, 8 Apr 2011 23:19:54 +0930 (CST)

I'd like to use the pSather fork statement (programmer-manual.ps
p. 199) or some other pSather syntax with a named pipe.  It seems a
natural and elegant way of doing it. Such a program would replace
something like the following, which does work, when I run it it
outputs the two lines:

0 %%BoundingBox: 257 339 355 453
1 %%HiResBoundingBox: 257.993992 339.353990 354.005989 452.645986

But if you want to write to and read from a named pipe it would seem
natural to do the system call in one thread and read from the pipe in
another, rather than having to run the gs command in the background
with & as is done here.

If you know a better way, please say, but I think there could be a
nice simple example of using pSather somewhere here.  If you have got
pSather working, i.e. you have Sather compiled for one or more of the
platforms linux/lwp, linux_at, linux_at/smp, please confess, and share
an equivalent example program and its test output.

(It is a test using the example file n6.ps, but the filename would be
a program option.  I just haven't gone into GETOPT and such.  My
interest is in rewriting such files, elminating a translate and
rewriting the bounding box so the first two numbers are 0 0 and
something very close to 0.0 0.0.  But that's a separate issue.  I'd be
interested in what you can do with this particular example.)

Incidentally, I suggest mkfifo() be put in RUNTIME.  And, the
tempnam() signature in RUNTIME is wrong.  Fix it
(Library/System/runtime.sa) before compiling this.

Regards,
Mike

--------------------------------------------------------------------
external C class OUTER is
   mkfifo(pathname:STR, mode:C_UNSIGNED_INT):C_INT;
end;
class MAIN is
   main is
      p::=STR::create_from_c_string(RUNTIME::tempnam("/tmp","bbpip"));
      q::=OUTER::mkfifo(p, 384.c_unsigned_int);
      r::=UNIX::system("gs -sDEVICE=bbox n6.ps >/dev/null 2>"+p+" &");
      f::=FILE::open_for_read(p);
      if f.error then raise "oops" end;
      s::=#FLIST{STR};
      loop
         t::=f.get_str;
         while!(~f.eof);
         s:=s.push(t)
      end;
      f.close;
      FILE::delete(p);
      loop
         i::=0.upto!(s.size-1);
         #OUT+i+" "+s[i];
      end;
   end;
end;


-- 
Michael Talbot-Wilson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]