home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * pr_handl.c - printer routines for the PC.
- *
- * Purpose: This file contains the functions to print output to the
- * standard printer device.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include "blackstr.h"
- #include "sy_head.h"
- #include "pr_head.h"
- #include "pr_defs.h"
- #include "sc_head.h"
-
-
- /********
- *
- * pr_putc(c) - raw character print
- *
- **/
-
- int pr_putc(char c)
- {
- return(pr_putc_(c));
- }
-
-
- /********
- *
- * pr_putch(c) - print a character on standard out
- *
- **/
-
- int pr_putch(char c)
- {
- while((!pr_stat()) || (!pr_putc_(c))) {
- if(!pr_pause()) /* try to continue if not ready */
- return(FALSE);
- }
- return(TRUE);
- }
-
-
- /********
- *
- * pr_puts(str) - print a string
- *
- **/
-
- int pr_puts(char *str)
- {
- char *p;
-
- for (p=str; *p!=NUL; p++) {
- if(!pr_putch(*p))
- return(FALSE); /* printer not ready */
- }
- return(TRUE);
- }
-
-
- /********
- *
- * pr_putl(buff) - print a line of text
- *
- **/
-
- int pr_putl(char *buff)
- {
- char *l;
-
- for(l=buff; (*l!='\0')&&(*l!=LF); l++) {
- if((l-buff ) > MAX_PL)
- break;
- if(!pr_putch(*l))
- return(FALSE);
- }
- if(!pr_putch(CR))
- return(FALSE);
- else if(!pr_putch(NEWLINE))
- return(FALSE);
- return(TRUE); /* everything went ok */
- }
-
-
- /********
- *
- * pr_prtscr() - print the current screen
- *
- **/
-
- void pr_prtscr(void)
- {
- int ocol,orow,i,j;
-
- /* First, make sure the printer is ready */
-
- while(!pr_stat()) {
- if(kb_hit()) /* to abort, hit any key */
- return;
- }
- ocol = sc_col_; /* save previous cursor */
- orow = sc_row_;
- for(i = rowst_; i<=rowen_; i++) {
- for(j=colst_; j<colen_; ++j)
- if(!pr_putch(sc_getch(j,i)))
- break; /* if printer gets busy */
- pr_puts("\r\n");
- }
- sc_setcur(ocol,orow); /* restore cursor */
- pr_putff(); /* just do form feed */
- }
-
-
- /********
- *
- * pr_signal(on) - set up printer interrupt service
- *
- **/
-
- void pr_signal(int on)
- {
- extern pr_prtsc_();
- extern int dos_prvec_[2];
-
- if(on) {
- sy_getintv(IPRINT,dos_prvec_); /*save dos vector */
- sy_setintf(IPRINT,pr_prtsc_); /* set like a c function */
- }
- else
- sy_setintv(IPRINT,dos_prvec_); /* back to dos */
- }
-
-
- /********
- *
- * pr_putff() - print a form feed
- *
- **/
-
- void pr_putff(void)
- {
- pr_putch(FORMF);
- }
-
-
- /********
- *
- * pr_stat() - printer ready routine
- *
- **/
-
- int pr_stat(void)
- {
- int pstat;
-
- pstat = pr_stat_(0,2); /* get printer status */
- if((pstat & 0x20) /* out of paper */
- || (pstat & 0x08) /* i/o error */
- || (!(pstat & 0x10)) /* not selected */
- || (pstat & 0x01)) /* time out */
- return(FALSE);
- else
- return(TRUE); /* printer is ready */
- }
-
-
- /********
- *
- * pr_init(prtype) - initialize printer
- *
- **/
-
- void pr_init(int prtype)
- {
- extern char *prattr_,*prtabs_,*tprattr_[],*tprtabs_[];
-
- prattr_ = tprattr_[prtype];
- prtabs_ = tprtabs_[prtype];
- }
-
-
- /********
- *
- * pr_attr(type) - return printer attribute string pointer
- *
- **/
-
- char *pr_attr(int type)
- {
- extern char *prattr_;
-
- return(prattr_+(type*3));
- }
-
- /********
- *
- * pr_sattr(type) - setup printer for type
- *
- **/
-
- void pr_sattr(int type)
- {
- extern char *prattr_;
-
- type*= 3; /* 2 bytes per type */
- pr_putch(prattr_[type++]);
- pr_putch(prattr_[type]); /* 2 bytes of output */
- }
-
- /********
- *
- * pr_tabs() - return string for printer tabs
- *
- **/
-
- char *pr_tabs(void)
- {
- extern char *prtabs_;
-
- return(prtabs_);
- }
-
-
- /********
- *
- * pr_pause() - printer paused
- *
- **/
-
- int pr_pause(void)
- {
- sc_puts("\nPrinter is not ready -- push any key to continue, [ESC] to stop.");
- return ((kb_getc()==ESC)? FALSE : TRUE);
- }
-