This is a multi-part message in MIME format.
--------------020005020609020109000905
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Stephen Leach wrote:
> Hi David,
>
>
>>I'm now working on the help system for the java poplog compiler
>
>
> Ummm, what's this? A Java compiler in Poplog? Or a Java program that
> calls out to Poplog via a Pty? Or what? Just interested.
>
Its the later. The not having any proper bindings makes this a bit
awkward, but I'm getting there...
>
>>and was wondering if anyone of you could point me to the adequate reference for the following:
>>
>>How to open a string as a character device
>
>
> I'm not sure what you mean by "a character device". If you mean a character
> repeater then the answer is -stringin- (see REF * CHARIO). If you mean
> a Poplog device you'll need -consdevice- (REF * SYSIO) and to decide on
> what level of read/write support you want to provide.
>
What I want is something like:
lvars str = 'some bunch of chars';
make_dev(str);
syswrite(str, 'hello, world'); ;;; I know thats not the syntax, I'm
;;; making this up on the fly
str=>
** hello, worldf chars
If that makes sense... I basically want to write input from a file into
a string as if the string were a file open for writing. preferably I
would like the string's length to be modifiable to fit any ammount of
data...
> Some code for using consdevice is included at the end of this message.
> It works like this ...
>
> : vars dev = string_to_device( 'foo bar gort' );
> : dev.discin.incharitem.pdtolist.explode =>
** foo bar gort
> :
>
> I don't suppose this is what you meant but it was quite fun to write.
> [You would be well advised to test my code out as I wrote it as fast
> as I can type so it is unlikely to be exactly right!]
>
>
>
>>How to open and list a directory
>
>
> Sadly the only interface to this is the hideous -sys_file_match-.
> See REF * SYSUTIL. The key to using this effectively is to set the
> full-path name flag and getting to grips with the "fname"
> procedures e.g. -sys_fname_nam- etc. (Ref * SYSUTIL again)
>
>
Thanks, I will have a look at it. If it gets me nowhere I'll write that
bit on C and load it at runtime.
>
>>How to make a character consumer that reads lists
>
>
> What do you mean by this? Is this a character consumer (i.e. a
> procedure of type char -> void) that when it has read enough
> characters that correspond to a list 'signals' it has got the
> list? Easy enough to write using -consproc-, I think. You
> write a procedure that reads a list off an item stream, but
> make the item stream grab a character from the stack and then
> call -suspend-.
>
> See REF * PROCESS.
>
> If this is really what you mean then write back saying so
> and I'll hack up the relevant code. (There's too much to
> processes to learn in a short space of time.) But I think
> I don't understand your requirements properly at this point.
>
>
Well, I tried to make a line consumer with vedfile_line_consumer and
attempted to send a list to it, but it reported an error. I would like
something that acts like pr([list]);
>
>
>>The current architecture for the system is that I will have a server (network based) running a pop11 process that served the documents required. I had to do this because I will need to use readline() in the procedure and if readline is put on a loop then no more code can be sent to the pop11 procedure as it would be read as an input line.
>
>
> Didn't understand this.
>
>
basically, the poplog process is reading from a pipe from a java
process, when I send information I only have this one pipe, so if the
code looks like this:
while true do
readline=>
endwhile;
some_more_code();
I get
** some_more_code();
for everyline thereafter. That is most unhelpful...
>
>>Besides that having a server is cool because you can just telnet to it and get the documents without the need to run the compiler in your own system :)
>
>
> Although security could be a problem? Poplog is not very easy to write
> secure servers with - unless you are reasonably serious and do it
> properly with the asynchronous calls (REF * ASYNC) interface. Watch
> out for security problems caused by sending SIGINT, for example.
>
The server is being implemented in java. I figured out that making a
server in pop11 would take me way longer than its worth it. The pop11
code is still for a server, just not a network one. I just have a
service loop and java feeds strings into it and reads its output, then
java sends that through the network for the client. Hope it makes sense...
> ;;; -- Code for using consdevice ---
> ...
Here is the code I have written so far, It will probably help you
understand what I want (attached)
--
=================================================
The future of HTML mail is clearly > /dev/null.
=================================================
Two of the most famous products of Berkeley are
LSD and Unix. I don t think that is a coincidence
=================================================
--------------020005020609020109000905
Content-Type: text/plain;
name="server.p"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="server.p"
/****************************************************************
* *
* File: server.p *
* Author: dsm *
* Created: Mon Aug 11 2003 *
* Version: 0.0.9 *
* *
* This file contains the instructions necessary to make pop11 *
* serve documents like ref, doc, help and teach files. *
* *
* All the stuff is printed to stdout as plain ascii and *
* collected by the java container, then its prepended the *
* message string and sent to the client that requested it. *
* *
****************************************************************/
/* filter: Filters a file containing ved control chars. Definition of filter shamelessly stolen
* from REF * VEDPROCS
* filein: The file to convert to ASCII
* fileout: A writable file to which the results will be printed (can be popdevout if is to be sent
* to stdout for example).
* retval: a string with the file in ascii
*/
define filter(filein, fileout) -> retval;
lvars repeater, consumer, str;
vedfile_line_repeater(filein) -> repeater;
vedfile_line_consumer(fileout, 1) -> consumer;
until (repeater() ->> str) == termin do
consumer(str);
enduntil;
enddefine;
/* getFileInASCII: Gets a file and converts all the control chars to ASCII, then returns the
* contents of the file
* filename: The name of the file to make ASCII
* retval: The resulting ASCII from the contents of file
*/
define getFileInASCII(filename) -> retval;
''->retval;
;;; open filename
;;; make a string device (REF CHARIO)
;;; use filter to make file into plain text and store in string
;;; return string
enddefine;
/* open: Opens a file
* args: The argument list. Defines the file to open
* retval: A list of lines of the file, like [[first line] [second line] [third line]]
*/
define open(args) -> retval;
if listlength(args) = 1 then
pr('doing default open');nl(1);
elseif listlength(args) > 1 then
pr('doing open with args');nl(1);
else
pr('I\'m afraid I can\'t open with no args at all');nl(1);
endif;
enddefine;
/* listDir: Lists a directory in the form listDir("/some/dir/") = [(F)filename (D)subdir
* (F)subdir/file etc..]
* dirname: The name of the directory to list
* retval: A list of files or directories in dirname
*/
define listDir(dirname) -> retval;
[]->retval;
if dirname = "teach"
or dirname = "doc"
or dirname = "ref"
or dirname = "help" then
return;
endif;
;;; list dirname
enddefine;
/* listList: Lists the dir contents of a list working with listDir()
* list: The list to list
* retval: The listing of list
*/
define listList(list) -> retval;
lvars i, o;
[]-> retval;
for i in list do
if islist(i) then
retval<>listList(i) -> retval;
elseif isident(i) then
retval<>listList(idval(i)) -> retval;
else
retval<>listDir(i) -> retval;
endif;
endfor;
enddefine;
/* listRef: Lists the contents of REF
*/
define listRef() -> retval;
listList(vedreflist) -> retval;
enddefine;
/* listTeach: Lists the contents of TEACH
*/
define listTeach() -> retval;
listList(vedteachlist) -> retval;
enddefine;
/* listHelp: Lists the contents of HELP
*/
define listHelp() -> retval;
listList(vedhelplist) -> retval;
enddefine;
/* listDoc: Lists the contents of DOC
*/
define listDoc() -> retval;
listList(veddoclist) -> retval;
enddefine;
/* list: lists a doc directory
* args: The argument lst. Defines the doc directory to list
* retval: A list with either an error message or a number of lists containing the listing
*/
define list(args) -> retval;
if listlength(args) = 1 then ;;; list from args
if args matches [REF] then
listRef() -> retval;
elseif args matches [HELP] then
listHelp() -> retval;
elseif args matches [TEACH] then
listTeach() -> retval;
elseif args matches [DOC] then
listDoc() -> retval;
else
[the category ^^args does not exist] -> retval;
endif;
elseif listlength(args) > 1 then ;;; error
[too many arguments ^^args for list] -> retval;
else ;;; list everything
listRef()<>listHelp()<>listTeach()<>listDoc()->retval;
endif;
enddefine;
/* main: Main procedure. It contains the service loop.
*/
define main();
vars input;
vars args;
/* service loop */
while true do
readline() -> input;
if input matches [LIST ??args] then
pr(list(args))nl(1);
elseif input matches [OPEN ??args] then
pr(open(args));nl(1);
else
pr([I\'m afraid I can\'t deal with that]);nl(1);
endif;
endwhile;
enddefine;
;;; now just run it all
main();
--------------020005020609020109000905--
|