[comp.sys.hp] HP GKS GESC_FILDES question?

spirit@uxe.cso.uiuc.edu (05/11/89)

Does anybody out there use HP-GKS?

We want to be able to let users make pictures
and print them.  (GASP! What a concept.)

To do this you have to have a file descriptor
for the open workstation you are using.  To get
this file descriptor you need to call a special
"escape" function: gescape.  Here's the catch:
one of the parameters you must supply to gescape
is the file descriptor.  So according to HP to
determine the file descriptor you must already
know the file descriptor.  Brilliant!

Here is the full test code.  If anyone has had any luck with
(or use for) the gescape(fildes,GESC_FILDES,&arg1,&arg2)
call please let me know.


			John Kemp
			--------------------------------------
			University of Illinois
			Department of Atmospheric Sciences
			kemp%atmos.uiuc.edu@uxc.cso.uiuc.edu
			--------------------------------------

/*
 * test hpgks GESC_FILDES call
 */
#include <stdio.h>
#include <fgks.c.h>
#include <starbase.c.h>
#define NBYTES 0
#define ERROUT stderr
#define CONID  4
#define WSTYP  4
int i,fildes; /* set to 3 if you want it to "work" */
gescape_arg arg1, arg2;
main()
{
   /*
    *  Open the workstation and GKS
    */
    gopks( ERROUT, NBYTES );
    gopwk( 1, CONID, WSTYP );
    gacwk( 1 );

   /*
    * Call gescape to determine active file descriptor
    */
   arg1.i[0] = 1;
   arg1.i[1] = -1;
   gescape(fildes,GESC_FILDES,&arg1,&arg2);

#ifdef DEBUG
   printf("arg1.i[0] %d \n",arg1.i[0]);    
   printf("arg1.i[1] %d \n",arg1.i[1]);
   printf("arg2.i[0] %d \n",arg2.i[0]);
   printf("arg2.i[1] %d \n",arg2.i[1]);
#endif

    /*
     *   Close the workstation and shut down GKS.
     */
    gdawk ( 1 );
    gclwk ( 1 );
    gclks();
}

stroyan@hpfcdc.HP.COM (Mike Stroyan) (05/13/89)

> To do this you have to have a file descriptor
> for the open workstation you are using.  To get
> this file descriptor you need to call a special
> "escape" function: gescape.

You need to use the GKS "escape" function, gesc(), rather than the
Starbase "escape" function, gescape().  The program below demonstrates
the use of GESC_FILDES for a workstation display device.

Mike Stroyan, stroyan@hpfcla.hp.com

/*
 * test hpgks GESC_FILDES ESCAPE
 */
#include <stdio.h>
#include <fgks.c.h>
#define NBYTES 0
#define ERROUT stderr
#define CONID  5
#define WSTYP  5
main()
{
	int i, fildes;
	int ia[3], oa[3], il, lidr, lodr, dummy, errind;
	char idr[80], odr[80];

	/*
	 *  Open the workstation and GKS
	 */
	gopks( ERROUT, NBYTES );
	gopwk( 1, CONID, WSTYP );
	gacwk( 1 );

	/*
	 * Pack data record
	 */
	ia[0] = 1; /* Workstation id */
	gprec(1, ia, 0, 0, 0, 0, 0, 1, &errind, &lidr, idr);
	if ( errind )
		fprintf(stderr, "GKS error %d in function %s\n", errind, "gprec");

	/*
	 * Call gesc to determine active file descriptor
	 */
	gesc(GESC_FILDES, lidr, idr, 1, &lodr, odr);

	/*
	 * Unpack data record
	 */
	gurec(lodr, odr, 1, 0, 0, &errind, &il, oa, &dummy, 0, &dummy, 0, 0 );
	if ( errind )
		fprintf(stderr, "GKS error %d in function %s\n", errind, "gurec");

	if ( il > 0 ) {
		fildes = oa[0];
		printf("fildes = %d\n", fildes);
	}

	/*
	 *   Close the workstation and shut down GKS.
	 */
	gdawk ( 1 );
	gclwk ( 1 );
	gclks();
}