[comp.windows.news] testing cps message queue

"bryan_kramer.TORHO"@XEROX.COM (01/21/89)

I have C plus CPS code that would really benefit from knowing when there is
no input waiting  on PostScriptInput (ie. all the current cps commands from
the NeWS server have been handled).  One application involves holding a
repaint request until all other current requests (user input) have been
handled.
Could someone please tell me how to do this?  I am using a sun4-110 with
OS4.01?
From my search of the manuals I gather that using SYSTEM V reads might
solve
the problem although I haven't really studied the details.  Of course, the
CPS
calls use regular io.

Any light that can be shed on this topic would be very much appreciated.

Thanks
Bryan Kramer
Xerox Canada Inc.
bryan_kramer.torho@xerox.com
(416) 733-6377

greg@gergle.UUCP (01/24/89)

>I have C plus CPS code that would really benefit from knowing when there is
>no input waiting  on PostScriptInput (ie. all the current cps commands from
>the NeWS server have been handled).  One application involves holding a
>repaint request until all other current requests (user input) have been
>handled.
>Could someone please tell me how to do this?  I am using a sun4-110 with
>OS4.01?

Here is a code frag which works for me. I have never tried running under
OS4.0. Please let me know if it works. block would be false in your case.
EVENTL is the minimum event length you expect to read.

	-greg.



	if(block) 
                avail = EVENTL;
        else {
                avail = psio_availinputbytes(PostScriptInput);
                if(avail < EVENTL) 
			{
                         ioctl(psio_fileno(PostScriptInput),FIONREAD,&bytes);
                         avail += bytes;
                        }
                }

        while(avail >= EVENTL) {
                if(psio_error(PostScriptInput)) {
                        fprintf(stderr,"PostScriptInput error\n"); 
                        exit(1);
                        }


                c = psio_getc(PostScriptInput);

	/* handling of input, CPS typed reads */
	/* handling of input, CPS typed reads */
	/* handling of input, CPS typed reads */
	/* handling of input, CPS typed reads */

                avail = psio_availinputbytes(PostScriptInput);
                }