32 #if defined ( _MSC_VER ) && _MSC_VER <= 1500
36 typedef unsigned char uint8_t;
37 typedef unsigned short int uint16_t;
102 plexit(
"plbuf_init: Error allocating plot buffer." );
234 short xpl[2], ypl[2];
252 wr_data( pls, xpl,
sizeof (
short ) * 2 );
253 wr_data( pls, ypl,
sizeof (
short ) * 2 );
279 wr_data( pls, xa,
sizeof (
short ) * (
size_t) npts );
280 wr_data( pls, ya,
sizeof (
short ) * (
size_t) npts );
379 wr_data( pls, pls->
dev_ix, sizeof (
short ) * (
size_t) npts );
380 wr_data( pls, pls->
dev_iy, sizeof (
short ) * (
size_t) npts );
382 sizeof (
unsigned short )
415 wr_data( pls, &text->
x, sizeof ( text->
x ) );
416 wr_data( pls, &text->
y, sizeof ( text->
y ) );
430 wr_data( pls, &fci,
sizeof ( fci ) );
443 len = strlen( text->
string ) + 1;
444 wr_data( pls, &len,
sizeof ( len ) );
446 wr_data( pls, (
void *) text->
string, sizeof (
char ) * len );
710 plabort(
"rdbuf_bop: Error reading first change state" );
719 plabort(
"rdbuf_bop: Error reading second change state" );
728 plabort(
"rdbuf_bop: Error reading third change state" );
737 plabort(
"rdbuf_bop: Error reading fourth change state" );
746 plabort(
"rdbuf_bop: Error reading fifth change state" );
755 plabort(
"rdbuf_bop: Error reading sixth change state" );
823 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
824 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
855 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
856 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
903 "rdbuf_state: Invalid color map entry: %d",
937 PLINT patt, nps, inclin[2], delta[2];
938 rd_data( pls, &patt,
sizeof ( patt ) );
939 rd_data( pls, &nps,
sizeof ( nps ) );
940 rd_data( pls, &inclin[0],
sizeof ( inclin ) );
941 rd_data( pls, &delta[0],
sizeof ( delta ) );
952 rd_data( pls, &ncol,
sizeof ( ncol ) );
955 size = (size_t) ncol *
sizeof (
PLColor );
964 if ( pls->
cmap0 != NULL )
967 if ( ( pls->
cmap0 = (
PLColor *) malloc( size ) ) == NULL )
969 plexit(
"Insufficient memory for colormap 0" );
985 rd_data( pls, &ncol,
sizeof ( ncol ) );
988 size = (size_t) ncol *
sizeof (
PLColor );
997 if ( pls->
cmap1 != NULL )
1000 if ( ( pls->
cmap1 = (
PLColor *) malloc( size ) ) == NULL )
1002 plexit(
"Insufficient memory for colormap 1" );
1117 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
1118 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
1153 short *dev_ix, *dev_iy = NULL;
1154 unsigned short *dev_z = NULL, dev_zmin, dev_zmax;
1155 PLINT nptsX, nptsY, npts;
1162 npts = nptsX * nptsY;
1169 rd_data( pls, &dev_zmin,
sizeof (
short ) );
1170 rd_data( pls, &dev_zmax,
sizeof (
short ) );
1176 if ( ( ( dev_ix = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1177 ( ( dev_iy = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1178 ( ( dev_z = (
unsigned short *) malloc( (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) *
sizeof (
unsigned short ) ) ) == NULL ) )
1179 plexit(
"rdbuf_image: Insufficient memory" );
1181 rd_data( pls, dev_ix,
sizeof (
short ) * (
size_t) npts );
1182 rd_data( pls, dev_iy,
sizeof (
short ) * (
size_t) npts );
1184 sizeof (
unsigned short )
1185 * (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) );
1238 PLFLT dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm;
1239 PLFLT dipxmin, dipymin, dipxmax, dipymax;
1240 PLFLT aspect, mar, jx, jy;
1241 rd_data( pls, &difilt,
sizeof ( difilt ) );
1242 rd_data( pls, &dipxmin,
sizeof ( dipxmin ) );
1243 rd_data( pls, &dipymin,
sizeof ( dipymin ) );
1244 rd_data( pls, &dipxmax,
sizeof ( dipxmax ) );
1245 rd_data( pls, &dipymax,
sizeof ( dipymax ) );
1246 rd_data( pls, &aspect,
sizeof ( aspect ) );
1247 rd_data( pls, &mar,
sizeof ( mar ) );
1248 rd_data( pls, &jx,
sizeof ( jx ) );
1249 rd_data( pls, &jy,
sizeof ( jy ) );
1250 rd_data( pls, &rot,
sizeof ( rot ) );
1251 rd_data( pls, &dimxmin,
sizeof ( dimxmin ) );
1252 rd_data( pls, &dimymin,
sizeof ( dimymin ) );
1253 rd_data( pls, &dimxmax,
sizeof ( dimxmax ) );
1254 rd_data( pls, &dimymax,
sizeof ( dimymax ) );
1255 rd_data( pls, &dimxpmm,
sizeof ( dimxpmm ) );
1256 rd_data( pls, &dimypmm,
sizeof ( dimypmm ) );
1258 c_plsdimap( dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm );
1262 c_plsdiplt( dipxmin, dipymin, dipxmax, dipymax );
1297 rd_data( pls, &text.
x, sizeof ( text.
x ) );
1298 rd_data( pls, &text.
y, sizeof ( text.
y ) );
1315 rd_data( pls, &fci,
sizeof ( fci ) );
1333 rd_data( pls, &len,
sizeof ( len ) );
1340 (
void **) ( &text.
string ),
1341 sizeof (
char ) * len );
1408 size_t finalReadPos;
1416 save_current_pls = plsc;
1442 plsc = save_current_pls;
1461 static U_CHAR esc_old = 0;
1525 pldebug(
"plbuf_control",
"Obsolete command %d, ignoring\n", c );
1529 pldebug(
"plbuf_control",
"Unrecognized command %d, previous %d\n",
1531 plexit(
"Unrecognized command" );
1554 count =
sizeof (
U_CHAR );
1576 pls->
plbuf_readpos += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1595 pls->
plbuf_readpos += ( buf_size + ( buf_size % sizeof ( uint16_t ) ) );
1607 size_t required_size;
1609 required_size = pls->
plbuf_top + data_size;
1627 printf(
"Growing buffer to %d KB\n",
1633 plexit(
"plbuf buffer grow: Plot buffer grow failed" );
1669 pls->
plbuf_top += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1719 save_size =
sizeof (
struct _state );
1725 if ( state != NULL )
1729 if ( plot_state->
size < save_size )
1732 if ( ( plot_state = (
struct _state *) realloc( state, save_size ) ) == NULL )
1738 plwarn(
"plbuf: Unable to reallocate sufficient memory to save state" );
1739 plot_state->
valid = 0;
1743 plot_state->
size = save_size;
1749 if ( ( plot_state = (
struct _state *) malloc( save_size ) ) == NULL )
1751 plwarn(
"plbuf: Unable to allocate sufficient memory to save state" );
1755 plot_state->
size = save_size;
1764 plot_state->
valid = 0;
1767 buf = (
U_CHAR *) ( plot_state + 1 );
1786 plwarn(
"plbuf: Got a NULL in memcpy!" );
1787 return (
void *) plot_state;
1793 plot_state->
valid = 1;
1794 return (
void *) plot_state;
1828 struct _state *prev_state;
1836 if ( state == NULL )
1839 if ( !new_state->
valid )
1841 plwarn(
"plbuf: Attempting to switch to an invalid saved state" );
1845 save_size =
sizeof (
struct _state );
1847 if ( ( prev_state = (
struct _state *) malloc( save_size ) ) == NULL )
1849 plwarn(
"plbuf: Unable to allocate memory to save state" );
1854 prev_state->
size = save_size;
1855 prev_state->
valid = 1;
1865 return (
void *) prev_state;