/* size.c 1.1 */ /* Copyright 1992, 1993 O'Reilly and Associates, Inc. Permission to use, copy, and modify this program is hereby granted, as long as this copyright notice appears in each copy of the program source code. */ #include "book_utils.h" int oc_size_ok( dpy, oc_data ) Display *dpy; PEXOCData *oc_data; { unsigned long max_oc_bytes; int float_format, oc_size; /* Determine the largest OC size. */ max_oc_bytes = 4 * (XMaxRequestSize( dpy ) - 4); /* Determine the size of this OC. */ float_format = PEXGetProtocolFloatFormat( dpy ); oc_size = PEXGetSizeOCs( float_format, 1, oc_data ); return (oc_size <= max_oc_bytes) ? 1 : 0; } main( argc, argv ) int argc; char *argv[]; { Display *dpy; PEXOCData oc_data; PEXExtensionInfo *pexinfo; static PEXCoord points[] = {{0,0,0},{1,1,1},{2,2,2}}; /* Open a display and initialize PEX. */ dpy = ora_init_pex( argv, &pexinfo ); if ( !dpy ) exit(1); oc_data.oc_type = PEXOCPolyline; oc_data.data.Polyline.count = sizeof(points)/sizeof(points[0]); oc_data.data.Polyline.points = points; if ( oc_size_ok( dpy, &oc_data ) ) printf( "OC Okay\n" ); else printf( "OC too large\n" ); }