/* SPOL.C 08/03/84 - 06/24/85 Lee Lorenzen */ /* added printer # and text flag 11/18/87 mdf */ /*** INCLUDE FILES ******************************************************/ #include #include #include #include #include #include /*** DEFINES ***********************************************************/ #define SPLSIZE 2048 #define NUM_SPOL 12 #define SPOL_SND 8 /*** GLOBAL VARIABLES ***************************************************/ EXTERN WORD gl_apid; EXTERN WORD color; GLOBAL BYTE spol_bufr[SPLSIZE]; GLOBAL UWORD spol_cntr; GLOBAL BYTE *spol_ptr; GLOBAL LONG spol_fcnt,spol_path,spol_pbuf; GLOBAL WORD spol_sts; GLOBAL WORD spol_texp; GLOBAL WORD spol_tcnt; GLOBAL WORD spol_prn; GLOBAL BYTE gl_fspol[82]; GLOBAL BYTE gl_fspec[68]; GLOBAL BYTE gl_fname[14]; GLOBAL LONG ad_spol; GLOBAL WORD wh_spol; GLOBAL WORD gl_lastch; GLOBAL WORD gl_itspol; GLOBAL WORD gl_inspol; GLOBAL WORD gl_spnxt; GLOBAL BYTE *gl_sppfn[12]; GLOBAL WORD gl_spdel[12]; GLOBAL WORD gl_sptab[12]; GLOBAL WORD gl_spcnt[12]; GLOBAL WORD gl_spprn[12]; GLOBAL BYTE *gl_splst[12] = { "01_\1234567890123456789012345678901234567890123456789012345678901234567890", "02_\1234567890123456789012345678901234567890123456789012345678901234567890", "03_\1234567890123456789012345678901234567890123456789012345678901234567890", "04_\1234567890123456789012345678901234567890123456789012345678901234567890", "05_\1234567890123456789012345678901234567890123456789012345678901234567890", "06_\1234567890123456789012345678901234567890123456789012345678901234567890", "07_\1234567890123456789012345678901234567890123456789012345678901234567890", "08_\1234567890123456789012345678901234567890123456789012345678901234567890", "09_\1234567890123456789012345678901234567890123456789012345678901234567890", "10_\1234567890123456789012345678901234567890123456789012345678901234567890", "11_\1234567890123456789012345678901234567890123456789012345678901234567890", "12_\1234567890123456789012345678901234567890123456789012345678901234567890", }; VOID spol_file( fname, tabexp, prntr) BYTE *fname; WORD tabexp; WORD prntr; { spol_path = ADDR(fname); spol_pbuf = ADDR( spol_bufr ); spol_prn = prntr; spol_sts = FALSE; spol_cntr = 0; spol_fcnt = 0; spol_texp = tabexp; spol_tcnt = 0; spol_gblk(); } VOID spol_gblk() { BYTE handle; handle = dos_open( spol_path, 0x0000 ); if (handle) { dos_lseek( handle, 0x0000, spol_fcnt ); spol_cntr = dos_read( handle, SPLSIZE, spol_pbuf ); if ( spol_cntr != SPLSIZE ) spol_sts = TRUE; spol_fcnt += LW( spol_cntr ); dos_close( handle ); spol_ptr = spol_bufr; } else { spol_sts = TRUE; spol_cntr = 0; } } WORD spol_tab( thechar ) WORD thechar; { WORD out; if (spol_texp) { if ( thechar == 0x09 ) { out = 8 - (spol_tcnt & 0x0007); if ( spol_out( gl_lastch = ' ' ) ) { spol_tcnt++; out--; return( !out ); } return(FALSE); } else { if ( spol_out( gl_lastch = thechar) ) { if ( thechar == 0x0D ) spol_tcnt = 0; if (thechar >= ' ') spol_tcnt++; return( TRUE ); } return( FALSE ); } } else return( spol_out( gl_lastch = thechar) ); } WORD spol_doit() { WORD i; if ( spol_cntr ) { for (i=0; i= 3) { the_spol[0].ob_spec = 0x0175L; } for (i=0; i pname) ) pstr--; if (*pstr == '.') { pstr++; for (i=0; i<3; i++) ptemp[i] = toupper(*pstr++); ptemp[3] = NULL; if ( strcmp(&ptemp[0], "GEM") || strcmp(&ptemp[0], "IMG") || strcmp(&ptemp[0], "GMP") || strcmp(&ptemp[0], "OUT") ) return(FALSE); } return(TRUE); } hndl_spmsg(len, lpath, cnt, delit, prntr) WORD len; LONG lpath; WORD cnt; WORD delit; WORD prntr; { BYTE *pslot; WORD newprn; pslot = spol_alloc(); if (pslot) { switch (prntr & 0xFF) { case 0: case 1: case 2: newprn = prntr; break; default: newprn = 0; /* LPT1 */ } LBCOPY(ADDR(pslot), lpath, len + 1); gl_sppfn[gl_spnxt] = pslot; gl_spdel[gl_spnxt] = delit; gl_sptab[gl_spnxt] = ((prntr & 0x0100) == 0); gl_spcnt[gl_spnxt] = cnt; gl_spprn[gl_spnxt] = newprn; if (!gl_spnxt) spol_file( pslot, gl_sptab[gl_spnxt], gl_spprn[gl_spnxt] ); gl_spnxt++; } spol_bttn(); spol_draw(SPOLBOX); } act_allchg(ex_obj, pt, chgvalue, dochg) WORD ex_obj; GRECT *pt; WORD chgvalue, dochg; { WORD obj, newstate; GRECT o; for(obj=F1NAME; obj!=SPOLBOX; obj=the_spol[obj].ob_next) { if ( (obj != ex_obj) && (gl_sppfn[obj - F1NAME] != NULLPTR) ) { objc_offset(ad_spol, obj, &o.g_x, &o.g_y); o.g_w = the_spol[obj].ob_width; o.g_h = the_spol[obj].ob_height; if ( r_intersect(pt->g_x, pt->g_y, pt->g_w, pt->g_h, &o.g_x, &o.g_y, &o.g_w, &o.g_h) ) { /* make change */ newstate = the_spol[obj].ob_state; if ( dochg ) newstate |= chgvalue; else newstate &= ~chgvalue; if (newstate != the_spol[obj].ob_state) spol_chg(obj, newstate); } } } } spol_down(mx, my) WORD mx, my; { GRECT m; WORD curr_ob; curr_ob = objc_find(ad_spol, ROOT, MAX_DEPTH, mx, my); if ( (curr_ob == ROOT) || (curr_ob == SPOLBOX) ) { m.g_x = mx; m.g_y = my; graf_rubbox(mx, my, 6, 6, &m.g_w, &m.g_h); act_allchg(curr_ob, &m, SELECTED, TRUE); } } VOID hndl_spsel(mx, my, mb, ks) WORD mx, my; WORD mb; WORD ks; { WORD curr_ob, x, y, w, h; WORD state, shifted; OBJECT *pobs; LONG tree; GRECT full; tree = ad_spol; shifted = (ks & K_LSHIFT) || (ks & K_RSHIFT); curr_ob = objc_find(tree, ROOT, MAX_DEPTH, mx, my); if ( (curr_ob >= F1NAME) && (curr_ob <= F12NAME) && (gl_sppfn[curr_ob - F1NAME] != NULLPTR) ) { state = the_spol[curr_ob].ob_state; if ( !shifted ) { if ( !(state & SELECTED) ) { act_allchg(curr_ob, &the_spol[0].ob_x, SELECTED, FALSE); state |= SELECTED; } } else { if (state & SELECTED) state &= ~SELECTED; else state |= SELECTED; } if (state != the_spol[curr_ob].ob_state ) spol_chg(curr_ob, state); } else { act_allchg(curr_ob, &the_spol[0].ob_x, SELECTED, FALSE); } graf_mkstate(&mx, &my, &mb, &ks); if (mb & 0x0001) spol_down(mx, my); } splt_dir(dir_wc,dir,wc) /* NEW ROUTINE 3/3/86 */ BYTE *dir_wc; BYTE *dir, *wc; { WORD length; BYTE *i; i = dir_wc + strlen(dir_wc); while ( ( *i != '\\') && ( *i != ':') ) { i--; if( i < dir_wc) { break; } } i++; if(strlen(i)) { strcpy( i, wc ); *i = NULL; } if(strlen(dir_wc)) { strcpy( dir_wc, dir ); } } /* splt_dir */ WORD file_exists( dir, name ) /* NEW ROUTINE 3/3/86 */ BYTE *dir; BYTE *name; { BYTE f_name[80]; strcpy( dir, f_name ); strcat( f_name, name ); return( dos_sfirst( ADDR(f_name), 0 ) ); } VOID hndl_spbut(ob) WORD ob; { BYTE *pstr; WORD isok; WORD i, j, k, remvd_1st, isgrafic; WORD exists; /* NEW LINE 3/3/86 */ BYTE dir[ 80 ]; /* NEW LINE 3/3/86 */ BYTE new_wc[ 14 ]; /* NEW LINE 3/3/86 */ BYTE new_file[ 14 ]; /* NEW LINE 3/3/86 */ BYTE dir_wc[ 80 ]; /* NEW LINE 3/3/86 */ if ( ob == ADDNAME ) { strcpy("", &gl_fname[0]); fsel_input(ADDR(&gl_fspec[0]), ADDR(&gl_fname[0]), &isok); strcpy( gl_fspec, dir_wc ); /* NEW LINE 3/3/86 */ strcpy( gl_fname, new_file ); /* NEW LINE 3/3/86 */ splt_dir( dir_wc, dir, new_wc ); /* NEW LINE 3/3/86 */ exists = file_exists( dir, new_file ); /* NEW LINE 3/3/86 */ if ( exists ) /* NEW LINE 3/3/86 */ { if ( (isok) && (gl_fname[0]) && (gl_fspec[0]) ) { strcpy(&gl_fspec[0], &gl_fspol[0]); pstr = &gl_fspol[0]; while (*pstr) pstr++; pstr--; while ( (*pstr) && (*pstr != '\\') && (*pstr != ':') ) pstr--; if (*pstr) pstr++; strcpy(&gl_fname[0], pstr); if ( istext( &gl_fname[0] ) ) hndl_spmsg(strlen(&gl_fspol[0]), ADDR(&gl_fspol[0]), 1, FALSE, 0); else { form_alert(1, ADDR("[1][The Print Spooler is only able to|\ directly print text files. If you wish|\ to print a graphic file in background,|\ go to the OUTPUT application, and select|\ the Print in Background option.][ OK ]") ); } } } else { if ( isok ) form_alert(1, ADDR("[1][I am sorry, but I am unable|\ to find the file requested.][ OK ]") ); } } if ( ob == REMNAME ) { j = 0; remvd_1st = isgrafic = FALSE; i = F1NAME; while( i != SPOLBOX ) { if (the_spol[i].ob_state & SELECTED) { the_spol[i].ob_state = NORMAL; k = i - F1NAME; if (k == 0) { remvd_1st = TRUE; isgrafic = !gl_sptab[0]; } spol_remv(k); j++; } else i = the_spol[i].ob_next; } if (j) { if (remvd_1st) { spol_sts = TRUE; spol_cntr = 0; if ( isgrafic ) spol_form(); if (gl_spnxt) spol_file(gl_sppfn[0], gl_sptab[0], gl_spprn[0]); } spol_draw(SPOLBOX); } } }