Back to index

plt-scheme  4.2.1
plbuf.c
Go to the documentation of this file.
00001 /* $Id: plbuf.c,v 1.1 2004/03/01 20:54:50 cozmic Exp $
00002 
00003     Handle plot buffer.
00004 
00005     Copyright 1992
00006     Maurice LeBrun
00007 
00008     This software may be freely copied, modified and redistributed without
00009     fee provided that this copyright notice is preserved intact on all
00010     copies and modified copies.
00011 
00012     There is no warranty or other guarantee of fitness of this software.
00013     It is provided solely "as is". The author(s) disclaim(s) all
00014     responsibility and liability with respect to this software's usage or
00015     its effect upon hardware or computer systems.
00016 */
00017 
00018 #define NEED_PLDEBUG
00019 #include "plplotP.h"
00020 #include "drivers.h"
00021 #include "metadefs.h"
00022 
00023 #include <string.h>
00024 
00025 /* Function prototypes */
00026 
00027 static int    rd_command    (PLStream *pls, U_CHAR *p_c);
00028 static int    wr_command    (PLStream *pls, U_CHAR c);
00029 static void   plbuf_control (PLStream *pls, U_CHAR c);
00030 
00031 static void   rdbuf_init    (PLStream *pls);
00032 static void   rdbuf_line    (PLStream *pls);
00033 static void   rdbuf_polyline       (PLStream *pls);
00034 static void   rdbuf_eop     (PLStream *pls);
00035 static void   rdbuf_bop     (PLStream *pls);
00036 static void   rdbuf_state   (PLStream *pls);
00037 static void   rdbuf_esc     (PLStream *pls);
00038 
00039 static void   plbuf_fill    (PLStream *pls);
00040 static void   rdbuf_fill    (PLStream *pls);
00041 static void   plbuf_swin    (PLStream *pls, PLWindow *plwin);
00042 static void   rdbuf_swin    (PLStream *pls);
00043 
00044 /*--------------------------------------------------------------------------*\
00045  * plbuf_init()
00046  *
00047  * Initialize device.
00048  * Actually just disables writes if plot buffer is already open (occurs
00049  * when one stream is cloned, as in printing).
00050 \*--------------------------------------------------------------------------*/
00051 
00052 void
00053 plbuf_init(PLStream *pls)
00054 {
00055     dbug_enter("plbuf_init");
00056 
00057     pls->plbuf_read = FALSE;
00058     if (pls->plbufFile != NULL) 
00059        pls->plbuf_write = FALSE;
00060 }
00061 
00062 /*--------------------------------------------------------------------------*\
00063  * plbuf_line()
00064  *
00065  * Draw a line in the current color from (x1,y1) to (x2,y2).
00066 \*--------------------------------------------------------------------------*/
00067 
00068 void
00069 plbuf_line(PLStream *pls, short x1a, short y1a, short x2a, short y2a)
00070 {
00071     short xpl[2], ypl[2];
00072 
00073     dbug_enter("plbuf_line");
00074 
00075     wr_command(pls, (U_CHAR) LINE);
00076 
00077     xpl[0] = x1a;
00078     xpl[1] = x2a;
00079     ypl[0] = y1a;
00080     ypl[1] = y2a;
00081 
00082     fwrite(xpl, sizeof(short), 2, pls->plbufFile);
00083     fwrite(ypl, sizeof(short), 2, pls->plbufFile);
00084 }
00085 
00086 /*--------------------------------------------------------------------------*\
00087  * plbuf_polyline()
00088  *
00089  * Draw a polyline in the current color.
00090 \*--------------------------------------------------------------------------*/
00091 
00092 void
00093 plbuf_polyline(PLStream *pls, short *xa, short *ya, PLINT npts)
00094 {
00095     dbug_enter("plbuf_polyline");
00096 
00097     wr_command(pls, (U_CHAR) POLYLINE);
00098     fwrite(&npts, sizeof(PLINT), 1, pls->plbufFile);
00099 
00100     fwrite(xa, sizeof(short), npts, pls->plbufFile);
00101     fwrite(ya, sizeof(short), npts, pls->plbufFile);
00102 }
00103 
00104 /*--------------------------------------------------------------------------*\
00105  * plbuf_eop()
00106  *
00107  * End of page.
00108 \*--------------------------------------------------------------------------*/
00109 
00110 void
00111 plbuf_eop(PLStream *pls)
00112 {
00113     dbug_enter("plbuf_eop");
00114 }
00115 
00116 /*--------------------------------------------------------------------------*\
00117  * plbuf_bop()
00118  *
00119  * Set up for the next page.
00120  * To avoid problems redisplaying partially filled pages, on each BOP the
00121  * old file is thrown away and a new one is obtained.  This way we can just
00122  * read up to EOF to get everything on the current page.
00123  *
00124  * Also write state information to ensure the next page is correct.
00125 \*--------------------------------------------------------------------------*/
00126 
00127 void
00128 plbuf_bop(PLStream *pls)
00129 {
00130     dbug_enter("plbuf_bop");
00131 
00132     plbuf_tidy(pls);
00133 
00134     pls->plbufFile = tmpfile();
00135     if (pls->plbufFile == NULL) 
00136        plexit("plbuf_init: Error opening plot data storage file.");
00137 
00138     wr_command(pls, (U_CHAR) BOP);
00139     plbuf_state(pls, PLSTATE_COLOR0);
00140     plbuf_state(pls, PLSTATE_WIDTH);
00141 }
00142 
00143 /*--------------------------------------------------------------------------*\
00144  * plbuf_tidy()
00145  *
00146  * Close graphics file
00147 \*--------------------------------------------------------------------------*/
00148 
00149 void
00150 plbuf_tidy(PLStream *pls)
00151 {
00152     dbug_enter("plbuf_tidy");
00153 
00154     if (pls->plbufFile == NULL)
00155        return;
00156 
00157     fclose(pls->plbufFile);
00158     pls->plbufFile = NULL;
00159 }
00160 
00161 /*--------------------------------------------------------------------------*\
00162  * plbuf_state()
00163  *
00164  * Handle change in PLStream state (color, pen width, fill attribute, etc).
00165 \*--------------------------------------------------------------------------*/
00166 
00167 void 
00168 plbuf_state(PLStream *pls, PLINT op)
00169 {
00170     dbug_enter("plbuf_state");
00171 
00172     wr_command(pls, (U_CHAR) CHANGE_STATE);
00173     wr_command(pls, (U_CHAR) op);
00174 
00175     switch (op) {
00176 
00177     case PLSTATE_WIDTH: {
00178        U_CHAR width = pls->width;
00179 
00180        fwrite(&width, sizeof(U_CHAR), 1, pls->plbufFile);
00181        break;
00182     }
00183 
00184     case PLSTATE_COLOR0: {
00185        U_CHAR icol0 = pls->icol0;
00186        U_CHAR r = pls->curcolor.r;
00187        U_CHAR g = pls->curcolor.g;
00188        U_CHAR b = pls->curcolor.b;
00189 
00190        fwrite(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
00191        if (icol0 == PL_RGB_COLOR) {
00192            fwrite(&r, sizeof(U_CHAR), 1, pls->plbufFile);
00193            fwrite(&g, sizeof(U_CHAR), 1, pls->plbufFile);
00194            fwrite(&b, sizeof(U_CHAR), 1, pls->plbufFile);
00195        }
00196        break;
00197     }
00198 
00199     case PLSTATE_COLOR1: {
00200        U_CHAR icol1 = pls->icol1;
00201 
00202        fwrite(&icol1, sizeof(U_CHAR), 1, pls->plbufFile);
00203        break;
00204     }
00205 
00206     case PLSTATE_FILL:{
00207        signed char patt = pls->patt;
00208 
00209        fwrite(&patt, sizeof(signed char), 1, pls->plbufFile);
00210        break;
00211     }
00212     }
00213 }
00214 
00215 
00216 /*--------------------------------------------------------------------------*\
00217  * plbuf_image()
00218  *
00219  * write image described in points pls->dev_x[], pls->dev_y[], pls->dev_z[].
00220  *                      pls->nptsX, pls->nptsY.
00221 \*--------------------------------------------------------------------------*/
00222 
00223 static void
00224 plbuf_image(PLStream *pls, IMG_DT *img_dt)
00225 {
00226     PLINT npts = pls->dev_nptsX * pls->dev_nptsY;
00227 
00228     dbug_enter("plbuf_image");
00229 
00230     fwrite(&pls->dev_nptsX, sizeof(PLINT), 1, pls->plbufFile);
00231     fwrite(&pls->dev_nptsY, sizeof(PLINT), 1, pls->plbufFile);
00232 
00233     fwrite(&img_dt->xmin, sizeof(PLFLT), 1, pls->plbufFile);
00234     fwrite(&img_dt->ymin, sizeof(PLFLT), 1, pls->plbufFile);
00235     fwrite(&img_dt->dx, sizeof(PLFLT), 1, pls->plbufFile);
00236     fwrite(&img_dt->dy, sizeof(PLFLT), 1, pls->plbufFile);
00237 
00238     fwrite(&pls->dev_zmin, sizeof(short), 1, pls->plbufFile);
00239     fwrite(&pls->dev_zmax, sizeof(short), 1, pls->plbufFile);
00240 
00241     fwrite(pls->dev_ix, sizeof(short), npts, pls->plbufFile);
00242     fwrite(pls->dev_iy, sizeof(short), npts, pls->plbufFile);
00243     fwrite(pls->dev_z, sizeof(unsigned short), (pls->dev_nptsX-1)*(pls->dev_nptsY-1), pls->plbufFile);
00244 }
00245 
00246 /*--------------------------------------------------------------------------*\
00247  * plbuf_esc()
00248  *
00249  * Escape function.  Note that any data written must be in device
00250  * independent form to maintain the transportability of the metafile.
00251  *
00252  * Functions:
00253  *
00254  *     PLESC_FILL    Fill polygon
00255  *     PLESC_SWIN    Set plot window parameters
00256  *      PLESC_IMAGE     Draw image
00257 \*--------------------------------------------------------------------------*/
00258 
00259 void
00260 plbuf_esc(PLStream *pls, PLINT op, void *ptr)
00261 {
00262     dbug_enter("plbuf_esc");
00263 
00264     wr_command(pls, (U_CHAR) ESCAPE);
00265     wr_command(pls, (U_CHAR) op);
00266 
00267     switch (op) {
00268     case PLESC_FILL:
00269        plbuf_fill(pls);
00270        break;
00271     case PLESC_SWIN:
00272        plbuf_swin(pls, (PLWindow *) ptr);
00273        break;
00274     case PLESC_IMAGE:
00275        plbuf_image(pls, (IMG_DT *) ptr);
00276        break;
00277     }
00278 }
00279 
00280 /*--------------------------------------------------------------------------*\
00281  * plbuf_fill()
00282  *
00283  * Fill polygon described in points pls->dev_x[] and pls->dev_y[].
00284 \*--------------------------------------------------------------------------*/
00285 
00286 static void
00287 plbuf_fill(PLStream *pls)
00288 {
00289     dbug_enter("plbuf_fill");
00290 
00291     fwrite(&pls->dev_npts, sizeof(PLINT), 1, pls->plbufFile);
00292     fwrite(pls->dev_x, sizeof(short), pls->dev_npts, pls->plbufFile);
00293     fwrite(pls->dev_y, sizeof(short), pls->dev_npts, pls->plbufFile);
00294 }
00295 
00296 /*--------------------------------------------------------------------------*\
00297  * plbuf_swin()
00298  *
00299  * Set up plot window parameters. 
00300 \*--------------------------------------------------------------------------*/
00301 
00302 static void
00303 plbuf_swin(PLStream *pls, PLWindow *plwin)
00304 {
00305     fwrite(&plwin->dxmi, sizeof(PLFLT), 1, pls->plbufFile);
00306     fwrite(&plwin->dxma, sizeof(PLFLT), 1, pls->plbufFile);
00307     fwrite(&plwin->dymi, sizeof(PLFLT), 1, pls->plbufFile);
00308     fwrite(&plwin->dyma, sizeof(PLFLT), 1, pls->plbufFile);
00309 
00310     fwrite(&plwin->wxmi, sizeof(PLFLT), 1, pls->plbufFile);
00311     fwrite(&plwin->wxma, sizeof(PLFLT), 1, pls->plbufFile);
00312     fwrite(&plwin->wymi, sizeof(PLFLT), 1, pls->plbufFile);
00313     fwrite(&plwin->wyma, sizeof(PLFLT), 1, pls->plbufFile);
00314 }
00315 
00316 /*--------------------------------------------------------------------------*\
00317  * Routines to read from & process the plot buffer.
00318 \*--------------------------------------------------------------------------*/
00319 
00320 /*--------------------------------------------------------------------------*\
00321  * rdbuf_init()
00322  *
00323  * Initialize device.
00324 \*--------------------------------------------------------------------------*/
00325 
00326 static void
00327 rdbuf_init(PLStream *pls)
00328 {
00329     dbug_enter("rdbuf_init");
00330 }
00331 
00332 /*--------------------------------------------------------------------------*\
00333  * rdbuf_line()
00334  *
00335  * Draw a line in the current color from (x1,y1) to (x2,y2).
00336 \*--------------------------------------------------------------------------*/
00337 
00338 static void
00339 rdbuf_line(PLStream *pls)
00340 {
00341     short xpl[2], ypl[2];
00342     PLINT npts = 2;
00343 
00344     dbug_enter("rdbuf_line");
00345 
00346     fread(xpl, sizeof(short), npts, pls->plbufFile);
00347     fread(ypl, sizeof(short), npts, pls->plbufFile);
00348 
00349     plP_line(xpl, ypl);
00350 }
00351 
00352 /*--------------------------------------------------------------------------*\
00353  * rdbuf_polyline()
00354  *
00355  * Draw a polyline in the current color.
00356 \*--------------------------------------------------------------------------*/
00357 
00358 static void
00359 rdbuf_polyline(PLStream *pls)
00360 {
00361     short xpl[PL_MAXPOLY], ypl[PL_MAXPOLY];
00362     PLINT npts;
00363 
00364     dbug_enter("rdbuf_polyline");
00365 
00366     fread(&npts, sizeof(PLINT), 1, pls->plbufFile);
00367     fread(xpl, sizeof(short), npts, pls->plbufFile);
00368     fread(ypl, sizeof(short), npts, pls->plbufFile);
00369 
00370     plP_polyline(xpl, ypl, npts);
00371 }
00372 
00373 /*--------------------------------------------------------------------------*\
00374  * rdbuf_eop()
00375  *
00376  * End of page.
00377 \*--------------------------------------------------------------------------*/
00378 
00379 static void
00380 rdbuf_eop(PLStream *pls)
00381 {
00382     dbug_enter("rdbuf_eop");
00383 }
00384 
00385 /*--------------------------------------------------------------------------*\
00386  * rdbuf_bop()
00387  *
00388  * Set up for the next page.
00389 \*--------------------------------------------------------------------------*/
00390 
00391 static void
00392 rdbuf_bop(PLStream *pls)
00393 {
00394     dbug_enter("rdbuf_bop");
00395 
00396     pls->nplwin = 0;
00397 }
00398 
00399 /*--------------------------------------------------------------------------*\
00400  * rdbuf_state()
00401  *
00402  * Handle change in PLStream state (color, pen width, fill attribute, etc).
00403 \*--------------------------------------------------------------------------*/
00404 
00405 static void 
00406 rdbuf_state(PLStream *pls)
00407 {
00408     U_CHAR op;
00409 
00410     dbug_enter("rdbuf_state");
00411 
00412     fread(&op, sizeof(U_CHAR), 1, pls->plbufFile);
00413 
00414     switch (op) {
00415 
00416     case PLSTATE_WIDTH:{
00417        U_CHAR width;
00418 
00419        fread(&width, sizeof(U_CHAR), 1, pls->plbufFile);
00420        pls->width = width;
00421        plP_state(PLSTATE_WIDTH);
00422 
00423        break;
00424     }
00425 
00426     case PLSTATE_COLOR0:{
00427        U_CHAR icol0, r, g, b;
00428 
00429        fread(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
00430        if (icol0 == PL_RGB_COLOR) {
00431            fread(&r, sizeof(U_CHAR), 1, pls->plbufFile);
00432            fread(&g, sizeof(U_CHAR), 1, pls->plbufFile);
00433            fread(&b, sizeof(U_CHAR), 1, pls->plbufFile);
00434        }
00435        else {
00436            if ((int) icol0 > 15) {
00437               plwarn("rdbuf_state: Color map 0 entry hosed");
00438               icol0 = 1;
00439            }
00440            r = pls->cmap0[icol0].r;
00441            g = pls->cmap0[icol0].g;
00442            b = pls->cmap0[icol0].b;
00443        }
00444        pls->icol0 = icol0;
00445        pls->curcolor.r = r;
00446        pls->curcolor.g = g;
00447        pls->curcolor.b = b;
00448 
00449        plP_state(PLSTATE_COLOR0);
00450        break;
00451     }
00452 
00453     case PLSTATE_COLOR1: {
00454        U_CHAR icol1;
00455 
00456        fread(&icol1, sizeof(U_CHAR), 1, pls->plbufFile);
00457 
00458        pls->icol1 = icol1;
00459        pls->curcolor.r = pls->cmap1[icol1].r;
00460        pls->curcolor.g = pls->cmap1[icol1].g;
00461        pls->curcolor.b = pls->cmap1[icol1].b;
00462 
00463        plP_state(PLSTATE_COLOR1);
00464        break;
00465     }
00466 
00467     case PLSTATE_FILL: {
00468        signed char patt;
00469 
00470        fread(&patt, sizeof(signed char), 1, pls->plbufFile);
00471 
00472        pls->patt = patt;
00473        plP_state(PLSTATE_FILL);
00474        break;
00475     }
00476     }
00477 }
00478 
00479 /*--------------------------------------------------------------------------*\
00480  * rdbuf_esc()
00481  *
00482  * Escape function.
00483  * Must fill data structure with whatever data that was written,
00484  * then call escape function.
00485  *
00486  * Note: it is best to only call the escape function for op-codes that
00487  * are known to be supported.
00488  *
00489  * Functions:
00490  *
00491  *     PLESC_FILL    Fill polygon
00492  *     PLESC_SWIN    Set plot window parameters
00493  *      PLESC_IMAGE     Draw image
00494 \*--------------------------------------------------------------------------*/
00495 
00496 static void
00497 rdbuf_image(PLStream *pls);
00498 
00499 static void
00500 rdbuf_esc(PLStream *pls)
00501 {
00502     U_CHAR op;
00503 
00504     dbug_enter("rdbuf_esc");
00505 
00506     fread(&op, sizeof(U_CHAR), 1, pls->plbufFile);
00507 
00508     switch (op) {
00509     case PLESC_FILL:
00510        rdbuf_fill(pls);
00511        break;
00512     case PLESC_SWIN:
00513        rdbuf_swin(pls);
00514        break;
00515     case PLESC_IMAGE:
00516        rdbuf_image(pls);
00517        break;
00518     }
00519 }
00520 
00521 /*--------------------------------------------------------------------------*\
00522  * rdbuf_fill()
00523  *
00524  * Fill polygon described by input points.
00525 \*--------------------------------------------------------------------------*/
00526 
00527 static void
00528 rdbuf_fill(PLStream *pls)
00529 {
00530     short xpl[PL_MAXPOLY], ypl[PL_MAXPOLY];
00531     PLINT npts;
00532 
00533     dbug_enter("rdbuf_fill");
00534 
00535     fread(&npts, sizeof(PLINT), 1, pls->plbufFile);
00536     fread(xpl, sizeof(short), npts, pls->plbufFile);
00537     fread(ypl, sizeof(short), npts, pls->plbufFile);
00538     
00539     plP_fill(xpl, ypl, npts);
00540 }
00541 
00542 /*--------------------------------------------------------------------------*\
00543  * rdbuf_image()
00544  *
00545  * .
00546 \*--------------------------------------------------------------------------*/
00547 
00548 static void
00549 rdbuf_image(PLStream *pls)
00550 {
00551   short *dev_ix, *dev_iy;
00552   unsigned short *dev_z, dev_zmin, dev_zmax;
00553   PLINT nptsX,nptsY, npts;
00554   PLFLT xmin, ymin, dx, dy;
00555 
00556     dbug_enter("rdbuf_image");
00557 
00558     fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile);
00559     fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile);
00560     npts = nptsX*nptsY;
00561 
00562     fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile);
00563     fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile);
00564     fread(&dx, sizeof(PLFLT), 1, pls->plbufFile);
00565     fread(&dy, sizeof(PLFLT), 1, pls->plbufFile);
00566 
00567     fread(&dev_zmin, sizeof(short), 1, pls->plbufFile);
00568     fread(&dev_zmax, sizeof(short), 1, pls->plbufFile);
00569 
00570     dev_ix=(short *)malloc(npts*sizeof(short));
00571     dev_iy=(short *)malloc(npts*sizeof(short));
00572     dev_z=(unsigned short *)malloc((nptsX-1)*(nptsY-1)*sizeof(unsigned short));
00573 
00574     fread(dev_ix, sizeof(short), npts, pls->plbufFile);
00575     fread(dev_iy, sizeof(short), npts, pls->plbufFile);
00576     fread(dev_z, sizeof(unsigned short), (nptsX-1)*(nptsY-1), pls->plbufFile);
00577 
00578     plP_image(dev_ix, dev_iy, dev_z, nptsX, nptsY, xmin, ymin, dx, dy, dev_zmin, dev_zmax);
00579 
00580     free(dev_ix);
00581     free(dev_iy);
00582     free(dev_z);
00583 }
00584 
00585 /*--------------------------------------------------------------------------*\
00586  * rdbuf_swin()
00587  *
00588  * Set up plot window parameters. 
00589 \*--------------------------------------------------------------------------*/
00590 
00591 static void
00592 rdbuf_swin(PLStream *pls)
00593 {
00594     PLWindow plwin;
00595 
00596     fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile);
00597     fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile);
00598     fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile);
00599     fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile);
00600 
00601     fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile);
00602     fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile);
00603     fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile);
00604     fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile);
00605 
00606     plP_swin(&plwin);
00607 }
00608 
00609 /*--------------------------------------------------------------------------*\
00610  * plRemakePlot()
00611  *
00612  * Rebuilds plot from plot buffer, usually in response to a window
00613  * resize or exposure event.
00614 \*--------------------------------------------------------------------------*/
00615 
00616 void
00617 plRemakePlot(PLStream *pls)
00618 {
00619     U_CHAR c;
00620     int plbuf_status;
00621 
00622     dbug_enter("plRemakePlot");
00623 
00624     if (pls->plbufFile == NULL)
00625        return;
00626 
00627     rewind(pls->plbufFile);
00628 
00629     plbuf_status = pls->plbuf_write;
00630     pls->plbuf_write = FALSE;
00631     pls->plbuf_read = TRUE;
00632     while (rd_command(pls, &c)) {
00633        plbuf_control(pls, c);
00634     }
00635 
00636     pls->plbuf_read = FALSE;
00637     pls->plbuf_write = plbuf_status;
00638 }
00639 
00640 /*--------------------------------------------------------------------------*\
00641  * plbuf_control()
00642  *
00643  * Processes commands read from the plot buffer.
00644 \*--------------------------------------------------------------------------*/
00645 
00646 static void
00647 plbuf_control(PLStream *pls, U_CHAR c)
00648 {
00649     static U_CHAR c_old = 0;
00650 
00651     dbug_enter("plbuf_control");
00652 
00653     switch ((int) c) {
00654 
00655     case INITIALIZE:
00656        rdbuf_init(pls);
00657        break;
00658 
00659     case EOP:
00660        rdbuf_eop(pls);
00661        break;
00662 
00663     case BOP:
00664        rdbuf_bop(pls);
00665        break;
00666 
00667     case CHANGE_STATE:
00668        rdbuf_state(pls);
00669        break;
00670 
00671     case LINE:
00672        rdbuf_line(pls);
00673        break;
00674 
00675     case POLYLINE:
00676        rdbuf_polyline(pls);
00677        break;
00678 
00679     case ESCAPE:
00680        rdbuf_esc(pls);
00681        break;
00682 
00683     default:
00684       pldebug("plbuf_control", "Unrecognized command %d, previous %d\n", c, c_old);
00685     }
00686     c_old = c;
00687 }
00688 
00689 /*--------------------------------------------------------------------------*\
00690  * rd_command()
00691  *
00692  * Read & return the next command
00693 \*--------------------------------------------------------------------------*/
00694 
00695 static int
00696 rd_command(PLStream *pls, U_CHAR *p_c)
00697 {
00698     int count;
00699     
00700     count = fread(p_c, sizeof(U_CHAR), 1, pls->plbufFile);
00701     return (count);
00702 }
00703 
00704 /*--------------------------------------------------------------------------*\
00705  * wr_command()
00706  *
00707  * Write the next command
00708 \*--------------------------------------------------------------------------*/
00709 
00710 static int
00711 wr_command(PLStream *pls, U_CHAR c)
00712 {
00713     U_CHAR c1 = c;
00714     int count;
00715 
00716     count = fwrite(&c1, sizeof(U_CHAR), 1, pls->plbufFile);
00717     return (count);
00718 }