Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!gergle.UUCP!greg From: greg@gergle.UUCP Newsgroups: comp.windows.news Subject: Re: testing cps message queue Message-ID: <8901220300.AA19541@frame.com> Date: 23 Jan 89 20:02:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 44 >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); }