FPRINT.CPP
资源名称:commutil.zip [点击查看]
上传用户:xr_qian
上传日期:2007-01-05
资源大小:443k
文件大小:5k
源码类别:
通讯/手机编程
开发平台:
DOS
- // ******************************************************************** //
- // //
- // FPRINT.CPP //
- // Copyright (c) 1993, Michael Holmes and Bob Flanders //
- // C++ Communication Utilities //
- // //
- // This file contains the routines under the PRINT main //
- // menu entry. //
- // //
- // ******************************************************************** //
- /* ******************************************************************** *
- *
- * f_lpt() -- format and print the fax to a printer
- *
- * ******************************************************************** */
- int f_lpt(int c, int r, // column and row
- int pn) // printer number
- {
- int i, j, k, l, // loop counters
- qf = 0; // quit flag
- char huge *p, huge *q, // work pointer
- buf[128]; // ..and work buffer
- Window p_win(c, r, // define temporary window
- c + 40, r + 4, // ..to hold message
- menu_cn, menu_cr); // ..using system colors
- int f; // printer file number
- if (f_handle == -1) // q. file open?
- return(ESC); // a. no .. just return
- p_win.Open(double_line); // open window with a border
- p_win.Display(print_msg); // give filename prompt
- sprintf(buf, "LPT%d", pn); // build printer name
- f = open(buf, O_WRONLY | O_BINARY); // open file for binary output
- for (i = 1; f_read_g3(i) == 0 && // for each page..
- NOT qf; i++)
- {
- sprintf(buf, page_msg, i, f_pgcnt); // format page status
- p_win.Display(buf); // ..and keep user informed
- sprintf(buf, ESC_CHAR "E" // reset printer
- ESC_CHAR "*p336x450Y" // position printer cursor
- ESC_CHAR "*t300R" // 300 dots per inch
- ESC_CHAR "*r0F" // specify orientation
- ESC_CHAR "*r1A"); // start raster graphics
- _write(f, buf, strlen(buf)); // ..write the line
- for (j = 0, p = page; j < LINES; // for each line
- j++, p += LINE) // ..in the bitmap
- {
- for (k = LINE, q = &p[k-1]; // starting at the end of line
- k > 1 && NOT *q; k--, q--) // ..and working backwards
- ; // ..look for non-null data
- sprintf(buf, ESC_CHAR "*b%dW", k); // give graphic command
- _write(f, buf, strlen(buf)); // ..send to the printer
- l = _write(f, p, k); // ..and print the data line
- assert(l == k);
- sprintf(buf, ESC_CHAR "*b%dW", k); // give graphic command
- _write(f, buf, strlen(buf)); // ..send to the printer
- l = _write(f, p, k); // ..and print the data line
- assert(l == k);
- if (get_key(ALLOW_ALT)) // q. key hit?
- {
- qf = 1; // a. yes .. set quit flag
- break; // ..and exit loop
- }
- }
- sprintf(buf, ESC_CHAR "*rB"); // end graphic mode
- _write(f, buf, strlen(buf)); // ..write the line
- }
- sprintf(buf, ESC_CHAR "E"); // re-initialize printer
- _write(f, buf, strlen(buf)); // ..write the line
- close(f); // ..and close file
- return(ESC); // finally, rtn to caller
- }
- /* ******************************************************************** *
- *
- * f_lpt1() -- print the fax to LPT1:
- *
- * ******************************************************************** */
- int f_lpt1(int c, int r) // column and row
- {
- f_lpt(c, r, 1); // print on LPT1:
- return(ESC); // ..and return to menu
- }
- /* ******************************************************************** *
- *
- * f_lpt2() -- print the fax to LPT2:
- *
- * ******************************************************************** */
- int f_lpt2(int c, int r) // column and row
- {
- f_lpt(c, r, 2); // print on LPT2:
- return(ESC); // ..and return to menu
- }
- /* ******************************************************************** *
- *
- * f_lpt3() -- print the fax to LPT3:
- *
- * ******************************************************************** */
- int f_lpt3(int c, int r) // column and row
- {
- f_lpt(c, r, 3); // print on LPT3:
- return(ESC); // ..and return to menu
- }