71 if ( pls->plbufFile != NULL )
99 wr_data( pls, xpl,
sizeof (
short ) * 2 );
100 wr_data( pls, ypl,
sizeof (
short ) * 2 );
118 wr_data( pls, xa,
sizeof (
short ) * (
size_t) npts );
119 wr_data( pls, ya,
sizeof (
short ) * (
size_t) npts );
154 if ( pls->plbufFile == NULL )
155 plexit(
"plbuf_bop: Error opening plot data storage file." );
164 plexit(
"plbuf_bop: Error allocating plot buffer." );
194 if (
pls->plbufFile == NULL )
197 fclose(
pls->plbufFile )
198 pls->plbufFile = NULL;
268 wr_data( pls, pls->
dev_ix, sizeof (
short ) * (
size_t) npts );
269 wr_data( pls, pls->
dev_iy, sizeof (
short ) * (
size_t) npts );
473 short xpl[2], ypl[2];
478 rd_data( pls, xpl,
sizeof (
short ) * (
size_t) npts );
479 rd_data( pls, ypl,
sizeof (
short ) * (
size_t) npts );
503 xpl = (
short *) malloc( (
size_t) ( npts + 1 ) *
sizeof (
short ) );
504 ypl = (
short *) malloc( (
size_t) ( npts + 1 ) *
sizeof (
short ) );
506 if ( ( xpl == NULL ) || ( ypl == NULL ) )
508 plexit(
"rdbuf_polyline: Insufficient memory for large polyline" );
518 rd_data( pls, xpl,
sizeof (
short ) * (
size_t) npts );
519 rd_data( pls, ypl,
sizeof (
short ) * (
size_t) npts );
588 rd_data( pls, &icol0,
sizeof (
short ) );
598 if ( (
int) icol0 >= pls->
ncol0 )
601 snprintf( buffer, 256,
"rdbuf_state: Invalid color map entry: %d", (
int) icol0 );
623 rd_data( pls, &icol1,
sizeof (
short ) );
638 rd_data( pls, &patt,
sizeof (
signed char ) );
739 xpl = (
short *) malloc( (
size_t) ( npts + 1 ) *
sizeof (
short ) );
740 ypl = (
short *) malloc( (
size_t) ( npts + 1 ) *
sizeof (
short ) );
742 if ( ( xpl == NULL ) || ( ypl == NULL ) )
744 plexit(
"rdbuf_polyline: Insufficient memory for large polyline" );
753 rd_data( pls, xpl,
sizeof (
short ) * (
size_t) npts );
754 rd_data( pls, ypl,
sizeof (
short ) * (
size_t) npts );
780 short *dev_ix, *dev_iy = NULL;
781 unsigned short *dev_z = NULL, dev_zmin, dev_zmax;
782 PLINT nptsX, nptsY, npts;
789 npts = nptsX * nptsY;
796 rd_data( pls, &dev_zmin,
sizeof (
short ) );
797 rd_data( pls, &dev_zmax,
sizeof (
short ) );
803 if ( ( ( dev_ix = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
804 ( ( dev_iy = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
805 ( ( dev_z = (
unsigned short *) malloc( (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) *
sizeof (
unsigned short ) ) ) == NULL ) )
806 plexit(
"rdbuf_image: Insufficient memory" );
808 rd_data( pls, dev_ix,
sizeof (
short ) * (
size_t) npts );
809 rd_data( pls, dev_iy,
sizeof (
short ) * (
size_t) npts );
810 rd_data( pls, dev_z,
sizeof (
unsigned short ) * (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) );
891 plexit(
"rdbuf_text: Insufficient memory" );
982 if ( pls->plbufFile )
984 rewind( pls->plbufFile );
1053 pldebug(
"plbuf_control",
"Unrecognized command %d, previous %d\n", c, c_old );
1069 #ifdef BUFFERED_FILE
1070 count = fread( p_c,
sizeof (
U_CHAR ), 1, pls->plbufFile );
1076 count =
sizeof (
U_CHAR );
1095 #ifdef BUFFERED_FILE
1096 plio_fread( buf, buf_size, 1, pls->plbufFile );
1116 #ifdef BUFFERED_FILE
1127 plexit(
"plbuf wr_data: Plot buffer grow failed" );
1144 #ifdef BUFFERED_FILE
1158 plexit(
"plbuf wr_data: Plot buffer grow failed" );
1197 #ifdef BUFFERED_FILE
1224 save_size =
sizeof (
struct _state )
1226 + (size_t) ( pls->ncol0 ) *
sizeof (
PLColor )
1227 + (
size_t) ( pls->ncol1 ) *
sizeof (
PLColor );
1229 #ifndef BUFFERED_FILE
1231 save_size += pls->plbuf_top;
1235 if ( state != NULL )
1238 if ( plot_state->
size < save_size )
1241 if ( ( plot_state = (
struct _state *) realloc( state, save_size ) ) == NULL )
1247 plwarn(
"plbuf: Unable to reallocate sufficient memory to save state" );
1248 plot_state->
valid = 0;
1252 plot_state->
size = save_size;
1258 if ( ( plot_state = (
struct _state *) malloc( save_size ) ) == NULL )
1260 plwarn(
"plbuf: Unable to allocate sufficient memory to save state" );
1264 plot_state->
size = save_size;
1266 #ifdef BUFFERED_FILE
1268 plot_state->plbufFile = NULL;
1278 plot_state->
valid = 0;
1281 buf = (
U_CHAR *) ( plot_state + 1 );
1283 #ifdef BUFFERED_FILE
1285 if ( plot_state->plbufFile != NULL )
1287 fclose( plot_state->plbufFile );
1296 plwarn(
"plbuf: Unable to open temporary file to save state" );
1297 return (
void *) plot_state;
1303 rewind( pls->plbufFile );
1304 while (
count = fread( &tmp,
sizeof (
U_CHAR ), 1, pls->plbufFile ) )
1306 if ( fwrite( &tmp,
sizeof (
U_CHAR ), 1, plot_state->plbufFile ) !=
count )
1311 plwarn(
"plbuf: Unable to write to temporary file" );
1312 fclose( plot_state->plbufFile );
1313 plot_state->plbufFile = NULL;
1314 return (
void *) plot_state;
1326 buf += pls->plbuf_top;
1331 if ( memcpy( plot_state->
plbuf_buffer, pls->plbuf_buffer, pls->plbuf_top ) == NULL )
1334 plwarn(
"plbuf: Got a NULL in memcpy!" );
1335 return (
void *) plot_state;
1339 pls->plbuf_write =
TRUE;
1340 pls->plbuf_read =
FALSE;
1349 buf +=
sizeof (
PLColor ) * (
size_t) ( pls->ncol0 );
1351 buf +=
sizeof (
PLColor ) * (
size_t) ( pls->ncol1 );
1356 for ( i = 0; i < pls->ncol0; i++ )
1364 for ( i = 0; i < pls->ncol1; i++ )
1369 plot_state->
valid = 1;
1370 return (
void *) plot_state;
1384 #ifdef BUFFERED_FILE
1385 pls->plbufFile = new_state->save_file;
1417 struct _state *prev_state;
1423 if ( state == NULL )
1426 if ( !new_state->
valid )
1428 plwarn(
"plbuf: Attempting to switch to an invalid saved state" );
1432 save_size =
sizeof (
struct _state )
1435 if ( ( prev_state = (
struct _state *) malloc( save_size ) ) == NULL )
1437 plwarn(
"plbuf: Unable to allocate memory to save state" );
1442 prev_state->
size = save_size;
1443 prev_state->
valid = 1;
1446 #ifdef BUFFERED_FILE
1447 prev_state->plbufFile = pls->plbufFile;
1465 return (
void *) prev_state;