home *** CD-ROM | disk | FTP | other *** search
/ ftp.eri.u-tokyo.ac.jp / 2014.03.ftp.eri.u-tokyo.ac.jp.zip / ftp.eri.u-tokyo.ac.jp / pub / seisv / src / 3.02 / device.c < prev    next >
C/C++ Source or Header  |  1999-11-10  |  15KB  |  728 lines

  1. /*  SeisView alone/client    Copyright (C) 1992,1998  K.Koketsu
  2.              <history>
  3.          98-11-03  Remove CR.
  4.          98-10-06  Printers appear again.
  5.                    Some global variables are replaced by constants.
  6.          98-10-02  MONOCHROME drops from the support list.
  7.                    Correct backspace().
  8.          98-02-26  Abandon DOS, but take Windows 95/NT.
  9.          96-06-19  remedy for BSD/386.
  10.                    Support RISC NEWS (thanks to Dr Shiobara).   */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <fcntl.h>
  15. #include <string.h>
  16. #include <ctype.h>
  17. #ifdef BSDI
  18. #include <sys/malloc.h>
  19. #else
  20. #include <malloc.h>
  21. #endif
  22.  
  23. #ifdef RISC_NEWS
  24. #include <varargs.h>
  25. #endif
  26.  
  27. #include "ctlname.h"
  28. #include "seis.h"
  29.  
  30. #ifdef WIN32
  31. #include <io.h>
  32. #endif
  33.  
  34. extern char em$[51];                             /* error message on menu   */
  35. extern char drv$[65], drvo$[65];                 /* parameters for disks    */
  36. extern char prn$[5], port$[65];                  /* printer type etc.       */
  37. extern char z$[11], w$[81];                      /* work string             */
  38. extern int  psflag;
  39.  
  40. char       *iseg[10];
  41. unsigned    nseg;                /* # of work segments for selected events  */
  42. int  oldx = -1, oldy;                 /* old cursor position        */
  43.  
  44. void show_machine()
  45. {
  46. #ifdef WIN32
  47.     strcpy(w$+28, "for Windows 95/98/NT");
  48. #else
  49.     strcpy(w$+29, "for UNIX/X Window");
  50. #endif
  51. }
  52.  
  53. void get_printer_defaults(s, t)
  54. char  *s, *t;
  55. {
  56. #ifdef WIN32
  57.     strcpy(s, "NEC ");  strcpy(t, "HP Laserjet 4M");
  58. #else
  59.     strcpy(s, "PS  ");  strcpy(t, "ps");
  60. #endif
  61. }
  62.  
  63. unsigned char  *cx, *cy, *cz;
  64. void keep_prt_buffer()
  65. {
  66.     cx = (unsigned char *)malloc(2560);
  67.     cy = (unsigned char *)malloc(1280);
  68.     cz = (unsigned char *)malloc( 640);
  69. }
  70.  
  71. int alloc_mem()
  72. {
  73.     int  i;
  74.  
  75.     keep_prt_buffer();
  76.  
  77.     for(i=0; i<8; i++) {
  78.     if((iseg[i] = malloc(0x10000)) == NULL)  break;
  79.     }
  80.     nseg = i;
  81.     return( i );
  82. }
  83.  
  84. /************ Text I/O (compatible to curses) ****************************/
  85. short  row = 0, col = 0;
  86. char   mz[2000], mv[2000];
  87.  
  88. void move(y, x)
  89. {
  90.     row = y;
  91.     col = x;
  92. }
  93.  
  94. void move_left()  { move(row, --col); }
  95. void move_right() { move(row, ++col); }
  96. void move_down()  { move(++row, col); }
  97. void move_up()    { move(--row, col); }
  98. int get_position() { return(row*80 + col); }
  99.  
  100. void set_writable(y, x)
  101. short  y, x;
  102. {
  103.     mv[y*80+x] = 1;
  104. }
  105.  
  106. _iswritable(y, x)
  107. int  y, x;
  108. {
  109.     if(mv[y*80+x] < 0)  return( 0 );
  110.     else  return( 1 );
  111. }
  112.  
  113. iswritable() { return( _iswritable(row, col) ); }
  114.  
  115. void addstr( s )
  116. char  *s;
  117. {
  118.     short  i, n;
  119.     n = strlen( s );
  120.     for(i=0; i<n; i++)  addch( s[i] );
  121. }
  122.  
  123. void mvaddstr(y, x, s)
  124. int  y, x;
  125. char *s;
  126. {
  127.     move(y, x);
  128.     addstr( s );
  129. }
  130.  
  131. void addch( c )
  132. char  c;
  133. {
  134.     char  cc[2];
  135.     cc[0] = c;  cc[1] = 0;
  136.     xouttext(row, col, cc, 1);
  137.     mz[row*80+col] = c;
  138.     move(row, col+1);
  139. }
  140.  
  141. void mvaddch(y, x, c)
  142. short  y, x, c;
  143. {
  144.     move(y, x);
  145.     addch( c );
  146. }
  147.  
  148. mvinch(y, x)
  149. int  y, x;
  150. {
  151.     return( mz[y*80+x] );
  152. }
  153.  
  154. #ifdef RISC_NEWS
  155. void printw(va_alist)
  156. va_dcl
  157. {
  158.     va_list args;
  159.     char    *fmt, s[81];
  160.  
  161.     va_start(args);
  162.     fmt= va_arg(args, char *);
  163.     (void)vsprintf(s, fmt, args);
  164.     addstr(s);
  165.     va_end(args);
  166. }
  167. #else
  168. void printw(fmt, A1, A2, A3, A4, A5, A6)
  169. char  *fmt;
  170. long  A1, A2, A3, A4, A5, A6;
  171. {
  172.     char  s[81];
  173.     sprintf(s, fmt, A1, A2, A3, A4, A5, A6);
  174.     addstr( s );
  175. }
  176. #endif
  177.  
  178. void wreverse() { _setcolor( 0 ); _setbkcolor( 7 ); }
  179. void wblink()   { _setcolor( 4 ); _setbkcolor( 9 ); }
  180. void wrblink()  { _setcolor( 4 ); _setbkcolor( 7 ); }
  181. void standend() { _setcolor( 0 ); _setbkcolor( 9 ); }
  182.  
  183. void clrtoeol()
  184. {
  185.     short   y, x, i;
  186.     char    s[81];
  187.  
  188.     y = row;
  189.     x = col;
  190.     for(i=x; i<80; i++)  s[i-x] = ' ';
  191.     s[i-x] = 0;
  192.     addstr( s );
  193.     move(y, x);
  194. }
  195.  
  196. void clear( clr )
  197. int  clr;
  198. {
  199.     short  i;
  200.  
  201.     for(i=0; i<2000; i++)  mz[i] = ' '; /* Assign blanks */
  202.     for(i=0; i<2000; i++)  mv[i] =  -1; /* Assign unwritable flags */
  203.     physical_clear( clr );
  204. }
  205.  
  206. void backspace()
  207. {
  208.     short  i, colold;
  209.  
  210.     if( _iswritable(row, col-1) ) {
  211.     colold = col;
  212.     i = col;
  213.     do mvaddch(row, i-1, mz[row*80+i]);
  214.     while( _iswritable(row, ++i) );
  215.     addch( ' ' );
  216.     move(row, colold-1);
  217.     }
  218.     else  beep();
  219. }
  220.  
  221. short getchr()
  222. {
  223.     short  c;
  224.  
  225.     wreverse();
  226.     _setbkcolor( 2 );
  227.     if( iswritable() ) _small_font(); else _normal_font();
  228.     addch( mz[row*80+col] );
  229.     move(row, --col);
  230.  
  231.     c = getcchr();
  232.  
  233.     if( iswritable() ) { wreverse(); _small_font(); }
  234.     else  { standend(); _normal_font(); }
  235.     addch( mz[row*80+col] );
  236.     move(row, --col);
  237.     restore_box(col, row);
  238.     if( iswritable() )  { wreverse(); _small_font(); }
  239.     else { standend(); _normal_font(); }
  240.     return( c );
  241. }
  242.  
  243. void avoid_cr( s )
  244. char  s[];
  245. {
  246. /* Avoid CR at the end of line */
  247. #ifdef WIN32
  248.     s[strlen(s)-1] = 0;
  249. #else
  250.     s[strlen(s)-2] = 0;
  251. #endif
  252. }
  253.  
  254. int bload(sg, off, fname)
  255. char *sg, *fname;
  256. unsigned  off;
  257. {
  258.     int  handle, len, rcod;
  259.     char *s, fn[78];
  260.  
  261.     /* seismicity data */
  262.     if(strstr(fname,".B") || strstr(fname,".b"))  strcpy(fn, drv$);
  263.     /* misc. data */
  264.     else  strcpy(fn, drvo$);
  265.     add_separator( fn );
  266. /* Don't change dummy strings. This results in segmentation fault on Linux.*/
  267. /*    strlwr( fname );  strcat(fn, fname); */
  268.     len = strlen( fn );  strcat(fn, fname);  strlwr( fn+len );
  269. #ifdef WIN32
  270.     handle = open(fn, O_BINARY|O_RDONLY);
  271. #else
  272.     handle = open(fn, O_RDONLY);
  273. #endif
  274.     if(handle == -1) {
  275.     sprintf(em$, "File '%s' does not exist!", fn);
  276.     return( 0 );
  277.     }
  278.     s = sg + off;
  279.     /* Windows ceck possibility of poking beyond the buffer end
  280.        (UNIX never does so). */
  281.     rcod = read(handle, s, 0xffff-off);
  282.     if(rcod == -1)  rcod = 0;
  283.     close( handle );
  284.     return( rcod );
  285. }
  286.  
  287. unsigned peek(off, sg) unsigned off;  unsigned char *sg;
  288. { return( (unsigned)sg[off] ); }
  289.  
  290. unsigned qeek(off, sg) unsigned off; unsigned char *sg;
  291. { return((unsigned)sg[off] + ((unsigned)sg[off+1] << 8)); }
  292.  
  293. void poke(byt, off, sg) unsigned byt, off; unsigned char *sg;
  294. { sg[off] = byt; }
  295.  
  296. /******************* Printers *********************/
  297.  
  298. /*************** Windows ****************/
  299. #ifdef WIN32
  300.  
  301. #define FontHeight    16
  302. #define FontWidth     8
  303. #define LineHeight    (FontHeight+1)
  304.  
  305. extern HWND   hwnd;
  306. extern HDC    hdc;
  307. extern HFONT  hFont, hSmallFont, hMenuFont;
  308. extern HBRUSH hBrush[];
  309. extern int    widespace;
  310.  
  311. int   PrinterWidth, PrinterHeight;
  312.  
  313. HDC     pdc, pmemdc;
  314. HBITMAP  pbit;
  315. HPEN     pPen[2];
  316. DOCINFO     di;
  317. double   Xratio;
  318. RECT     r;
  319. int      prow, pcol, plines;
  320.  
  321. int lpinit()
  322. {
  323.     double  mXPPI, pXPPI;
  324.  
  325.     prow = 0;  pcol = 0;
  326.  
  327.     pdc = CreateDC("WINSPOOL", port$, NULL, NULL);
  328.     if(pdc == NULL){
  329.     sprintf(em$, "Printer `%s' is not found!", port$);
  330.     return( 0 );
  331.     }
  332.     if(!(GetDeviceCaps(pdc,RASTERCAPS) & RC_BITBLT)) {
  333.     sprintf(em$, "Printer `%s' cannot print raster images!",
  334.         port$);
  335.     return( 0 );
  336.     }
  337.  
  338.     PrinterWidth  = GetDeviceCaps(pdc, HORZRES);
  339.     PrinterHeight = GetDeviceCaps(pdc, VERTRES);
  340.     pmemdc = CreateCompatibleDC( pdc );
  341.     pbit   = CreateCompatibleBitmap(pdc, PrinterWidth, PrinterHeight);
  342.     SelectObject(pmemdc, pbit);
  343.     PatBlt(pmemdc, 0, 0, PrinterWidth, PrinterHeight, WHITENESS);
  344.     SelectObject(pmemdc, hFont);      /* normal font  */
  345.     SelectObject(pmemdc, hBrush[12]); /* hollow brush */
  346.     GetClientRect(hwnd, &r);
  347.     mXPPI  = GetDeviceCaps(hdc, LOGPIXELSX);
  348.     pXPPI  = GetDeviceCaps(pdc, LOGPIXELSX);
  349.     Xratio = pXPPI / mXPPI;
  350.     plines = (int)(PrinterHeight / Xratio / LineHeight);
  351.  
  352.     memset(&di, 0, sizeof(DOCINFO));
  353.     di.cbSize = sizeof( DOCINFO );
  354.     di.lpszDocName = "SeisView hard copy";
  355.     StartDoc(pdc, &di);
  356.     StartPage( pdc );
  357.     return( 1 );
  358. }
  359.  
  360. void build_image()
  361. {
  362.     int  factor;
  363.  
  364.     if(psflag == 2)  factor = 2;
  365.     else  factor = 1;
  366.     StretchBlt(pdc, 0, 0, PrinterWidth/factor, PrinterHeight/factor,
  367.            pmemdc, 0, 0, (int)(PrinterWidth/Xratio),
  368.            (int)(PrinterHeight/Xratio), SRCCOPY); 
  369. }
  370.  
  371. void lpclose(){
  372.     build_image();
  373.     EndPage( pdc );
  374.     EndDoc( pdc );
  375.     DeleteDC( pdc );
  376. }
  377.  
  378. void newpage()
  379. {
  380.     build_image();
  381.     EndPage( pdc );
  382.     PatBlt(pmemdc, 0, 0, PrinterWidth, PrinterHeight, WHITENESS);
  383.     StartPage( pdc );
  384.     prow = 0;
  385. }
  386.  
  387. void lpputn(s, n)
  388. int   n;
  389. char  *s;
  390. {
  391.     int   yw, xw;
  392.  
  393.     if( widespace )  yw = yy(prow * LineHeight);
  394.     else  yw = yy(prow * FontHeight);
  395.     xw = xx(pcol * FontWidth);
  396.     TextOut(pmemdc, xw, yw, s, n);
  397.     pcol = pcol + strlen(s);
  398. }
  399.  
  400. void lpputs( s )
  401. char *s;
  402. {
  403.     unsigned int i;  char t[2];
  404.  
  405.     for(i=0; i<strlen(s); i++) {
  406.     if(s[i] == '\r')  pcol = 0;
  407.     else if(s[i] == '\n') {
  408.         if(++prow > plines-1)  newpage();
  409.     }
  410.     else {
  411.         t[0] = s[i];  t[1] = 0;
  412.         lpputn(t, 1);
  413.     }
  414.     }
  415. }
  416.  
  417. /*************** Simulated PostScript ****************/
  418.  
  419. extern short   xoff, yoff;
  420.  
  421. void psinit()
  422. {
  423.     pPen[0] = CreatePen(PS_SOLID  , 1, 0);
  424.     pPen[1] = CreatePen(PS_DASHDOT, 1, 0);
  425. }
  426.  
  427. void psviewport(x1, y1, x2, y2)
  428. short  x1, y1, x2, y2;
  429. {
  430.     HRGN hrgn;
  431.     int  left, right, top, bottom;
  432.  
  433.     if(x1==0 && y1==0 && x2==639 && y2==YPixels-1) { /* Full Screen */
  434.     left   = 0;
  435.     top    = 0;
  436.     right  = PrinterWidth;
  437.     bottom = PrinterHeight;
  438.     }
  439.     else {
  440.     left   = xx( x1 );
  441.     top    = yy( y1 );
  442.     right  = xx( x2 );
  443.     bottom = yy( y2 );
  444.     }
  445.     hrgn = CreateRectRgn(left, top, right, bottom);
  446.     SelectClipRgn(pmemdc, hrgn);
  447.     xoff = x1;
  448.     yoff = y1;
  449. }
  450.  
  451. void psmoveto(x, y) short  x, y;
  452. { MoveToEx(pmemdc, xx(x), yy(y), NULL); }
  453.  
  454. void pslineto(x, y) short  x, y;
  455. { LineTo(pmemdc, xx(x), yy(y)); }
  456.  
  457. void pspen(ipen, idash)
  458. int  ipen, idash;
  459. {
  460.     if(idash == 1)  SelectObject(pmemdc, pPen[1]);
  461.     else  SelectObject(pmemdc, pPen[0]);
  462. }
  463.  
  464. void psnormal_font() { SelectObject(pmemdc, hFont); }
  465. void pssmall_font()  { SelectObject(pmemdc, hSmallFont); }
  466.  
  467. void pstext(x, y, s)
  468. int  x, y;
  469. char *s;
  470. { TextOut(pmemdc, xx(x), yy(y), s, strlen(s)); }
  471.  
  472. void pscircle(x, y, r)
  473. short  x, y, r;
  474. {
  475.     if(r <= 1)  SetPixel(pmemdc, xx(x), yy(y), 0);
  476.     else  Ellipse(pmemdc, xx(x)-r, yy(y)-r, xx(x)+r, yy(y)+r);
  477. }
  478.  
  479. void psbox(flag, x1, y1, x2, y2)
  480. short flag, x1, y1, x2, y2;
  481. { Rectangle(pmemdc, xx(x1), yy(y1), xx(x2), yy(y2)); }
  482.  
  483. void pshcopy( n )
  484. short  n;
  485. {
  486.     lpclose();
  487. }
  488.  
  489. /*************** UNIX ****************/
  490. #else
  491.  
  492. FILE   *fq;
  493.  
  494. int pfile_open( s )
  495. char  *s;
  496. {
  497.     fq = fopen("seis.prn", s);
  498.     if(fq == NULL)  return( 0 );
  499.     else  return( 1 );
  500. }
  501.  
  502. void pfile_close() { fclose( fq ); }
  503.  
  504. char *strupr( s )
  505. char  *s;
  506. {
  507.     char  *t;
  508.     t = s;
  509.     while(*t != 0)  *(t++) = toupper( (int)*t );
  510.     return( s );
  511. }
  512.  
  513. char *strlwr( s )
  514. char  *s;
  515. {
  516.     char  *t;
  517.     t = s;
  518.     while(*t != 0)  *(t++) = tolower( (int)*t );
  519.     return( s );
  520. }
  521.  
  522. char *itoa(i, s, radix)
  523. int  i, radix;
  524. char *s;
  525. {   /* Assume radix = 10. */
  526.     sprintf(s, "%d", i);
  527.     return( s );
  528. }
  529.  
  530. int  lpinit()
  531. {
  532.     int  rc;
  533.     rc = pfile_open("w");
  534.     if(rc == 0)  strcpy(em$, "Printer file cannot be opened!");
  535.     return( rc );
  536.  }
  537.  
  538. void lpputs( s ) char *s; { fputs(s, fq); }
  539.  
  540. void lpclose()
  541. { pfile_close();  lpsubmit(); }
  542.  
  543. void lpputn(s, n)  char *s; int n;
  544. { int  i;  for(i=0; i<n; i++)  fputc(*(s++), fq); }
  545.  
  546. void lpsubmit()
  547. {
  548.     char   cmd[25];
  549.  
  550.     strcpy(cmd, "lpr -P");  strcat(cmd, port$);
  551.     strcat(cmd," seis.prn");
  552.     system( cmd );
  553. }
  554.  
  555. /*************** PostScript ****************/
  556.  
  557. #define  PSXOffset   60.0
  558. #define  PSYOffset   110.0
  559. #define  XOffset     4
  560. #define  YOffset     5
  561. double   PSXFactor, PSYFactor, PSFontSize = 15.95;
  562. short    psxoff, psyoff;
  563.  
  564. double xps( x )  short  x;
  565. { return((x+psxoff)*PSXFactor + PSXOffset); }
  566.  
  567. double yps( y )  short  y;
  568. { return((YPixels-y-psyoff)*PSYFactor + PSYOffset); }
  569.  
  570. void psinit()
  571. {
  572.     fputs("%!PS-Adobe-2.0 EPSF-2.0\n", fq);
  573.     fputs("%%BoundingBox:                    \n", fq);
  574.     fputs("initmatrix\n", fq);
  575.     fputs("/pM {stroke newpath moveto} def\n", fq);
  576.     fputs("/pL {lineto} def\n", fq);
  577.     fputs("/pQ {moveto} def\n", fq);
  578.     fputs("2 setlinejoin\n", fq);
  579.     fputs("/tR {/Times-Roman findfont exch scalefont setfont} def\n", fq);
  580.     fputs("/tI {/Times-Italic findfont exch scalefont setfont} def\n", fq);
  581.     fputs("/tB {/Times-Bold findfont exch scalefont setfont} def\n", fq);
  582.     fputs("/hV {/Helvetica-Bold findfont exch scalefont setfont}def\n",fq);
  583.     fputs("590 5 translate\n90 rotate\n", fq);
  584.     fputs("        scale\n", fq);
  585.     pspen(2, 0);
  586.     fputs("gsave\nnewpath\n", fq);
  587.     PSYFactor = 440. / YPixels;
  588.     PSXFactor = PSYFactor;
  589. }
  590.  
  591. void psterm()
  592. {
  593.     fputs("stroke\n", fq);
  594.     fputs("showpage\n", fq);
  595. }
  596.  
  597. void psviewport(x1, y1, x2, y2)
  598. short  x1, y1, x2, y2;
  599. {
  600.     double  xp1, yp1, xp2, yp2;
  601.  
  602.     psxoff = x1;
  603.     psyoff = y1;
  604.     if(x1==0 && y1==0 && x2==639 && y2==YPixels-1) {
  605.     fputs("stroke\ngrestore\ngsave\n", fq);
  606.     }
  607.     else {
  608.     xp1 = x1*PSXFactor + PSXOffset;
  609.     yp1 = (YPixels-y1)*PSYFactor + PSYOffset;
  610.     xp2 = x2*PSXFactor + PSXOffset;
  611.     yp2 = (YPixels-y2)*PSYFactor + PSYOffset;
  612.     fprintf(fq, "/viewpath { newpath %6.1f %6.1f pM\n", xp1, yp1);
  613.     fprintf(fq, "%6.1f %6.1f pL\n", xp2, yp1);
  614.     fprintf(fq, "%6.1f %6.1f lineto\n", xp2, yp2);
  615.     fprintf(fq, "%6.1f %6.1f lineto\n", xp1, yp2);
  616.     fputs("closepath } def\n", fq);
  617.     fputs("grestore\ngsave\nviewpath clip\n", fq);
  618.     }
  619. }
  620.  
  621. void psmoveto(x, y)  short  x, y;
  622. { fprintf(fq, "%6.1f %6.1f pM\n", xps(x), yps(y)); }
  623.  
  624. void pslineto(x, y)  short  x, y;
  625. { fprintf(fq, "%6.1f %6.1f pL\n", xps(x), yps(y)); }
  626.  
  627. void psbox(flag, x1, y1, x2, y2)
  628. short flag, x1, y1, x2, y2;
  629. {
  630.     if(_getcolor() > 0) {
  631.     if( flag )  fputs("stroke newpath\n", fq);
  632.     psmoveto(x1, y1);
  633.     pslineto(x2, y1);
  634.     pslineto(x2, y2);
  635.     pslineto(x1, y2);
  636.     pslineto(x1, y1);
  637.     if( flag )  fputs("gsave stroke grestore fill\n", fq);
  638.     }
  639. }
  640.  
  641. void pscircle(x, y, r)
  642. short  x, y, r;
  643. {
  644.     psmoveto(x+r, y);
  645.     fprintf(fq, "%6.1f %6.1f %6.1f %6.1f %6.1f arc\n",
  646.         xps(x), yps(y), r*PSXFactor, 0., 360.);
  647. }
  648.  
  649. void pstext(x, y, s)
  650. int  x, y;
  651. char *s;
  652. {
  653.     unsigned  i;
  654.  
  655.     fprintf(fq, "0 %6.1f rmoveto\n", -(PSFontSize-2)*PSYFactor);
  656.     fprintf(fq, "%6.1f tR (", PSFontSize);
  657.     for(i=0; i<strlen(s); i++) {
  658.     if(s[i]=='(' || s[i]==')')  fputc('\\', fq);
  659.     fputc(s[i], fq);
  660.     }
  661.     fputs(") show\n", fq);
  662. }
  663.  
  664. void psnormal_font() { PSFontSize = 15.95; }
  665. void pssmall_font()  { PSFontSize = 10.; }
  666.  
  667. void pspen(ipen, idash)
  668. int  ipen, idash;
  669. {
  670.     double  width;
  671.  
  672.     if( psflag ) {
  673.     if(ipen>=0 || idash>=0)  fputs("stroke\n", fq);
  674.     if(ipen >= 0) {
  675.         width = ipen * 0.2 + 0.1;
  676.         if(ipen == 0)  width = 0.;
  677.         fprintf(fq, "%6.2f setlinewidth\n", width);
  678.     }
  679.     if(idash == 1)  fputs("[6 2 2 2] 0 setdash\n", fq);
  680.         else if(idash == 0)  fputs("[] 0 setdash\n", fq);
  681.     }
  682. }
  683.  
  684. void pshcopy( n )
  685. short  n;
  686. {
  687.     short  i;
  688.     long   m;
  689.  
  690.     psterm();  pfile_close();
  691.  
  692.     /* `open as a+ and rewind' does not work on BSD/386. */
  693.     if( pfile_open("r+") ) {
  694.     m = 0;
  695.     for(i=0; i<13; i++) { fgets(w$,81,fq);  m += strlen(w$); }
  696.     fseek(fq, m, 0);
  697.     fprintf(fq, "%3.1f %3.1f", 0.5*(3-n), 0.5*(3-n));
  698.     pfile_close();
  699.     lpsubmit();
  700.     }
  701. }
  702.  
  703. #endif
  704.  
  705. /****************** common routines **********************/
  706.  
  707. int tcopy()
  708. {
  709.     /* c[1]=0 is required for TextOut of Windows. */
  710.     int  i, j;  char c[2];
  711.  
  712.     blueF1_2( 0 );
  713.     if(lpinit() == 0)  return( 0 );
  714.     c[1] = 0;
  715.     for(i=0; i<25; i++) {
  716.     for(j=0; j<80; j++) {
  717.         c[0] = mz[i*80+j];
  718.         if(! isprint(c[0]))  c[0] = ' ';
  719.         lpputn(c, 1);
  720.     }
  721.         lpputs( "\r\n" );
  722.     }
  723.     lpclose();
  724.     return( 1 );
  725. }
  726.  
  727. void hcopy(){}
  728.