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." );
239 short xpl[2], ypl[2];
257 wr_data( pls, xpl,
sizeof (
short ) * 2 );
258 wr_data( pls, ypl,
sizeof (
short ) * 2 );
284 wr_data( pls, xa,
sizeof (
short ) * (
size_t) npts );
285 wr_data( pls, ya,
sizeof (
short ) * (
size_t) npts );
390 wr_data( pls, pls->
dev_ix, sizeof (
short ) * (
size_t) npts );
391 wr_data( pls, pls->
dev_iy, sizeof (
short ) * (
size_t) npts );
393 sizeof (
unsigned short )
426 wr_data( pls, &text->
x, sizeof ( text->
x ) );
427 wr_data( pls, &text->
y, sizeof ( text->
y ) );
441 wr_data( pls, &fci,
sizeof ( fci ) );
454 len = strlen( text->
string ) + 1;
455 wr_data( pls, &len,
sizeof ( len ) );
457 wr_data( pls, (
void *) text->
string, sizeof (
char ) * len );
721 plabort(
"rdbuf_bop: Error reading first change state" );
730 plabort(
"rdbuf_bop: Error reading second change state" );
739 plabort(
"rdbuf_bop: Error reading third change state" );
748 plabort(
"rdbuf_bop: Error reading fourth change state" );
757 plabort(
"rdbuf_bop: Error reading fifth change state" );
766 plabort(
"rdbuf_bop: Error reading sixth change state" );
775 plabort(
"rdbuf_bop: Error reading seventh change state" );
846 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
847 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
878 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
879 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
926 "rdbuf_state: Invalid color map entry: %d",
960 PLINT patt, nps, inclin[2], delta[2];
961 rd_data( pls, &patt,
sizeof ( patt ) );
962 rd_data( pls, &nps,
sizeof ( nps ) );
963 rd_data( pls, &inclin[0],
sizeof ( inclin ) );
964 rd_data( pls, &delta[0],
sizeof ( delta ) );
975 rd_data( pls, &ncol,
sizeof ( ncol ) );
978 size = (size_t) ncol *
sizeof (
PLColor );
987 if ( pls->
cmap0 != NULL )
990 if ( ( pls->
cmap0 = (
PLColor *) malloc( size ) ) == NULL )
992 plexit(
"Insufficient memory for colormap 0" );
1008 rd_data( pls, &ncol,
sizeof ( ncol ) );
1011 size = (size_t) ncol *
sizeof (
PLColor );
1020 if ( pls->
cmap1 != NULL )
1023 if ( ( pls->
cmap1 = (
PLColor *) malloc( size ) ) == NULL )
1025 plexit(
"Insufficient memory for colormap 1" );
1145 rd_data_no_copy( pls, (
void **) &xpl,
sizeof (
short ) * (
size_t) npts );
1146 rd_data_no_copy( pls, (
void **) &ypl,
sizeof (
short ) * (
size_t) npts );
1181 short *dev_ix, *dev_iy = NULL;
1182 unsigned short *dev_z = NULL, dev_zmin, dev_zmax;
1183 PLINT nptsX, nptsY, npts;
1184 PLFLT xmin, ymin, dx, dy;
1190 npts = nptsX * nptsY;
1197 rd_data( pls, &dev_zmin,
sizeof (
short ) );
1198 rd_data( pls, &dev_zmax,
sizeof (
short ) );
1204 if ( ( ( dev_ix = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1205 ( ( dev_iy = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
1206 ( ( dev_z = (
unsigned short *) malloc( (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) *
sizeof (
unsigned short ) ) ) == NULL ) )
1207 plexit(
"rdbuf_image: Insufficient memory" );
1209 rd_data( pls, dev_ix,
sizeof (
short ) * (
size_t) npts );
1210 rd_data( pls, dev_iy,
sizeof (
short ) * (
size_t) npts );
1212 sizeof (
unsigned short )
1213 * (
size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) );
1266 PLFLT dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm;
1267 PLFLT dipxmin, dipymin, dipxmax, dipymax;
1268 PLFLT aspect, mar, jx, jy;
1269 rd_data( pls, &difilt,
sizeof ( difilt ) );
1270 rd_data( pls, &dipxmin,
sizeof ( dipxmin ) );
1271 rd_data( pls, &dipymin,
sizeof ( dipymin ) );
1272 rd_data( pls, &dipxmax,
sizeof ( dipxmax ) );
1273 rd_data( pls, &dipymax,
sizeof ( dipymax ) );
1274 rd_data( pls, &aspect,
sizeof ( aspect ) );
1275 rd_data( pls, &mar,
sizeof ( mar ) );
1276 rd_data( pls, &jx,
sizeof ( jx ) );
1277 rd_data( pls, &jy,
sizeof ( jy ) );
1278 rd_data( pls, &rot,
sizeof ( rot ) );
1279 rd_data( pls, &dimxmin,
sizeof ( dimxmin ) );
1280 rd_data( pls, &dimymin,
sizeof ( dimymin ) );
1281 rd_data( pls, &dimxmax,
sizeof ( dimxmax ) );
1282 rd_data( pls, &dimymax,
sizeof ( dimymax ) );
1283 rd_data( pls, &dimxpmm,
sizeof ( dimxpmm ) );
1284 rd_data( pls, &dimypmm,
sizeof ( dimypmm ) );
1286 c_plsdimap( dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm );
1290 c_plsdiplt( dipxmin, dipymin, dipxmax, dipymax );
1325 rd_data( pls, &text.
x, sizeof ( text.
x ) );
1326 rd_data( pls, &text.
y, sizeof ( text.
y ) );
1343 rd_data( pls, &fci,
sizeof ( fci ) );
1361 rd_data( pls, &len,
sizeof ( len ) );
1368 (
void **) ( &text.
string ),
1369 sizeof (
char ) * len );
1401 plsc->page_status =
AT_EOP;
1439 size_t finalReadPos;
1447 save_current_pls = plsc;
1473 plsc = save_current_pls;
1492 static U_CHAR esc_old = 0;
1556 pldebug(
"plbuf_control",
"Obsolete command %d, ignoring\n", c );
1560 pldebug(
"plbuf_control",
"Unrecognized command %d, previous %d\n",
1562 plexit(
"Unrecognized command" );
1585 count =
sizeof (
U_CHAR );
1607 pls->
plbuf_readpos += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1626 pls->
plbuf_readpos += ( buf_size + ( buf_size % sizeof ( uint16_t ) ) );
1638 size_t required_size;
1640 required_size = pls->
plbuf_top + data_size;
1658 printf(
"Growing buffer to %d KB\n",
1664 plexit(
"plbuf buffer grow: Plot buffer grow failed" );
1700 pls->
plbuf_top += ( buf_size + ( buf_size %
sizeof ( uint16_t ) ) );
1750 save_size =
sizeof (
struct _state );
1756 if ( state != NULL )
1760 if ( plot_state->
size < save_size )
1763 if ( ( plot_state = (
struct _state *) realloc( state, save_size ) ) == NULL )
1769 plwarn(
"plbuf: Unable to reallocate sufficient memory to save state" );
1770 plot_state->
valid = 0;
1774 plot_state->
size = save_size;
1780 if ( ( plot_state = (
struct _state *) malloc( save_size ) ) == NULL )
1782 plwarn(
"plbuf: Unable to allocate sufficient memory to save state" );
1786 plot_state->
size = save_size;
1795 plot_state->
valid = 0;
1798 buf = (
U_CHAR *) ( plot_state + 1 );
1817 plwarn(
"plbuf: Got a NULL in memcpy!" );
1818 return (
void *) plot_state;
1824 plot_state->
valid = 1;
1825 return (
void *) plot_state;
1859 struct _state *prev_state;
1867 if ( state == NULL )
1870 if ( !new_state->
valid )
1872 plwarn(
"plbuf: Attempting to switch to an invalid saved state" );
1876 save_size =
sizeof (
struct _state );
1878 if ( ( prev_state = (
struct _state *) malloc( save_size ) ) == NULL )
1880 plwarn(
"plbuf: Unable to allocate memory to save state" );
1885 prev_state->
size = save_size;
1886 prev_state->
valid = 1;
1896 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)