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

How does KCL implement STREAMS ?



   I'm having problems interfacing  KCL with some  C routines, and probably
there are many people on this list who can give us enlightning explanations
on that topic.


   Basically,  I would like to pass  a KCL stream  to a C function.   The C
function has to find the Unix stream which is buried inside the KCL stream.
I looked at file "object.h" in the KCL sources,  to find  that a KCL stream
is built the following way:

	struct stream {
		short	t, m;
		FILE	*sm_fp;		/*  file pointer  */
		object	sm_object0;	/*  some object  */
		object	sm_object1;	/*  some object */
		int	sm_int0;	/*  some int  */
		int	sm_int1;	/*  some int  */
		short	sm_mode;	/*  stream mode  */
					/*  of enum smmode  */
	};

where sm_mode is one of:

	enum smmode {			/*  stream mode  */
		smm_input,		/*  input  */
		smm_output,		/*  output  */
		smm_io,			/*  input-output  */
		smm_probe,		/*  probe  */
		smm_synonym,		/*  synonym  */
		smm_broadcast,		/*  broadcast  */
		smm_concatenated,	/*  concatenated  */
		smm_two_way,		/*  two way  */
		smm_echo,		/*  echo  */
		smm_string_input,	/*  string input  */
		smm_string_output	/*  string output  */
	};

   The comments on fields sm_object0 and sm_object1 did not help me much in
understanding the purpose of these fields. Anyway, I followed sm_object0 in
case of a synonym stream, and this worked. At the moment,  it seems  that I
have a working solution for some usual  situations, but  I certainly do not
understand how it works !

   Could  a knowledgeable hacker  explains us   the details of  what  these
fields  are for, what  they mean, when  they  are relevant  ?  This kind of
explanation about the internals   of a lisp implementation  would  probably
interest several people (if it is clear enough) and encourage many of us to
look at the source.

Much thanks in advance,
--
Philippe SCHNOEBELEN,				Best:        phs@lifia.imag.fr
LIFIA - INPG,
46, Avenue Felix VIALLET			2nd:		phs@lifia.UUCP
38000 Grenoble, FRANCE				last: ..!mcvax!inria!lifia!phs

"Algebraic symbols are used when you do not know what you are talking about."