[comp.sources.wanted] C source to invoke pager on stdout.

bills@sequent.com (Bill Sears) (05/23/91)

This seems like such a useful function, I can't believe that someone
somewhere hasn't developed such a beastie (or at least something like
it).

I need source for a C function which, when called, sets up a pipe from
stdout into a pager (more, less, etc.).  I would also like this to be
"undoable".  That is, I want to be able to make the pager terminate
and redirect the output to return to regular old stdout mode.  Something
like the following would be a typical invokation:

    printf("this is on stdout.\n");
    printf("this is on stdout too.\n");
    printf("this is on stdout three :-).\n");

    pager();			/* Now send stuff through a pager */

    printf("this goes into the pager\n");
    printf("another line into the pager\n");
    printf("still another line into the pager\n");
    printf("yet another line into the pager\n");
    printf("this is the last line into the pager\n");

    end_pager();		/* Done using the pager */

    printf("this goes straight to the screen\n");
    printf("this goes straight to the screen too\n");
    printf("and so does this");

The different shells (sh, csh, ksh, etc.) do this type of thing when they
set up pipes.  I'm looking for a C function that will do essentially the
same thing (without the shell overhead).
-- 
Bill Sears            Sequent Computer Systems            bills@sequent.com

Women and cats do as they please, men and dogs had best learn to live with it.