/**************************************************************** * Filename: hpterm.c * Purpose: implements HP block mode terminals. * implements 'Primitive Commands' used * to configure local terminal charactistics. * implements NCD 'attached printer' protocol * that provides 'print screen' and 'passthru * printing' capabilities. * Usage: Called from telnetd.telrcv() * Author: Most of it looks like tishware. NCD printing * is from Network Computing Devices. * * History: * -------- * * Programmer: Jeff Martin * Date: 06-Sept-1999 * Modification: Instrumented 'attached printing' events * enabled via primitive command 'DEBUG' * or local exceptions. * * Programmer: Jeff Martin * Date: 19-Aug-1999 * Modification: The string returned in response to * primitive command 'DATEC' is defined * near the top of this module. * Typically, clients can exercise primitive * commands by proceeding them with '???'. * and then entering them with the other * enter key. Then the command is interpreted * and not forwarded. * * * Programmer: Jeff Martin * Date: 15-Mar-1999 * Modification: Ported to Alpha/unix: * Added automatic identification for RCS vice sccs. * * changed static int *savptr * to static unsigned char *savptr * * changed static signed char *array * to static unsigned char *array * * changed char *ptr * to unsigned char *ptr in HPInitialise. * * changed char *buffloc * to unsigned char *buffloc in send_packet. * * changed static char *num_str * to static unsigned char *num_str in getnx_fld. * * changed char *str1, *ptr * to unsigned *str1, *ptr in fkey_string. * * got rid of forward declarations for * HPTermInput, OutputHPMsg, now ANSI C. * $Log$ * ****************************************************************/ static char rcsid[] = "$Id$"; #include "gateway.h" #include "ascii.h" #include "telnetd.h" #include #define DATEC "\nhpterm.c compiled 06-Sep-1999" #define IAC 0xff #define maxinput 2000 #define WIDTH 80 /* ====================================================================== */ char candemsg=0; static int Hostflag; static int xprinterstatus=0; static char rdyprt; static char page2; static char PC_print; static char show_pg2data; static char new_pg_row; static char pagecnt; static char NoPrinter; static char prt_tog; static char Block_sw; static int pg2textsz; static int pos; static int cmd_stk_cnt; /* primitive commands */ static char cmd_mode,precmd; /* ??? */ static char dontdisplay; static char showlabels; static unsigned char Hold[2000]; static unsigned char svtext[2000]; static unsigned char HoldAttr[maxinput]; static unsigned char FkeyScreen[maxinput]; static unsigned char FkeyAttr[maxinput]; static unsigned char fkey_form[18*8]; /* fkey default form */ static unsigned char fkey_data[80*8]; /* fkey data */ static unsigned char cmd_stack[10]; static int options[9]; static unsigned char savelabel[9]; static unsigned char esc_stack[120]; static unsigned char fkey_label[9*8]; static unsigned char BUFF0[maxinput]; static unsigned char array[2000]; static unsigned char outbuff[maxinput]; #define row nRow #define col nCol #define rowcol nCurPos #define lastrow 23 #define PAGESZ 2000 #define left -1 #define minrow 0 #define maxrow 75 #define num_chek(x) (( x > '/' && x < ':') || x == '+' || x == '-') #define alpha 0 #define num 1 #define sign 2 #define lf 0x0a #define local 0x4c #define transmit 0x54 #define null 0x00 #define bel 0x07 #define VT 0x0b #define SI 0x0f #define DC2 0x12 #define cmp_print 0x1d #define norm_print 0x1e #define space 0x20 #define normal 0x00 #define cursor_lf 0x4b #define cursor_rt 0x4d #define cursor_up 0x48 #define page_up 0x49 #define cursor_dn 0x50 #define page_dn 0x51 #define cursor_home 0x47 #define back_sp 0x08 #define cr 0x0d #define erase 0x4f #define spec_char 0x1f #define exec 0xe0 #define insert 0x52 #define delete 0x53 #define prev 0x51 #define next 0x49 #define sh_exec 0xd5 #define sh_insert 0xd6 #define sh_delete 0x2e #define sh_prev 0xd8 #define sh_next 0xd9 #define alt_plus 0x83 #define enter 0x2b /* scan code 4e */ #define esc 0x1b /* scan code 01 */ #define rs 0x1e /* field separator */ #define UnderScore 0x5f #define tab 0x09 #define backtab 0x0f #define sh_tab 0xdc #define sh_backtab 0xdd #define fkey_1 0x3b #define fkey_2 0x3c #define fkey_3 0x3d #define fkey_4 0x3e #define fkey_5 0x3f #define fkey_6 0x40 #define fkey_7 0x41 #define fkey_8 0x42 #define fkey_9 0x43 #define fkey_10 0x44 #define sh_fkey_1 0x54 #define sh_fkey_2 0x55 #define sh_fkey_3 0x56 #define sh_fkey_4 0x57 #define sh_fkey_5 0x58 #define sh_fkey_6 0x59 #define sh_fkey_7 0x5a #define sh_fkey_8 0x5b #define sh_fkey_9 0x5c #define sh_fkey_10 0x5d #define alt_fkey_1 0x68 #define alt_fkey_2 0x69 #define alt_fkey_3 0x6a #define alt_fkey_4 0x6b #define alt_fkey_5 0x6c #define alt_fkey_6 0x6d #define alt_fkey_7 0x6e #define alt_fkey_8 0x6f #define alt_fkey_9 0x70 #define alt_fkey-10 0x71 #define command 0x44 #define vtfind 0 #define vtfkey1 0 #define vtfkey2 1 #define vtfkey3 2 #define vtfkey4 3 #define vtfkey5 4 #define vtfkey6 5 #define vtfkey7 6 #define vtfkey8 7 #define vtfkey9 8 #define vtfkey10 9 #define vtfkey11 10 #define vtfkey15 14 #define vtfkey16 15 #define vtfkey17 16 #define vtfkey20 19 #define vtremove 3 #define PC 0x01 #define HP 0x02 /* same definition as E80term.c */ #define Xterm 0x04 #define vt420 0x80 #define PC_TERM (nTermType & PC) #define XTERM (nTermType & Xterm) /* ************************** video attribute ****************** */ #define blink 0x02 /* blink */ #define revvideo 0x01 /* inverse video */ #define security 0x0a /* don't display char */ #define bold 0x08 /* bold */ #define overscore 0x00 /* no attribute */ #define underscore 0x10 /* */ #define superscript 0x00 /* no attribute */ #define subscript 0x00 #define half_bright 0x00 /* ************************** printer status's *********************** */ #define noprinter '3' #define prtready '0' #define prtnotrdy '1' #define prtbusy '8' #define prtnotassign '9' /* ****************************************************************** */ #define hp_set_tab '1' #define hp_clear_tab '2' #define hp_clr_alltabs '3' #define hp_set_lfmargin '4' #define hp_set_rtmargin '5' #define hp_define_alpha '6' #define hp_define_numeric '7' #define hp_define_unres '8' #define hp_clr_margin '9' #define hp_delay_sec '@' #define hp_cursor_up 'A' #define hp_cursor_dn 'B' #define hp_cursor_rt 'C' #define hp_cursor_lf 'D' #define hp_hard_reset 'E' #define hp_home_dn 'F' #define hp_move_lf_margin 'G' #define hp_cursor_home 'H' #define hp_horz_tab 'I' #define hp_erase 'J' #define hp_clear_ln 'K' #define hp_insert_ln 'L' #define hp_delete_ln 'M' #define hp_delete_char 'P' #define hp_insert 'Q' #define hp_end_insert 'R' #define hp_roll_up 'S' #define hp_roll_dn 'T' #define hp_next_pg 'U' #define hp_prev_pg 'V' #define hp_form_on 'W' #define hp_form_off 'X' #define hp_disp_func_on 'Y' #define hp_disp_func_off 'Z' #define hp_start_unprot '[' #define hp_end_unprot ']' #define hp_primary_status '^' #define hp_soe '_' #define hp_rel_cursor_addr 0x60 #define hp_abs_cursor_addr 'a' #define hp_unlock_kb 'b' #define hp_lock_kb 'c' #define hp_transmit_blk 'd' #define hp_modem_disconnect 'f' #define hp_soft_reset 'g' #define hp_cursor_hm 'h' #define hp_backtab 'i' #define hp_begin_userkey 'j' #define hp_end_userkey 'k' #define hp_begin_memlock 'l' #define hp_end_memlock 'm' #define hp_dcomm_test 'x' #define hp_term_test 'z' #define hp_start_xmitonly '{' #define hp_erase_soe '|' #define hp_sec_status '~' #define hp_esc_ext '&' /* ********************* EXTENDED ESC FUNCTIONS ***************** */ #define cursor_control 'a' #define config_term1 'k' #define config_term2 's' #define config_menu1 'q' #define config_menu2 'w' #define data_oper 'p' #define format_mode 'e' #define func_label 'j' #define func_load 'f' #define disp_enhance 'd' #define PF_KEYS 'O' #define PF1 'P' #define PF2 'Q' #define PF3 'R' #define PF4 'S' #define FK5 'p' #define FK6 'q' #define FK7 'r' #define FK8 's' #define FK9 't' #define FK10 'u' #define FK11 'v' #define FK12 'w' #define CSI '[' /* ******************** CONFIGURATION DEFINE ******************** */ #define autolf 'A' #define block 'B' #define caps_lock 'C' #define bell 'D' #define ascii8bit 'I' #define localecho 'L' #define modifyall 'M' #define caps_mode 'P' #define click 'Q' #define remote 'R' /* ******************** ATTRIBUTE VALUES ********************* */ #define ATT_REVERSE 0x01 /* reverse video */ #define ATT_BLINK 0x02 /* blinking video */ #define ATT_XMIT 0x04 /* transmittable */ #define ATT_SOE_BIT 0x08 /* Soe indicator */ #define ATT_SECURE 0x0a /* secured video */ #define ATT_UNDER 0x10 /* underline video */ #define ATT_XMITONLY 0x20 /* transmit only field */ #define ATT_BLOCK 0x40 /* block mode delimiter */ #define ATT_SPEC 0x80 /* attribute specified */ #define ATT_XSTART 0x84 /* start of xmit fld */ #define ATT_ENDFLD 0x40 /* end of xmit fld */ #define ATT_MASK 0x1f /* video attr mask */ #define BitsOn(v,m) (((v)&(m)) == (m)) #define soe_bit 0x08 #define numeric_fld 0x10 #define end_fld 0x20 #define end_ln 0x40 #define alpha_fld 0x80 /* ************************************************************************ */ #define true -1 #define false 0 #define left -1 #define right 0 #define minrow 0 #define dn -1 #define up 0 #define lastln 24 /* last crt line relative 0 */ /* ====================================================================== */ int rscnt; static unsigned char togs; static int xmit_rd; static int last_ptr,nPrint_cnt; static int i; static int d; static int k; static int topln; static int bottomln; static int loc; static int startloc; static int saveloc; static int startdpy; static int enddpy; static int save_row; static int save_col; static int save_nCurPos; static int start_col; static int prev_ROW; static int left_margin; static int right_margin; static int stack_loc; static int num_val; static int kind; static int fkey_type; static int label_sz; static int str_sz; static int keyno; static int string_sz; static int prt_cnt; static int attr_cnt; static int time_now; static int time_last; static int dup_cnt; static unsigned char *stack_ptr; static unsigned char char_attr; static unsigned char prev_attr; static unsigned char normal_attr; static unsigned char prev_char; static unsigned char kb_prev_char; static char fkeydata; char debug; char debug2; char insert_mode; /* ******************** B 0 0 L E A N S *************************** */ static char soe_present; static char special; char fkey_mode; char candeSEQmode; static char esc_mode; static char kb_esc_command; static char esc_ext; static char display_func; static char key_lock; static bPrint_command; static char unprotect; /* if true set unprotect bit on */ static char xmitonly; /* if true set transmit bit on */ static char fld_type; /* alpha or numeric */ static char block_mode; static char save_flag; static char endfld_flag; char unsolmsg; static char unsolprt; static unsigned char *BUF_PTR; char FORMS_MODE; /* USE IN ASSEMBLER FUNCTION */ char IAC_cnt; char IAC_data; static char kb; static char crypt_ch; /* encrypted char */ static char end_form; /* if true-cursor is sitting nx to*/ /* last field - rdy to send data */ /* static int *savptr; */ static unsigned char *savptr; static char bWaitforprinter; static char bWaitprintend; static char bPrtok; static int FkeyLine; static int sv_Textsz; static int ignorefkey1_3=0; int nFormfield_cnt; int nTermType; int OPA=0; int startdata; int beepcnt; /* *************************************************************** */ extern int bPageMode; extern int bInsertMode; extern int bUpdateVideo; extern int nRow; extern int nCol; extern int nCurPos; extern int SendBufferLen; extern int bDecrypt; extern int bEncrypt; extern int Alton; extern char printer_open; extern unsigned char *ScreenData; extern unsigned char *ScreenAttr; extern unsigned char *pOut; extern unsigned char OutBuffer[]; extern unsigned char termname[]; extern unsigned char hostip[]; /* ******************************************************************* */ #define WriteESC() \ { \ *pOut++ = ASCII_ESC; \ } #define WriteCSI(ch) \ { \ WriteESC(); \ *pOut++ = ANSI_CSI; \ if (ch != 0) \ *pOut++ = ch; \ } /* ****************************************************************** */ char sDefaultFkey[]={0x7e,0x70,0x7e,0x71,0x7e,0x72,0x7e,0x73,0x7e,0x74,0x7e, 0x75,0x7e,0x76,0x7e,0x77}; /* forward function declarations */ static void HPTermInput(char ch); static void OutputHPMsg(int nText,char *pTest,int sz,unsigned char toggles, unsigned char tally[3]); #if defined (__STDC__) static void set_attributes(int row_col,char attr,char on); static void TermHpInput(char c); void HPInitialise(void); static void HPTimeout(void); static void submain(void); static void stuff_cmd(char ch); static void execute_cmd(void); static void NetMsg(char *array,int sizze); static void display(unsigned c,int kb); static void cursor(void); static int get_pos(void); static void do_sp_char(unsigned c,int kb); static void home_it(void); static void clear_term(void); static void update_col(int direction); static void send_packet(char *buffloc,int offset,int sz,char bPrtdevice); void send_forms_packet(int offset,int sz); static void scroll(int dir); static void displayln(unsigned rownum,unsigned framerow); static void storeln(unsigned framerow,unsigned rownum); static void moveln(int direction,int startln,int endln); void insert_sp(char *ptr,int cnt); static void delete_char(char *ptr,int cnt); static void do_escfunc(char c); static void do_escext(char c); static int getnx_fld(void); static void Print_page2(); static void attributes(int row_col,char attr,char on); static void set_screenattributes(void); static int go_nx_attributes(char attr,char dir); int find_soe(char thisline); void dump(char *ptr,int sz); void do_fkey(unsigned c); static void pokeb(char *ptr,int offset,char d); void show_fkeylabels(void); static void fkey_skeleton(void); static void fkey_display(void); static void fkey_input(unsigned c); static void fkey_string(void); static void print_screen(void); static void show_statusind(char fkey); static void createfkey_screen(void); void VtEsc_Func(char *ptr); void restore_statusln(key); static void Beep(void); void passthruprint(int nText,char *msg); void Scrollup(void); /* ********************************************************************** */ #else static void set_attributes(); static void TermHpInput(); void HPInitialise(); static void HPTimeout(); static void submain(); static void stuff_cmd(); static void execute_cmd(); static void NetMsg(); static void display(); static void cursor(); static int get_pos(); static void do_sp_char(); static void home_it(); static void clear_term(); static void update_col(); static void send_packet(); void send_forms_packet(); static void scroll(); static void displayln(); static void storeln(); static void moveln(); void insert_sp(); static void delete_char(); static void do_escfunc(); static void do_escext(); static int getnx_fld(); static void Print_page2(); static void set_attributes(); static void set_screenattributes(); static int go_nx_attributes(); int find_soe(); void dump(); void do_fkey(); static void pokeb(); void show_fkeylabels(); static void fkey_skeleton(); static void fkey_display(); static void fkey_input(); static void fkey_string(); static void print_screen(); static void createfkey_screen(); void VtEsc_Func(); void restore_statusln(); static void show_statusind(); void Beep(); void passthruprint(); void Scrollup(); #endif extern char **environ; /* ******************************************************************* */ #if defined (__STDC__) void HPInitialise(void) #else void HPInitialise() #endif { unsigned char *pOut; unsigned char *ptr; extern char **environ; int i; unsigned char *pt1,*pt2; debug=false; Hostflag=1; savptr=outbuff; prt_cnt=0; dup_cnt=0; FkeyLine=80; /* set this to 0 for vt200 */ Block_sw=1; /* 1=open or off 0=on */ PC_print=false; cmd_stk_cnt=0; cmd_mode=false; startdata=0; ptr=termname; /* ********* DEFAULT terminal type is vtHP -- if you add new terminal ********* type you may need to change terminal keymap in "E80TERM.c" . */ syslog(LOG_INFO,"hpterm.HPInitialise: termname is %s",termname); if (*ptr==null) bcopy("vtHP.",ptr,5); nTermType = HP; /* HP */ if ((strcmp(termname,"network")==0) || (strcmp(termname,"vt-220")==0)) nTermType=nTermType | PC; else if ((strcmp(termname,"vt420")==0) || (strcmp(termname,"VT420")==0)) { nTermType = HP; ignorefkey1_3=true; /* OPA terminal type */ } else if ((strcmp(termname,"vt102")==0) || (strcmp(termname,"dec-vt220")==0)) { nTermType=nTermType | PC; } else if (strcmp(termname,"xterm")==0) { nTermType=nTermType | Xterm; } else if (strcmp(termname,"xterms")==0) { nTermType=nTermType | Xterm; } syslog(LOG_INFO,"termnm=%s termtype=%d\n",ptr,nTermType); /* submain(); */ if (!PC_TERM) /* set numeric keypad -- application */ { pOut=array; *pOut++ = esc; if (strcmp(termname,"vt420")==0) *pOut++ = '>'; else *pOut++ = '='; *pOut++ = esc; *pOut++ = '['; *pOut++ = '2'; *pOut++ = '$'; *pOut++ = '~'; *pOut++ = esc; *pOut++ = '['; *pOut++ = '?'; *pOut++ = '8'; *pOut++ = 'h'; NetWrite(array,12); } E80Initialise(); submain(); TermInput = HPTermInput; OutputMsg = OutputHPMsg; TimeOut = HPTimeout; SetTimeOut(0L,0L); show_fkeylabels(); } /* ********************************************************************** */ static void HPTermInput(char ch) { if (debug)printf("ch=%x row=%d col=%d startdata=%d\n",ch,row,col,startdata); if (ch==0x60) if (OPA) { ch='@'; } if (ch==0x7f) ch=ASCII_BS; if (ch=='?') { if (kb_prev_char=='?') {cmd_mode=true; cmd_stk_cnt=0;} } kb_prev_char=ch; if (cmd_mode) { if (ch==cr) { execute_cmd(); return; } stuff_cmd(ch); } if ((ch==esc) && (fkey_mode)) { esc_mode=true; kb_esc_command = true; esc_ext = false; return; } if ((esc_mode) && (!kb_esc_command)) { esc_mode=false; esc_ext =false; } if (esc_mode) { if (bDecrypt) ch = Decrypt(ch); kb=true; do_escfunc(ch); kb=false; return; } if (fkey_mode) { if (bDecrypt) ch = Decrypt(ch); display(ch,true); return; } E80TermInput(ch); } /* ****************************************************************** */ #if defined(__STDC__) static void stuff_cmd(char ch) #else static void stuff_cmd(ch) char ch; #endif { unsigned char *ptr; if ((cmd_stk_cnt==0) && (ch=='?'))return; *(ptr = &cmd_stack[cmd_stk_cnt++]) = ch; ptr=ptr+1; *ptr=null; } /* ******************************************************************* */ #if defined(__STDC__) static void execute_cmd(void) #else static void execute_cmd() #endif { unsigned char *ptr; int sizze; if (debug)dump(cmd_stack,cmd_stk_cnt); ptr=termname; if (strcmp(cmd_stack,"TERM")==0) { sprintf(array,"\ntermname = %5s termtype = %x\n",ptr,nTermType); } else if (strcmp(cmd_stack,"DEBUG")==0) { Beep();Beep(); if (debug){debug=false; sprintf(array,"\nDEBUG is off");} else {debug=true; sprintf(array,"\nDEBUG is on ");} } else if (strcmp(cmd_stack,"DATEC")==0) { sprintf(array,DATEC); } else if (strcmp(cmd_stack,"STATUS")==0) { sprintf(array,"\nHostEnabled = %d Printer status =%d dup_cnt=%d\n", Hostflag,bWaitforprinter,dup_cnt); } else if (strcmp(cmd_stack,"RESET")==0) { EnableHost(); /* patched 7/7/92 */ Hostflag=1; sprintf(array,"\nHost Enabled\n"); } else if (strcmp(cmd_stack,"OPA")==0) { OPA=true; ignorefkey1_3=true; /* OPA terminal type */ sprintf(array," Key ~ = @ -- DUP\n"); } else if (strcmp(cmd_stack,"CREDIT")==0) { /* provide the ability for maintenance programmers to contact me (or whoever you want here) */ sprintf(array,"\nTSO, UW-MCIS. 221-4589 \n"); } else sprintf(array, "\n-- Invalid Primitive Command\n"); NetMsg(array,strlen(array)); cmd_stk_cnt=0; cmd_mode=false; UpdateDisplay(); } /* ****************************************************************** */ #if defined(__STDC__) static void NetMsg(char *array,int sizze) #else static void NetMsg(array,sizze) unsigned char *array; int sizze; #endif; { int i; if (bEncrypt) { if (debug)dump(array,sizze); bcopy(array,Hold,sizze); EncryptOutput(Hold,sizze); NetWrite(Hold,sizze); } else NetWrite(array,sizze); } /* ****************************************************************** */ #if defined(__STDC__) static void Beep(void) #else static void Beep() #endif { array[0]=bel; NetWrite(array,1); } /* ****************************************************************** */ #if defined (__STDC__) static void HPTimeout(void) #else static void HPTimeout() #endif { if (unsolmsg) { Beep(); return; } if (bWaitprintend) { if (debug) printf("TIMEOUT\n"); print_screen(); /* chk if printer is done */ return; } SetTimeOut(0L,0L); } /* ****************************************************************** */ #if defined (__STDC__) static void submain(void) #else static void submain() #endif { unsigned c, i; cursor(); char_attr = normal; NoPrinter = false; left_margin=0; right_margin=79; fkeydata=false; kb_esc_command=false; label_sz=str_sz=0; unprotect=xmitonly=block_mode=0; prev_char=null; kb_prev_char=space; bottomln=24;topln=0;row=0;col=0; clear_term(); fkey_skeleton(); show_fkeylabels(); } /* ******************************************************************* */ static void OutputHPMsg(int nText,char *pText,int Flags, unsigned char toggles,unsigned char tally[3]) { static int i; int c; static int msgcntr; int textsz; #define printcommand 0x80 #define passthru 0x04 #define MCS 0x10 #define candeseqmode 0x01 #define securebit 0x02 #define strangerbit 0x02 unsigned char *pOut; togs = toggles; enddpy=0; /* patched 7/28/91 */ saveloc=0; beepcnt=0; if (nText==0) return; /* toggles is defined in telnetd.telnet and is copied from incoming msg->msg.info2. msg format is defined in msg.h. bit 2 (0x04, passthru) and bit 7 (0x80, printcommand) are set in the A-Series application - Jeff */ /* force printcommand processing for each message - Jeff toggles += 0x114; */ if (debug) syslog(LOG_INFO,"hpterm: toggles: %d",toggles); if (debug) dump(pText,nText); if (!(toggles & MCS)) { candemsg=true; } else candemsg=false; if (candemsg) { if (toggles & candeseqmode) candeSEQmode=true; else candeSEQmode=false; if (toggles & securebit) dontdisplay=true; else dontdisplay=false; } if ((toggles & passthru)) /* && !candemsg) patch 9/19/5 */ { if (debug) syslog(LOG_INFO,"hpterm: got passthru command"); if (PC_TERM) {PC_print=bPrtok=true;} if (NoPrinter) toggles=toggles & 0x6f; else /*turn off prt bits. clear 0x90, preserve all others - Jeff */ { if (debug) syslog(LOG_INFO,"hpterm: calling passthruprint()"); passthruprint(nText,pText); return; } } /* attached/slave printer */ if ((toggles & printcommand) && !candemsg) { if (debug) syslog(LOG_INFO,"hpterm: got printcommand"); if (PC_TERM) { if (debug)printf("set PC print command\n"); PC_print=true; bPrtok=true; /* patch 8/8/91 */ prt_tog=true; } else if (!NoPrinter) prt_tog = true; } if (!candemsg) /* check toggles.bit6, if set message type is "unsolicited" -jeff */ if (toggles & 0x40) { if (debug)printf("unsolmsg \n"); DisableHost(); Hostflag=0; unsolmsg=true; sv_Textsz=nText; bcopy(pText,BUFF0,nText); Beep(); SetTimeOut(2L,2L); show_statusind(6); /* fkey7 */ if (toggles & 0x80) unsolprt = true; return; } if (fkey_mode) fkey_display(); /* reload main screen */ prev_ROW = nRow; /* 5/22/91 */ /* if (candeSEQmode)if (row>22){row=23;nCurPos=80*row;Scrollup();} */ for (i=0;i23) /* was 22 */ { page2=true; i++; } if (prt_tog && page2) { if (nRow>22) pos =0; pagecnt=1; pg2textsz=nText-i; if (pg2textsz>0) bcopy(&pText[i],svtext,pg2textsz); else page2=false; if (debug){printf("More pages-- page2=%d remainder=%d\n",page2,pg2textsz); /* dump(svtext,pg2textsz); */ } break; } } if (candemsg) { if (!(toggles & candeseqmode)) /* patched 11/20/91 */ { if (nRow>23) {Scrollup(); nRow=23;} if (nFormfield_cnt==0) { display(c=cr,false); if (debug)printf("cande-send cr row=%d rowcol=%d\n",row,rowcol); } } } if (bUpdateVideo) RegenerateDisplay(); UpdateDisplay(); if (candemsg) { if (toggles & candeseqmode)startdata=nCurPos; else startdata=nCurPos-nCol; } else startdata=nCurPos; /* if (!candemsg) if (PC_print) { PC_print=false; pOut=array; *pOut++=esc; *pOut++='['; *pOut++='0'; *pOut++='i'; if (debug)dump(array,4); NetMsg(array,4); return; } */ if ((toggles & MCS) && (toggles & strangerbit)) /* patch 10/25/93 */ { sprintf(array,"\nYou have an existing connection.\n"); NetMsg(array,sizeof(array)); if (!debug) { sleep(5); cleanup(); exit(1); } } /* patched 9/19/95 if (!candemsg) */ /* check toggles.bit7 */ if (toggles & printcommand) { if (debug) syslog(LOG_INFO,"hpterm: got printcommand..."); if (NoPrinter) return; if (debug) syslog(LOG_INFO,"hpterm: calling print_screen()"); print_screen(); if (!XTERM) show_statusind(7); } } /* ******************************************************************* */ #if defined (__STDFC__) static void display(unsigned c,int kb) #else static void display(c,kb) unsigned c; int kb; #endif { int i; unsigned x; unsigned char *ptr; static unsigned char prev_ch; char y; char lffound; char pchar; /* if (c==0x7f || c == null) return; patch 10/10/92 */ if (c==0x7f) c=space; /* patch 10/12/92 */ if (c==null) return; if (c==0x1b) pchar='~'; /* debug */ else /* debug */ if (c<0x20) pchar='?'; else pchar=c; /* debug */ if (fkeydata) /* process fkey string data */ { if (string_sz > 0 ) { if (debug) printf("fkey-c=%x\n",c); if (c==esc) c = '~'; *(ptr=esc_stack+(stack_loc++)) = c; string_sz--; if (string_sz==0) {fkey_string(); if (debug) dump(esc_stack,20);} return; } } if (bPrint_command) /* inbedded print command */ if (nPrint_cnt > 0) { if (c==esc) { if (prt_cnt > 0) goto prt_it; else goto contchk; } *(ptr =array+(prt_cnt++)) = c; nPrint_cnt--; if (c == cr) prt_it: { if (debug) { printf("print inbedded msg\n"); dump(array,prt_cnt); } lffound=false; for(i=0;i0) { IAC_cnt++; if (IAC_cnt >2) IAC_cnt=0; return; } if (c==esc) { if (bWaitforprinter) { bWaitprintend=false; bWaitforprinter=false; /* user canceled print */ return; } esc_mode=true; kb_esc_command = false; esc_ext=false; return; } if (esc_mode) {do_escfunc(c); return;} /* esc processing */ if (kb && key_lock) return; if (c==bel) {Beep(); return;} if (c==back_sp || c==cr || c==tab) {do_sp_char(c,kb);} if (c==lf) { if (prev_char==cr) { prev_char=c;return;} prev_char=c; if (row < lastrow) row++; else if (prt_tog) {page2=true;return;} else row=0; cursor(); return; } if (bPageMode) { go_nx_attribute(rowcol,ATT_XMIT,true); if (fld_type > 0) /* patched 6/20 */ if (fld_type == alpha_fld) { if (c < 'A' || c > 'z') { ding: /* delay(0);sound(440);delay(100); nosound(); */ return; } } else /* fld_type numeric */ if (c < '0' || c > '9') goto ding; } if (!kb) { if (char_attr && 0x03) if (attr_cnt > 79) { attr_cnt=0; char_attr = char_attr & 0xfc; } else if ((ScreenAttr[nCurPos+1] && 0x03)) { attr_cnt=0; char_attr = char_attr & 0xfc; } else attr_cnt++; ScreenAttr[nCurPos] = ScreenAttr[nCurPos] | char_attr; /* if (page2 && show_pg2data){home_it();clear_term(); show_pg2data=false;} */ DCProcessChar(c); prev_char=c; } else { if (page2) return; DisplayChar(c); if (end_form) { end_form = false; cursor(); } } } /* ******************************************************************** */ #if defined (__STDC__) static void display_char(unsigned c) #else static void display_char(c) unsigned c; #endif { unsigned char *p1; register int i = nCurPos; prev_char=c; loc=get_pos(); p1 = &ScreenData[loc]; if (end_form) { end_form = false; /* indicates cursor is out of form */ cursor(); /* put cursor in first form fld */ } *p1++ = c; if (col > right_margin) { scroll(dn); col=left_margin; start_col=left_margin; /* patched 6/15 */ } IncrCursor(false); } /* ******************************************************************** */ #if defined (__STDC__) static void cursor(void) #else static void cursor() #endif { int cursor_pos; if (bPageMode) { if (!(*(&ScreenAttr[rowcol]) & ATT_XMIT)) go_nx_attribute(ATT_XMIT,true); /* find nx unprot fld */ } cursor_pos=(80 * row) + col; rowcol = (80 * row) + col; if (fkey_mode) { pOut=array; Position(rowcol); NetWrite(array,8); } } /* ********************************************************************* */ #if defined (__STDC__) static int get_pos(void) #else static int get_pos() #endif { unsigned loc; if (col > right_margin) { col=left_margin; scroll(dn); } loc = ((80 * row) + col++); return(loc); } /* ******************************************************************** */ #if defined (__STDC__) static void do_sp_char(unsigned c,int kb) #else static void do_sp_char(c,kb) unsigned c; int kb; #endif { unsigned char *ptr; int k,i; special=false; switch (c) { case cursor_lf:update_col(left); break; case cursor_rt:update_col(right);break; case back_sp :update_col(left); break; case cursor_up:Scrollup() ;break; case cursor_dn:scroll(dn);break; case cursor_home: home_it();break; case erase: clear_term();break; case exec: sendit: { if (fkey_mode) break; if ((!block_mode) && (!bPageMode)) { i=col; if (soe_present) col = find_soe(true); i = i-start_col; k = (row*80)+start_col; cursor(); /* send_packet(video_base,k,i,0); */ col=left_margin; scroll(dn); break; } startloc = find_soe(false); i=(rowcol - startloc)+1; /* send_forms_packet(startloc,i); */ startloc=0; /* patched 7/1/91 */ break; } case cr: if (kb) { if (fkey_mode) {fkey_input(c);break;} goto sendit; } else { char_attr = normal; prev_char = cr; if (candemsg && (col==left_margin)) return; /* patched 2/16/94 */ col=left_margin; if (debug)printf("char cr row=%d\n",row); if (row11 && col<28)); else { if (col<3) col=3;else if (col==3)col=12; else {row++;col=0;} cursor();return; } } if (!fkey_mode) storeln(row,topln+row); /* patched 6/14 ln may not be stored */ if (direction==left) /* cursor left */ { if (fkey_mode && !(row & 0x0001)) if (col<13 || col<4) {col=3;cursor();return;} if (col>left_margin) col--; else if (row>minrow){ row--; col=right_margin;} else {row=lastrow;col=right_margin;} } else if (col col) start_col=left_margin; /* patched 6/15 */ } /* ******************************************************************** */ #if defined (__STDC__) static void send_packet(char *buffloc,int offset,int sz,char bPrtdevice) #else static void send_packet(buffloc,offset,sz,bPrtdevice) unsigned char *buffloc; int offset,sz; char bPrtdevice; #endif { int i; unsigned char *ptr; unsigned char *ptr1; ptr = buffloc + offset; ptr1 = outbuff; /* packet output buffer */ for (i=sz;i>0;i--) { *ptr1 = *ptr; /* move data from screen buf */ ptr++; ptr1++; } *ptr1 = cr; NetWrite(outbuff,sz+1); } /* ********************************************************************* */ #if defined (__STDC) void send_forms_packet(int offset,int sz) #else void send_forms_packet(offset,sz) int offset,sz; #endif { static unsigned char *p_in; static char attr; static unsigned char *p_out; static int outcnt; static unsigned char *p_attr; static int i; static int nRs_cnt; nRs_cnt=0; outcnt = 0; if (beepcnt>5) return; /* don't transmit */ p_out = outbuff; if (Block_sw==0) sz=2000-offset; if (candemsg && bPageMode) sz=2000-offset; /* patch 3/18/93 */ if (sz>2000) return; /* patch 2/18/92 */ attr = ATT_XMITONLY | ATT_XMIT | ATT_ENDFLD; for (i=0;i< sz-1;i++) { p_attr = &ScreenAttr[offset+i]; if ((*p_attr & attr) > 0) { p_in = &ScreenData[offset+i]; *p_out = *p_in; outcnt=outcnt+1; p_out=p_out+1; if (BitsOn(*p_attr,ATT_ENDFLD) > 0) { if (nRs_cnt+1 < nFormfield_cnt) { *p_out = rs; outcnt=outcnt+1; /* send end of field mk */ nRs_cnt=nRs_cnt+1; /* cnt # of fields */ p_out++; } } } } if (outcnt == 0) { outcnt++; *p_out = rs; nRs_cnt++; p_out++; } else { outcnt++; *p_out = cr; } if (debug ) { printf("offset=%d\n",offset); printf("outcnt=%d nRs-cnt=%d nFormfieldcnt=%d\n",outcnt,nRs_cnt,nFormfield_cnt); printf("TRANSMIT-DATA (BELOW) rowcol=%d\n",rowcol); dump(ScreenData,1000); dump(outbuff,outcnt); } time_now=time(0); if (time_now>time_last+1) time_last=time_now;else { dup_cnt++; home_it(); return; } if (savptr != &outbuff[0]) { syslog(LOG_INFO,"hpterm.send_forms_packet: savptr != &outbuff[0]"); syslog(LOG_INFO,"outbuff-ptr=%x org-addr=%x\n",&outbuff[0], savptr); cleanup(); abort(); } SendBlock(outbuff,outcnt); home_it(); if (beepcnt>1) Beep(); beepcnt++; } /* ******************************************************************** */ #if defined (__STDC) static void scroll(int dir) #else static void scroll(dir) int dir; #endif { int startln,endln,row_num; char_attr = normal; start_col=left_margin; if (dir==dn) { if (row==lastrow) { if (bPageMode) return; /* patched 6/21 */ printf("(dn)col=%d row=%d botln=%d\n",col,row,bottomln); storeln(row, bottomln); /* store ln23 */ if (bottomln>maxrow-2) bottomln= -1; if (topln>maxrow-1) topln=0; { storeln(0,topln++); moveln(dir,1,24); displayln(++bottomln,lastrow); } } else { storeln(row,topln+row); if (debug2) printf("top ln=%x row=%x botln=%x\n",topln,row,bottomln); row++; char_attr=normal; /* don't line wrap char attr */ } } else /* must be roll screen up */ { if (fkey_mode) { if (row==0) return; else row--; cursor(); return; } if (row>0) { storeln(row,topln+row); /* patched 6/18 */ row--; char_attr=normal; } else { if (bPageMode) return; if (topln==0) topln=maxrow; { storeln(lastrow,bottomln--); if (bottomln==-1) bottomln=maxrow-1; moveln(dir,22,-1); /* moves ln-22 to ln-23, 21 to 22, etc */ displayln(--topln,0); } } } } /* ****************************************************************** */ #if defined (__STDC__) static void displayln(unsigned rownum,unsigned framerow) #else static void displayln(rownum,framerow) /* moves a line from hold area to screen */ unsigned rownum; unsigned framerow; #endif { UpdateRange(80*rownum,80); UpdateDisplay(); } /* ***************************************************************** */ #if defined (__STDC__) static void storeln(unsigned framerow,unsigned rownum) #else static void storeln(framerow,rownum) /* moves a line from screen to hold area */ unsigned framerow; unsigned rownum; #endif { unsigned char *ptr; ptr=ScreenData + (80 * rownum); /* addr of array slot. */ } /* ****************************************************************** */ #if defined (__STDC__) static void moveln(int direction,int startln,int endln) #else static void moveln(direction,startln,endln) int direction; int startln; int endln; #endif { int i, inc; if (direction) inc=1; else inc= -1; for (i=startln;i!=endln;i+=inc) bcopy(ScreenData[80*i],ScreenData[80*(i-inc)],80); } /* ****************************************************************** */ #if defined (_STDC__) void insert_sp(char *ptr,int cnt) #else void insert_sp(ptr,cnt) unsigned char *ptr; int cnt; #endif { unsigned char *ptr2; int i,sz; i=79; if (bPageMode) { sz=nCurPos; for (i=nCurPos;i0;i--) { *ptr2 = *(ptr2-1); ptr2--; } *ptr = space; /* insert sPace */ } /* *********************************************************************** */ #if defined (__STDC__) static void delete_char(char *ptr,int cnt) #else static void delete_char(ptr,cnt) unsigned char *ptr; int cnt; #endif { unsigned char *ptr2,*pt; int i; pt=ptr; ptr2 = ptr+1; for (i=cnt;i>0;i--) { *ptr = *ptr2; ptr++; ptr2++; } *(pt+cnt)=space; } /* ******************************************************************** */ #if defined (__STDC__) static void fkey_input(unsigned c) #else static void fkey_input(c) unsigned c; #endif { int i; unsigned char *ptr; char updatelabel; if (debug) printf("fk-ch=%x\n",c); if (c15) {row=0;col=3;home_it();} if (row & 0x0001) { if (col>79) return; ptr = &fkey_data[(row-(row/2)-1)*80+col]; *ptr=c; KbdProcessChar(c); /*E80TermInput(c); */ } else if (col>3 && col<29) { ptr = &fkey_label[((row-(row/2))*9) + col-12]; *ptr=c; KbdProcessChar(c); /*E80TermInput(c);*/ updatelabel=true; /* show_fkeylabels(); */ } else { if (col==3) { if (c==local || c== transmit) { ptr = &fkey_form[((row-(row/2))*18)+3]; *ptr=c; KbdProcessChar(c); } else return; } else return; } update: if (bUpdateVideo) RegenerateDisplay(); UpdateRange(row * 80,80); UpdateDisplay(); /* if (updatelabel) show_fkeylabels(); */ } /* ******************************************************************* */ #if defined (__STDC__) void do_fkey(unsigned c) #else void do_fkey(c) unsigned c; #endif { int j; unsigned char *pt,*ptr,*ptr2,ch; unsigned char *pOut; int key,k, i; static unsigned char sFkey[8]; special=false; if (c>341) key=c-341; else key = c-276; /* value of c comes from e80term */ if (debug) printf("fkey value =%d\n",key); switch (key) { case vtfkey1: case vtfkey2: case vtfkey3: if (ignorefkey1_3) return; /* OPA terminals */ case vtfkey4: case vtfkey5: case vtfkey6: goto ex_fkey; case vtfkey9: return; case vtfkey10: if (!XTERM) return; nRow=24; print_screen(); home_it(); return; case vtfkey15: fkey_display(); return; case vtfkey17: aliasF6: if (candemsg)return; sprintf(sFkey,"SAMEN"); SendBlock(sFkey,5); return; case vtfkey20: bPageMode=false; home_it();clear_term(); pOut=array; *pOut++ = esc; *pOut++ = '['; *pOut++ = '2'; *pOut++ = '0'; *pOut++ = 'l'; *pOut++ = esc; *pOut++ = '>'; NetWrite(array,7); if (candemsg) sprintf(array,"DISCONNECTED FROM CANDE"); else sprintf(array,"DISCONNECTED FROM MCIS "); NetWrite(array,23); sleep(2); if (dup_cnt>0) syslog(LOG_INFO,"hpterm: dup cnt = %d\n",dup_cnt); cleanup(); exit(1); case vtfkey11: if (PC_TERM) { /* if (debug) debug=false; else debug=true; */ showlabels=true; if (bPageMode) { pt = &ScreenAttr[1920]; for (i=0;i<80;i++) if (*(pt+i) > 0x02) showlabels=false; if (!showlabels) return; show_fkeylabels(); return; } show_fkeylabels(); return; } if (debug) { printf("**********FKEY11 DUMP************\n"); dump(ScreenData,2000); dump(ScreenAttr,2000); } return; case vtfkey7: if (unsolmsg) { unsolmsg=false; restore_statusln(vtfkey7); if (unsolprt) { unsolprt=false; print_screen(); } return; } if (candemsg)goto ex_fkey; /* patch 12/16/91 */ return; case vtfkey8: if (bWaitforprinter) { bWaitforprinter=false; bWaitprintend=false; bPrtok=false; restore_statusln(vtfkey8); if (Hostflag==0) { EnableHost(); Hostflag=1; } return; } if (candemsg)goto ex_fkey; /* patch 12/16/91 */ restore_statusln(vtfkey8); /* patched 8/14/91 */ return; default: return; } ex_fkey: ptr = &fkey_data[80 * key]; ptr2 = &fkey_form[18 * key]+3; pt=ptr+79; for (j=80;j>0;j--) /* blank suppression */ { if ((*pt == space) || (*pt == null)) pt--; else break; } if ((*ptr2)== transmit) { if (beepcnt>5) return; /* don't transmit */ if (strncmp(ptr,&sDefaultFkey[key*2],2)==0) { if (key==vtfkey5) { bPageMode=false; home_it(); clear_term(); SendBufferLen=0;return; } if ((key==vtfkey6) && (PC_TERM)) goto aliasF6; sprintf(sFkey,"$FUN%d",key+1); SendBlock(sFkey,5); if (beepcnt>1) Beep(); beepcnt++; return; } pt=array; for (i=0;i1) Beep(); beepcnt++; return; /* patch 8/20/92 */ } else { for (i=0;i'?') && ( c < scandelimiter) || c==esc || c=='~' || c == 'n') esc_ext=false; *(ptr = &esc_stack[stack_loc++]) = c; /* if (debug) printf("escext c=%x\n",c); */ if (stack_loc==2) if ((esc_stack[0]=='[') && (c > '@' && c < 'E')) /* up-dn-lf-rt */ esc_ext=false; if (!esc_ext) { if (debug) dump(esc_stack,stack_loc); limit=stack_loc; stack_loc=0; esc_mode = false; kb_esc_command = false; scan_done = false; stack_ptr = &esc_stack[0]; switch (*(stack_ptr++) & 0x00ff) { case cursor_control: { storeln(row,topln+row); parse_val=getnx_fld(); /* get col val */ /* if (debug) printf("val=%d kind=%x\n",parse_val,kind); */ if ((kind==sign) && (parse_val == '+')) Plus=true; if ((kind==sign) && (parse_val == '-')) Neg =true; if (Plus || Neg) parse_val=getnx_fld(); if (kind) /* plus-neg-num */ { inc_col=parse_val; parse_val=getnx_fld(); if (parse_val=='C') /* short col pos */ { if (Plus) inc_col=col+inc_col; if (Neg) inc_col=col-inc_col; col=inc_col; cursor(); break; } if (parse_val=='R') /* short row pos */ { if (Plus) inc_col=row+inc_col; if (Neg ) inc_col=row-inc_col; row=inc_col; cursor(); break; } if (parse_val=='S') /* go to nx soe +_ */ { /* printf("sval=%x\n",parse_val); */ go_nx_attribute(soe_bit, (inc_col>0)); cursor(); break; } if ((parse_val=='r') || (parse_val=='y')) /* normally col is first */ { rev=true; /* reversed cursor addressing */ if (Plus) inc_col=inc_col+row; if (Neg) inc_col=inc_col-row; inc_row=inc_col; } else { if (Plus)inc_col=inc_col+col; if (Neg) inc_col=inc_col-col; } Plus=Neg=false; parse_val=getnx_fld(); /* get nxt val */ /* if (debug) printf("rval=%d kind=%x\n",parse_val,kind); */ if ((kind==sign) && (parse_val=='+')) Plus =true; if ((kind==sign) && (parse_val=='-')) Neg =true; if (Plus || Neg) parse_val=getnx_fld(); /* if (debug)printf("kind=%x parse-val=%x\n",kind,parse_val); */ if (kind) { if (rev) { if (Plus) parse_val=parse_val+col; if (Neg) parse_val=parse_val-col; inc_col=parse_val; } else { /* if (debug)printf("parse_val=%d row=%d\n",parse_val,row); */ if (Plus) parse_val=parse_val+row; if (Neg) parse_val=parse_val-row; /* if (debug) printf("plus=%x neg=%x parse_val=%d\n",Plus,Neg, parse_val); */ inc_row=parse_val; /* if (debug) printf("parse_val=%d inc_row=%d\n",parse_val,inc_row); */ } /* if (debug)printf("parse next\n"); */ parse_val=getnx_fld(); /* if (debug)printf("Parse_val=%x\n",parse_val); */ if (parse_val=='Y') /* relative addressing */ { row=inc_row+row; col=inc_col+col; } else if (parse_val=='R' || parse_val=='C') { row=inc_row; col=inc_col; } cursor(); if (debug)printf("Row=%d Col=%d Rowcol=%d\n",row,col,rowcol); if ((startdpy>0) && (rowcol>startdpy)) enddpy=rowcol; /* patch 7/2/91 */ if (debug)printf("rowcol=%d startdpy=%d\n",rowcol,startdpy); /* patch 7/29 */ if (col>right_margin) col=right_margin; if (debug)printf("stloc=%d endloc=%d char_attr=%x\n",startdpy,enddpy,char_attr); if (((startdpy>0) && (enddpy>startdpy))&&(char_attr>normal)) { /* UpdateRange(startdpy,enddpy-startdpy+1); for (i=startdpy;ilastrow) row=lastrow; cursor(); break; } } break; } /* end of cursor control case */ case config_term1: { num_val=getnx_fld(); if (kind!=num)break; switch(parse_val=getnx_fld()) { case autolf: break; case block: if (num_val==0) block_mode=false; else if (num_val==1) block_mode=true; break; case caps_lock: break; case bell: break; case ascii8bit: break; case localecho: break; case modifyall: break; case caps_mode: break; case click: break; case remote: break; default:break; } } case config_term2 : for(;;) { num_val=getnx_fld(); if (kind!=num) break; parse_val=getnx_fld(); if (kind != alpha) break; if (parse_val=='j' || parse_val=='J') Block_sw = num_val; if (parse_val=='k' || parse_val=='K'); if (parse_val>'a') break; /* end of esc string */ } case config_menu1 : break; case config_menu2 : break; case data_oper : /* ~&pnW - send nx n char to all devices */ { /* ~&p3s4D - print from screen */ /* ~&pW - send 256 or to cr to printer */ /* ~&p4W - send 256 or until cr to prt */ num_val = getnx_fld(); /* 3 = device code */ if (kind != num) { parse_val = num_val; nPrint_cnt = 256; } else parse_val = getnx_fld(); if (kind != alpha) break; if (parse_val == 'd') parse_val = getnx_fld(); if (parse_val == 'W') /* short blast */ { nPrint_cnt = 256; bPrint_command = true; prt_cnt = 0; if (debug) printf("inbedded prt command\n"); break; } if (debug)printf("inbedded print commmand\n"); if (num_val != 3) break; if (parse_val != 's') break; /* input source */ parse_val = getnx_fld(); if (kind != num || parse_val != 4) break; /*printer device */ parse_val = getnx_fld(); if (kind != alpha || parse_val != 'D') break;/* to device code */ print_screen(); show_statusind(vtfkey8); break; } case format_mode : break; case func_label : break; case func_load : { label_sz=str_sz=0; for (;;) { num_val=getnx_fld(); if (debug) printf("num_val=%x\n",num_val); if (kind!=num) break; parse_val=getnx_fld(); if (kind!=alpha) break; if (parse_val<'a') { parse_val=parse_val + 32; /* convert to lower case */ scan_done=true; } /* if (debug) printf("parse_val=%x\n",parse_val); */ if (parse_val=='a') fkey_type=num_val; if (parse_val=='k') keyno = num_val; if (parse_val=='l') str_sz = num_val; if (parse_val=='d') label_sz= num_val; if (scan_done) break; } string_sz=label_sz + str_sz; if (string_sz > 0 ) fkeydata = true; if (debug2) printf("string_sz=%d\n",string_sz); stack_loc=0; break; } case disp_enhance :char_attr = normal; /* patched 5/31/91 */ if (debug2)printf("display enhance\n"); set_screenattributes(); break; case PF_KEYS : parse_val = getnx_fld(); if (fkey_mode && parse_val < FK11) break; switch(parse_val) { case PF1:do_fkey(276);break; case PF2:do_fkey(277);break; case PF3:do_fkey(278);break; case PF4:do_fkey(279);break; case FK5:do_fkey(276+4);break; case FK6:do_fkey(276+5);break; case FK7:do_fkey(276+6);break; case FK8:do_fkey(276+7);break; case FK9:do_fkey(276+8);break; case FK10:do_fkey(276+9);break; case FK11:do_fkey(276+10);break; case FK12:do_fkey(276+14);break; default :break; } case CSI: /* only if "fkey_mode=true */ num_val = getnx_fld(); if (debug) printf("CSI -- %x\n",num_val); /* if (kind == alpha) check vt type { if (num_val != '>') break; num_val = getnx_fld(); if (kind != num) break; if (num_val == 41) nTermType | vt420; if (debug)printf("term type = %x\n",nTermType); break; } */ if (num_val == 34) {do_fkey(295);break;} /* fkey20 */ if (num_val == 28) {do_fkey(290);break;} /* fkey15 */ if (num_val == 29) break; /* no xmit on fkey-screen */ parse_val=esc_stack[1]; if (debug) dump(esc_stack,6); if (parse_val == '?') { VtEsc_Func(esc_stack); return; } if (parse_val == 'A') k=0x101; else if (parse_val == 'B') k=0x102; else if (parse_val == 'C') k=0x104; else if (parse_val == 'D') k=0x103; else break; if (debug) printf("k=%x\n",k); if (debug)printf("ncurpos=%d\n",nCurPos); KbdProcessChar((unsigned int) k); /* cursor up/dn/lf/rt */ if (debug)printf("ncurpos=%d\n",nCurPos); UpdateRange(nCurPos,1); /* UpdateRange(row*80,80); */ UpdateDisplay(); break; default:break; } } } /* ************************************************************* */ #if defined (__STDC__) void VtEsc_Func(char *ptr) #else void VtEsc_Func(ptr) unsigned char *ptr; #endif { static int i,sz; char ch,c; unsigned char *pOut; /*temp patch */ unsigned char *ploc; if (debug){printf(" STATUS RESULT\n"); dump(ptr,10);} if (*(ptr+2)=='?') /* esc[?1xn */ { if (*(ptr+3)== '1') { ch = *(ptr+4); switch (ch) { case noprinter: bWaitforprinter = false; bWaitprintend = false; EnableHost(); Hostflag=1; SetTimeOut(0L,0L); if (XTERM){ printf("bypass no printer\n");return;} NoPrinter=true; if (debug)printf("NoPrinter attached\n"); restore_statusln(vtfkey8); return; case prtready: if (debug)printf("PRTREADY\n"); if (debug)printf("bwaitprintend=%x bwaitforprint=%x\n", bWaitprintend,bWaitforprinter); if (bWaitprintend) { bWaitprintend=false; bWaitforprinter = false; if (page2) {Print_page2(); return;} /* { home_it(); clear_term(); if (debug)dump(&svtext[pos],pg2textsz); for (i=pos;i22 && prt_tog) { i++; pos=pos+i; if (pos>pg2textsz) { page2=false; show_pg2data=false; pos=0; pg2textsz=0; } break; } } pg2textsz=pg2textsz-i; if (pg2textsz==0) if (nCurPos==0 || show_pg2data) { page2=false; show_pg2data=false; EnableHost(); Hostflag=1; SetTimeOut(0L,0L); return; } if (debug) { printf("remainder=%d pos=%d\n",pg2textsz,pos); dump(ScreenData,500); printf("bPrtok=%d\n",bPrtok); } UpdateDisplay(); pagecnt++; print_screen(); if (pg2textsz<1) {page2=false; show_pg2data=false;pos=0;} return; } */ EnableHost(); Hostflag=1; SetTimeOut(0L,0L); restore_statusln(vtfkey8); return; } if (bWaitforprinter) { bPrtok = true; print_screen(); } return; case prtnotrdy: rdyprt=true; show_statusind(vtfkey8); restore_statusln(vtfkey8); print_screen(); return; case prtbusy: /* sleep(1); */ if(debug)printf("PRTBUSY\n"); print_screen(); return; case prtnotassign: return; default:return; } /* end of switch */ } } else if (*(ptr+3)=='~') /* esc[x~ */ { switch(*(ptr+2)) { case '1': home_it();break; /*find key */ case '2': return; case '3':bPageMode=false; /*remove key */ home_it();clear_term();SendBufferLen=0;return; case '4': /*select key */ if (debug)printf("insert '@' \n"); /*OPA */ KbdProcessChar('@'); /*insert @ */ UpdateRange(nCurPos,1); UpdateDisplay(); return; case '5': /*prev key */ i=79; if (bPageMode) { sz=nCurPos; for (i=nCurPos;i22 && prt_tog) /* was 22 */ { i++; pos=pos+i; if (pos>pg2textsz) { page2=false; show_pg2data=false; pos=0; pg2textsz=0; } break; } } pg2textsz=pg2textsz-i; if (pg2textsz==0) /* no data to print */ if (nCurPos==0 || show_pg2data) { page2=false; show_pg2data=false; EnableHost(); Hostflag=1; SetTimeOut(0L,0L); return; } if (PC_print)bPrtok=true; if (debug) printf("remainder=%d pos=%d\n",pg2textsz,pos); UpdateDisplay(); pagecnt++; if (pg2textsz<1) {page2=false; show_pg2data=false;pos=0;} print_screen(); } } /* ********************************************************************** */ #if defined (__STDC__) static int getnx_fld(void) #else static int getnx_fld() #endif { static unsigned char num_str[10]; static char c; static unsigned char *ptr; int i; i=0; c= *(stack_ptr++); if (!num_chek(c)) { kind=alpha; return(c); } if (c=='+' || c=='-') {kind=sign;return(c);} while (num_chek(c)) /* numeric check */ { *(ptr = &num_str[i++])=c; c= *(stack_ptr++); } *(ptr+1)=0x00; kind=num; stack_ptr--; return(atoi(num_str)); /* convert string to number */ } /* ********************************************************************** */ #if defined (__STDC__) static void set_attributes(int row_col,char attr, char on) #else static void set_attributes(row_col,attr,on) int row_col; unsigned char attr,on; #endif { unsigned char *ptr; ptr = &ScreenAttr[row_col]; if (on) *ptr = *ptr | attr; else *ptr = *ptr & ~attr; if (!soe_present) /* patched 7/15/91 */ { saveloc=startloc; /* patched 9/23/91 */ startloc=0; /* patched 7/1/91 */ } } /* ********************************************************************** */ #if defined (__STDC__) static void set_screenattributes(void) #else static void set_screenattributes() #endif { int k; int i; static unsigned char save_attr; if ((k=getnx_fld()) > '?' && k < 'T') { if (k!='@') startdpy=rowcol;else enddpy=rowcol; attr_cnt=0; switch (k) { case '@': char_attr = normal; break; case 'A': char_attr = blink; break; case 'B': char_attr = revvideo;break; case 'C': char_attr = (blink | revvideo); break; case 'D': char_attr|=underscore; break; case 'E': char_attr|=(blink | underscore); break; case 'F': char_attr|=(revvideo | underscore); break; case 'G': char_attr|=(blink | underscore | revvideo); break; case 'H': char_attr|=half_bright; break; case 'I': char_attr|=(blink | half_bright); break; case 'J': char_attr|=(revvideo | half_bright); break; case 'K': char_attr|=(blink | revvideo | half_bright); break; case 'L': char_attr|=(underscore | half_bright); break; case 'M': char_attr|=(blink | underscore | half_bright); break; case 'N': char_attr|=(revvideo | underscore | half_bright); break; case '0': char_attr|=(blink | underscore | half_bright | revvideo); break; case 'S': char_attr|=security; break; default : break; } if (debug) printf("set-startdpy=%d enddpy=%d char_attr=%x\n",startdpy,enddpy, char_attr); if ((char_attr==normal) && (startdpy==0)) /* patch 9/6 */ if (BitsOn(ScreenAttr[enddpy],ATT_XSTART)) { i=enddpy; while (true) if (ScreenAttr[enddpy] & (blink | revvideo)) { if (debug) printf("Scr-Attr=%x n=%d\n",ScreenAttr[enddpy],enddpy); ScreenAttr[enddpy]=ScreenAttr[enddpy] & 0xfc; if (debug) printf("Scr-Attr=%x n=%d\n",ScreenAttr[enddpy],enddpy); enddpy++; } else break; UpdateRange(i,enddpy-i); UpdateDisplay(); return; } if ((enddpy>startdpy) && (startdpy>0)) { if (prev_attr>0) {save_attr=char_attr; char_attr=prev_attr;} UpdateRange(startdpy,enddpy-startdpy); for (i=startdpy;i0)char_attr=save_attr; cursor(); UpdateDisplay(); } } ScreenAttr[nCurPos]=ScreenAttr[nCurPos] | char_attr; /* patch 12/11/90*/ } /* ********************************************************************** */ #if defined (__STDC__) static int go_nx_attribute(char attr, char dir) #else static int go_nx_attribute(attr,dir) char attr; char dir; #endif { int loopcnt; int xx; unsigned char *ptr; fld_type=0; save_row=row; save_col=col; loopcnt=0; ptr = &ScreenAttr[rowcol]; while (loopcnt < 2) { if ((*ptr & attr) > 0) { /* if (*ptr & alpha_fld > 0 ) fld_type = alpha_fld; if (*ptr & numeric_fld >0 ) fld_type = numeric_fld; */ cursor(); return(rowcol); } else if (dir) /* true forward */ { if (col0) col--; else if (row>0) { row--; col=right_margin; } else { row=lastrow;col=right_margin;loopcnt++; } } ptr = &ScreenAttr[rowcol]; } row=save_row; /* attribute not found */ col=save_col; return(0); } /* ******************************************************************** */ #if defined (__STDC__) int find_soe(char thisline) #else int find_soe(thisline) char thisline; #endif { unsigned char *ptr; save_row=row; save_col=col; if (!soe_present) return(0); ptr = &ScreenAttr[rowcol]; while (true) { if (debug) printf("ptr=%x saverow=%x savecol=%x\n",*ptr,save_row,save_col); if (*ptr & soe_bit) { if (thisline) return(save_col); else return((save_row *80) + save_col); } else { if (save_col>0) save_col--; else if (save_row>0) { if (thisline) return(0); /* only search this line */ save_row--; save_col=right_margin; } else return(0); } ptr = &ScreenAttr[(save_row * 80) + save_col]; } } /* ******************************************************************** */ #if defined (__STDC__) void dump(char *ptr,int sz) #else void dump(ptr,sz) unsigned char *ptr; int sz; #endif { int k,i,maxsz; int j; char c; char dmpdata[21]; char pt; printf("***************** SZ = %d ***togs %x *********\n",sz,togs); k=0; if (sz<20) maxsz=sz; else maxsz=20; for (i=0;i ====\n",i); for (k=0;k 0) { if (label_sz>8) sz=8; else sz=label_sz; for (i=0;i80) str_sz=80; for (i=0;i0) { NoPrinter=true; syslog(LOG_ERR, "can't open Xterm print port-status=%d.\n",xprinterstatus); } else bPrtok=true; bWaitprintend=false; } if (bPrtok) { if (nCol>0) rowcnt=1; else rowcnt=0; rowcnt=rowcnt+nRow; if (debug)printf("NROW=%d rowcnt=%d nCol=%d\n",nRow,rowcnt,nCol); if (rowcnt==24 && nCol==0) ; else if ((rowcnt>22) || (nRow==0)) rowcnt=23; if (row>22)row=0; for (i=0;i0) { NoPrinter=true; syslog(LOG_ERR,"can't open Xterm print port."); } else bPrtok=true; bWaitprintend=false; } if (debug) dump(msg,nText); for (i=0;i