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 );
774 short *dev_ix, *dev_iy = NULL;
775 unsigned short *dev_z, dev_zmin, dev_zmax;
776 PLINT nptsX, nptsY, npts;
783 npts = nptsX * nptsY;
790 rd_data( pls, &dev_zmin,
sizeof (
short ) );
791 rd_data( pls, &dev_zmax,
sizeof (
short ) );
797 if ( ( ( dev_ix = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
798 ( ( dev_iy = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
799 ( ( dev_z = (
unsigned short *) malloc( (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) *
sizeof (
unsigned short ) ) ) == NULL ) )
800 plexit(
"rdbuf_image: Insufficient memory" );
802 rd_data( pls, dev_ix,
sizeof (
short ) * (
size_t) npts );
803 rd_data( pls, dev_iy,
sizeof (
short ) * (
size_t) npts );
804 rd_data( pls, dev_z,
sizeof (
unsigned short ) * (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) );
885 plexit(
"rdbuf_text: Insufficient memory" );
976 if ( pls->plbufFile )
978 rewind( pls->plbufFile );
1047 pldebug(
"plbuf_control",
"Unrecognized command %d, previous %d\n", c, c_old );
1063 #ifdef BUFFERED_FILE
1064 count = fread( p_c,
sizeof (
U_CHAR ), 1, pls->plbufFile );
1070 count =
sizeof (
U_CHAR );
1089 #ifdef BUFFERED_FILE
1090 plio_fread( buf, buf_size, 1, pls->plbufFile );
1110 #ifdef BUFFERED_FILE
1121 plexit(
"plbuf wr_data: Plot buffer grow failed" );
1138 #ifdef BUFFERED_FILE
1152 plexit(
"plbuf wr_data: Plot buffer grow failed" );
1191 #ifdef BUFFERED_FILE
1218 save_size =
sizeof (
struct _state )
1220 + (size_t) ( pls->ncol0 ) *
sizeof (
PLColor )
1221 + (
size_t) ( pls->ncol1 ) *
sizeof (
PLColor );
1223 #ifndef BUFFERED_FILE
1225 save_size += pls->plbuf_top;
1229 if ( state != NULL )
1232 if ( plot_state->
size < save_size )
1235 if ( ( plot_state = (
struct _state *) realloc( state, save_size ) ) == NULL )
1241 plwarn(
"plbuf: Unable to reallocate sufficient memory to save state" );
1242 plot_state->
valid = 0;
1246 plot_state->
size = save_size;
1252 if ( ( plot_state = (
struct _state *) malloc( save_size ) ) == NULL )
1254 plwarn(
"plbuf: Unable to allocate sufficient memory to save state" );
1258 plot_state->
size = save_size;
1260 #ifdef BUFFERED_FILE
1262 plot_state->plbufFile = NULL;
1272 plot_state->
valid = 0;
1275 buf = (
U_CHAR *) ( plot_state + 1 );
1277 #ifdef BUFFERED_FILE
1279 if ( plot_state->plbufFile != NULL )
1281 fclose( plot_state->plbufFile );
1290 plwarn(
"plbuf: Unable to open temporary file to save state" );
1291 return (
void *) plot_state;
1297 rewind( pls->plbufFile );
1298 while (
count = fread( &tmp,
sizeof (
U_CHAR ), 1, pls->plbufFile ) )
1300 if ( fwrite( &tmp,
sizeof (
U_CHAR ), 1, plot_state->plbufFile ) !=
count )
1305 plwarn(
"plbuf: Unable to write to temporary file" );
1306 fclose( plot_state->plbufFile );
1307 plot_state->plbufFile = NULL;
1308 return (
void *) plot_state;
1320 buf += pls->plbuf_top;
1325 if ( memcpy( plot_state->
plbuf_buffer, pls->plbuf_buffer, pls->plbuf_top ) == NULL )
1328 plwarn(
"plbuf: Got a NULL in memcpy!" );
1329 return (
void *) plot_state;
1333 pls->plbuf_write =
TRUE;
1334 pls->plbuf_read =
FALSE;
1343 buf +=
sizeof (
PLColor ) * (
size_t) ( pls->ncol0 );
1345 buf +=
sizeof (
PLColor ) * (
size_t) ( pls->ncol1 );
1350 for ( i = 0; i < pls->ncol0; i++ )
1358 for ( i = 0; i < pls->ncol1; i++ )
1363 plot_state->
valid = 1;
1364 return (
void *) plot_state;
1378 #ifdef BUFFERED_FILE
1379 pls->plbufFile = new_state->save_file;
1411 struct _state *prev_state;
1417 if ( state == NULL )
1420 if ( !new_state->
valid )
1422 plwarn(
"plbuf: Attempting to switch to an invalid saved state" );
1426 save_size =
sizeof (
struct _state )
1429 if ( ( prev_state = (
struct _state *) malloc( save_size ) ) == NULL )
1431 plwarn(
"plbuf: Unable to allocate memory to save state" );
1436 prev_state->
size = save_size;
1437 prev_state->
valid = 1;
1440 #ifdef BUFFERED_FILE
1441 prev_state->plbufFile = pls->plbufFile;
1459 return (
void *) prev_state;