www.pudn.com > commutil.zip > FAXUTIL.CPP
// ******************************************************************** // // // // FAXUTIL.CPP // // Copyright (c) 1993, Michael Holmes and Bob Flanders // // C++ Communication Utilities // // // // This file contains the main function for the fax utility // // program. This program allows the user to view, print and // // encode ASCII text files into fax formated files. This code // // is Borland C++ version 3.x specific. Code for Microsoft // // C/C++ version 7 is on diskette. // // // // Compile with: BCC -O2-i -mc faxutil.cpp // // // // ******************************************************************** // #include// standard i/o library #include // variable argument list #include // string handling routines #include // std conversion routines #include // assertion routines #include // dos functions #include // character routines #include // console functions #include // bios functions #include // directory routines #include // memory routines #include // file i/o functions #include // access symbolics #include // graphics routines #include // dos create fnc flags #include "keys.h" // keyboard definitions #define CURSOR() _setcursortype(_NORMALCURSOR) // normal text cursor #define BIGCURSOR() _setcursortype(_SOLIDCURSOR) // insert mode cursor #define NOCURSOR() _setcursortype(_NOCURSOR) // turn off cursor #define COUNT(x) (sizeof(x) / sizeof(x[0])) // item count #define NOT ! // shorthand logical #define BYTE char // single byte #define UINT unsigned int // unsigned integer #define UCHAR unsigned char // unsigned char #define MAX_PATH 79 // maximum path length #define MIX(x,y) ((x << 4) + (y)) // mix colors for fg and bg #define FG(x) (unsigned char) x >> 4 // extract foreground color #define BG(x) x & 0x07 // ..and background color #define IN(x) inportb(base + x) // read a UART register #define OUT(x,y) outportb(base + x, y) // ..and write a register #define PELS 1728 // pixels per line #define LINE PELS / 8 // bytes per line #define LINES 1143 // lines per page #define PAGE ((long)LINE * LINES) // bitmap size #define COLUMNS PELS / 16 // max chars per line #define ROWS LINES / 22 // ..and max lines per page #define DLE 0x10 // DLE character #define ETX 0x3 // ..and ETX character #define ESC_CHAR "\x1b" // escape char for printer /* ******************************************************************** * * * Routine definitions * * ******************************************************************** */ void initialization(int, char **), // initialization wait(long); // wait a number of ticks int f_exit(int, int), // menu exit routine f_open(int, int), // fax file open routine f_format(int, int), // format ASCII file routine f_lpt1(int, int), // fax print for LPT1: f_lpt2(int, int), // ..LPT2: f_lpt3(int, int), // ..and LPT3: f_view(int, int), // view fax onscreen get_key(int); // get any type of key /* ******************************************************************** * * * Includes * * ******************************************************************** */ #include "window.cpp" // window class #include "menu.cpp" // menu class #include "fglobal.cpp" // strings and global data #include "futility.cpp" // utility functions #include "codeword.cpp" // codewords for G3 encoding #include "asciimap.cpp" // bitmap of ASCII chars #include "fconvert.cpp" // conversion routines #include "ffile.cpp" // file menu functions #include "fprint.cpp" // print menu functions #include "fview.cpp" // view menu functions /* ******************************************************************** * * * main() -- mainline * * ******************************************************************** */ void main(int argc, // command line token count char *argv[]) // ..and command line tokens { printf(copyright); // display copyright msg initialization(argc, argv); // init and parse cmd line while(NOT quit_flag) // loop 'til user requests out main_menu.Display(0x100); // ..else display menu, always clrscr(); // clean up screen rc = 0; // clear DOS errorlevel quit_with(done); // ..and give completion msg } /* ******************************************************************** * * * initialization() -- perform framework initializations * * ******************************************************************** */ void initialization(int ac, // command line token count char *av[]) // ..and command line tokens { struct text_info screen; // screen info structure old_break = _dos_getvect(0x1b); // get old ^break handler addr if (ac > 1 || // q. need help.. NOT strcmp(av[1], "/?")) // ..or want help? quit_with(help); // a. yes .. give help/quit _dos_setvect(0x1b, control_break); // set up control break _dos_setvect(0x24, critical_routine); // ..and DOS critical handler gettextinfo(&screen); // get current screen info max_lines = screen.screenheight; // save max lines on screen if (screen.screenwidth < 80) // q. less than 80 columns? quit_with(bad_width); // a. yes .. give error/quit if (screen.currmode == BW80 || // q. black and white mode.. screen.currmode == MONO) // ..or monochrome mode? { main_menu.SetColors(mono_1, mono_2); // a. yes .. set up for term_cn = mono_2; // ..monochrome display term_cr = mono_1; // ..for all windows stat_cn = mono_1; } page = (char *) malloc_chk(PAGE); // get memory for bitmap wait_ms(1000L); // wait a little bit full_screen = 1; // show init complete _wscroll = 1; // set scrolling mode term = new Window(1, 1, 80, 24, // define main window term_cn, term_cr); // ..and its colors term->Open(none); // ..then open w/o borders status_line(status, ""); // clear status line } /* ******************************************************************** * * * f_exit() -- user exit request, called from memu entry * * ******************************************************************** */ #pragma argsused // hold unused arg messages int f_exit(int c, int r) // column and row { quit_flag = 1; // set termination flag return(ESC); // return with an ESC to // ..cause menu to return }