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." );
238 short xpl[2], ypl[2];
256 wr_data( pls, xpl,
sizeof (
short ) * 2 );
257 wr_data( pls, ypl,
sizeof (
short ) * 2 );
283 wr_data( pls, xa,
sizeof (
short ) * (
size_t) npts );
284 wr_data( pls, ya,
sizeof (
short ) * (
size_t) npts );
383 wr_data( pls, pls->
dev_ix, sizeof (
short ) * (
size_t) npts );
384 wr_data( pls, pls->
dev_iy, sizeof (
short ) * (
size_t) npts );
386 sizeof (
unsigned short )
419 wr_data( pls, &text->
x, sizeof ( text->
x ) );
420 wr_data( pls, &text->
y, sizeof ( text->
y ) );
434 wr_data( pls, &fci,
sizeof ( fci ) );
447 len = strlen( text->
string ) + 1;
448 wr_data( pls, &len,
sizeof ( len ) );
450 wr_data( pls, (
void *) text->
string, sizeof (
char ) * len );
714 plabort(
"rdbuf_bop: Error reading first change state" );
723 plabort(
"rdbuf_bop: Error reading second change state" );
732 plabort(
"rdbuf_bop: Error reading third change state" );
741 plabort(
"rdbuf_bop: Error reading fourth change state" );
750 plabort(
"rdbuf_bop: Error reading fifth change state" );
759 plabort(
"rdbuf_bop: Error reading sixth change state" );
830 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
831 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
862 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
863 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
910 "rdbuf_state: Invalid color map entry: %d",
944 PLINT patt, nps, inclin[2], delta[2];
945 rd_data( pls, &patt,
sizeof ( patt ) );
946 rd_data( pls, &nps,
sizeof ( nps ) );
947 rd_data( pls, &inclin[0],
sizeof ( inclin ) );
948 rd_data( pls, &delta[0],
sizeof ( delta ) );
959 rd_data( pls, &ncol,
sizeof ( ncol ) );
962 size = (size_t) ncol *
sizeof (
PLColor );
971 if ( pls->
cmap0 != NULL )
974 if ( ( pls->
cmap0 = (
PLColor *) malloc( size ) ) == NULL )
976 plexit(
"Insufficient memory for colormap 0" );
992 rd_data( pls, &ncol,
sizeof ( ncol ) );
995 size = (size_t) ncol *
sizeof (
PLColor );
1004 if ( pls->
cmap1 != NULL )
1007 if ( ( pls->
cmap1 = (
PLColor *) malloc( size ) ) == NULL )
1009 plexit(
"Insufficient memory for colormap 1" );
1124 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
1125 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
1160 short *dev_ix, *dev_iy = NULL;
1161 unsigned short *dev_z = NULL, dev_zmin, dev_zmax;
1162 PLINT nptsX, nptsY, npts;
1163 PLFLT xmin, ymin, dx, dy;
1169 npts = nptsX * nptsY;
1176 rd_data( pls, &dev_zmin,
sizeof (
short ) );
1177 rd_data( pls, &dev_zmax,
sizeof (
short ) );
1183 if ( ( ( dev_ix = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1184 ( ( dev_iy = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1185 ( ( dev_z = (
unsigned short *) malloc( (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) *
sizeof (
unsigned short ) ) ) == NULL ) )
1186 plexit(
"rdbuf_image: Insufficient memory" );
1188 rd_data( pls, dev_ix,
sizeof (
short ) * (
size_t) npts );
1189 rd_data( pls, dev_iy,
sizeof (
short ) * (
size_t) npts );
1191 sizeof (
unsigned short )
1192 * (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) );
1245 PLFLT dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm;
1246 PLFLT dipxmin, dipymin, dipxmax, dipymax;
1247 PLFLT aspect, mar, jx, jy;
1248 rd_data( pls, &difilt,
sizeof ( difilt ) );
1249 rd_data( pls, &dipxmin,
sizeof ( dipxmin ) );
1250 rd_data( pls, &dipymin,
sizeof ( dipymin ) );
1251 rd_data( pls, &dipxmax,
sizeof ( dipxmax ) );
1252 rd_data( pls, &dipymax,
sizeof ( dipymax ) );
1253 rd_data( pls, &aspect,
sizeof ( aspect ) );
1254 rd_data( pls, &mar,
sizeof ( mar ) );
1255 rd_data( pls, &jx,
sizeof ( jx ) );
1256 rd_data( pls, &jy,
sizeof ( jy ) );
1257 rd_data( pls, &rot,
sizeof ( rot ) );
1258 rd_data( pls, &dimxmin,
sizeof ( dimxmin ) );
1259 rd_data( pls, &dimymin,
sizeof ( dimymin ) );
1260 rd_data( pls, &dimxmax,
sizeof ( dimxmax ) );
1261 rd_data( pls, &dimymax,
sizeof ( dimymax ) );
1262 rd_data( pls, &dimxpmm,
sizeof ( dimxpmm ) );
1263 rd_data( pls, &dimypmm,
sizeof ( dimypmm ) );
1265 c_plsdimap( dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm );
1269 c_plsdiplt( dipxmin, dipymin, dipxmax, dipymax );
1304 rd_data( pls, &text.
x, sizeof ( text.
x ) );
1305 rd_data( pls, &text.
y, sizeof ( text.
y ) );
1322 rd_data( pls, &fci,
sizeof ( fci ) );
1340 rd_data( pls, &len,
sizeof ( len ) );
1347 (
void **) ( &text.
string ),
1348 sizeof (
char ) * len );
1415 size_t finalReadPos;
1423 save_current_pls = plsc;
1449 plsc = save_current_pls;
1468 static U_CHAR esc_old = 0;
1532 pldebug(
"plbuf_control",
"Obsolete command %d, ignoring\n", c );
1536 pldebug(
"plbuf_control",
"Unrecognized command %d, previous %d\n",
1538 plexit(
"Unrecognized command" );
1561 count =
sizeof (
U_CHAR );
1583 pls->
plbuf_readpos += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1602 pls->
plbuf_readpos += ( buf_size + ( buf_size % sizeof ( uint16_t ) ) );
1614 size_t required_size;
1616 required_size = pls->
plbuf_top + data_size;
1634 printf(
"Growing buffer to %d KB\n",
1640 plexit(
"plbuf buffer grow: Plot buffer grow failed" );
1676 pls->
plbuf_top += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1726 save_size =
sizeof (
struct _state );
1732 if ( state != NULL )
1736 if ( plot_state->
size < save_size )
1739 if ( ( plot_state = (
struct _state *) realloc( state, save_size ) ) == NULL )
1745 plwarn(
"plbuf: Unable to reallocate sufficient memory to save state" );
1746 plot_state->
valid = 0;
1750 plot_state->
size = save_size;
1756 if ( ( plot_state = (
struct _state *) malloc( save_size ) ) == NULL )
1758 plwarn(
"plbuf: Unable to allocate sufficient memory to save state" );
1762 plot_state->
size = save_size;
1771 plot_state->
valid = 0;
1774 buf = (
U_CHAR *) ( plot_state + 1 );
1793 plwarn(
"plbuf: Got a NULL in memcpy!" );
1794 return (
void *) plot_state;
1800 plot_state->
valid = 1;
1801 return (
void *) plot_state;
1835 struct _state *prev_state;
1843 if ( state == NULL )
1846 if ( !new_state->
valid )
1848 plwarn(
"plbuf: Attempting to switch to an invalid saved state" );
1852 save_size =
sizeof (
struct _state );
1854 if ( ( prev_state = (
struct _state *) malloc( save_size ) ) == NULL )
1856 plwarn(
"plbuf: Unable to allocate memory to save state" );
1861 prev_state->
size = save_size;
1862 prev_state->
valid = 1;
1872 return (
void *) prev_state;
void c_plsdidev(PLFLT mar, PLFLT aspect, PLFLT jx, PLFLT jy)
static void wr_command(PLStream *pls, U_CHAR c)
void plexit(PLCHAR_VECTOR errormsg)
void plP_esc(PLINT op, void *ptr)
static void wr_data(PLStream *pls, void *buf, size_t buf_size)
#define PLESC_CONTROL_CHAR
void c_plsdiori(PLFLT rot)
void plbuf_state(PLStream *pls, PLINT op)
static void rdbuf_text_unicode(PLINT op, PLStream *pls)
void c_plssub(PLINT nx, PLINT ny)
static void plbuf_image(PLStream *pls, IMG_DT *img_dt)
static void rdbuf_line(PLStream *pls)
void c_plpat(PLINT nlin, PLINT_VECTOR inc, PLINT_VECTOR del)
void plbuf_di(PLStream *pls)
void plbuf_clip(PLStream *pls)
void plbuf_restore(PLStream *pls, void *state)
void plP_swin(PLWindow *plwin)
void * plbuf_switch(PLStream *pls, void *state)
void plFlushBuffer(PLStream *pls, PLBOOL restart, size_t amount)
static void plbuf_fill(PLStream *pls)
void plabort(PLCHAR_VECTOR errormsg)
void plbuf_init(PLStream *pls)
static void rdbuf_ssub(PLStream *pls)
void plbuf_esc(PLStream *pls, PLINT op, void *ptr)
static void check_buffer_size(PLStream *pls, size_t data_size)
static void rdbuf_swin(PLStream *pls)
void plP_polyline(short *x, short *y, PLINT npts)
static void rdbuf_text(PLStream *pls)
static void plbuf_text_unicode(PLStream *pls, EscText *text)
void plbuf_polyline(PLStream *pls, short *xa, short *ya, PLINT npts)
static void rdbuf_esc(PLStream *pls)
static void rdbuf_eop(PLStream *pls)
static void rdbuf_fill(PLStream *pls)
#define PLESC_FLUSH_REMAINING_BUFFER
void plbuf_tidy(PLStream *PL_UNUSED(pls))
static void rdbuf_bop(PLStream *pls)
void difilt(PLINT *xsc, PLINT *ysc, PLINT npts, PLINT *clpxmi, PLINT *clpxma, PLINT *clpymi, PLINT *clpyma)
#define PLESC_END_RASTERIZE
static void rdbuf_polyline(PLStream *pls)
void xform(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data)
void plbuf_ssub(PLStream *pls)
static void rdbuf_setsub(PLStream *pls)
#define PLESC_APPEND_BUFFER
static PLStream * pls[PL_NSTREAMS]
static void rdbuf_init(PLStream *pls)
void plbuf_line(PLStream *pls, short x1a, short y1a, short x2a, short y2a)
unsigned short unicode_array_len
static void plbuf_text(PLStream *pls, EscText *text)
static void plbuf_swin(PLStream *pls, PLWindow *plwin)
void plbuf_setsub(PLStream *pls)
static void rdbuf_image(PLStream *pls)
void plP_fill(short *x, short *y, PLINT npts)
void * plbuf_save(PLStream *pls, void *state)
static void rd_data_no_copy(PLStream *pls, void **buf, size_t buf_size)
void plRemakePlot(PLStream *pls)
#define PLESC_START_RASTERIZE
static void rdbuf_di(PLStream *pls)
void c_plsdimap(PLINT dimxmin, PLINT dimxmax, PLINT dimymin, PLINT dimymax, PLFLT dimxpmm, PLFLT dimypmm)
#define PLESC_IMPORT_BUFFER
void plP_line(short *x, short *y)
void plbuf_eop(PLStream *pls)
static void plbuf_control(PLStream *pls, U_CHAR c)
void plwarn(PLCHAR_VECTOR errormsg)
void plbuf_bop(PLStream *pls)
static int rd_command(PLStream *pls, U_CHAR *p_c)
void plbuf_write(PLStream *pls, void *data, size_t bytes)
static void rdbuf_clip(PLStream *pls)
PLUNICODE * unicode_array
static void rdbuf_state(PLStream *pls)
static void rd_data(PLStream *pls, void *buf, size_t buf_size)
void c_plsdiplt(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax)