[Linux-decnet-commit] CVS: dnprogs/apps sethost.c,1.7,1.8
Brought to you by:
chrissie_c,
ph3-der-loewe
From: Patrick C. <pa...@us...> - 2003-09-26 08:02:13
|
Update of /cvsroot/linux-decnet/dnprogs/apps In directory sc8-pr-cvs1:/tmp/cvs-serv9791 Modified Files: sethost.c Log Message: Don't use SIGIO Index: sethost.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/apps/sethost.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** sethost.c 15 Dec 2002 19:43:29 -0000 1.7 --- sethost.c 26 Sep 2003 08:02:05 -0000 1.8 *************** *** 51,55 **** unsigned char char_attr[256]; ! unsigned char *nodename,inpbuf[132],buf[1000], ahead[32]; short bufptr,blklen,cnt; --- 51,55 ---- unsigned char char_attr[256]; ! unsigned char *nodename,inpbuf[132],buf[1600], ahead[32]; short bufptr,blklen,cnt; *************** *** 75,78 **** --- 75,80 ---- static int htype; /*ed*/ + static void (*kb_handler)(int); + /* Routines in this program: static void usage(char *prog, FILE *f) *************** *** 288,298 **** } /* ! if ((zz == 2 ) && (car == ESC) && (han_char.input_escseq_recognition)) */ if (car == ESC) escseq=TRUE; ! if (!escseq) ct_echo_input_char(&car); ! inpbuf[inpptr++]=car; inpcnt += 1; --- 290,300 ---- } /* ! if ((zz == 2 ) && (car == ESC) && (han_char.input_escseq_recognition)) */ if (car == ESC) escseq=TRUE; ! if (!escseq) ct_echo_input_char(&car); ! inpbuf[inpptr++]=car; inpcnt += 1; *************** *** 301,309 **** { esclen += 1; ! if (escseq_terminator(car)) ct_terminate_read(1); return; } ! if (zz==2) { if (car < 0x1B) --- 303,311 ---- { esclen += 1; ! if (escseq_terminator(car)) ct_terminate_read(1); return; } ! if (zz==2) { if (car < 0x1B) *************** *** 323,327 **** if (flavor != CTERM) return 0; ! oo=char_attr[car] & 0x03; i =(char_attr[car] & 0x04) >> 2; --- 325,329 ---- if (flavor != CTERM) return 0; ! oo=char_attr[car] & 0x03; i =(char_attr[car] & 0x04) >> 2; *************** *** 329,333 **** ee=(char_attr[car] & 0x30) >> 4; f =(char_attr[car] & 0x40) >> 6; ! if (oo==0) return 0; msg[5]=d; --- 331,335 ---- ee=(char_attr[car] & 0x30) >> 4; f =(char_attr[car] & 0x40) >> 6; ! if (oo==0) return 0; msg[5]=d; *************** *** 349,356 **** if (oo==3) redisplay=TRUE; ! if ((oo==3) && (i==1)) return 0; ! return 1; ! } /*-------------------------------------------------------------------------*/ --- 351,358 ---- if (oo==3) redisplay=TRUE; ! if ((oo==3) && (i==1)) return 0; ! return 1; ! } /*-------------------------------------------------------------------------*/ *************** *** 366,370 **** for (i=0; i < 32; i++) term_tab[i]=0; for (i=0; i < 256; i++) char_attr[i]=0; ! if ( (np=getnodebyname(nodename)) == NULL) --- 368,372 ---- for (i=0; i < 32; i++) term_tab[i]=0; for (i=0; i < 256; i++) char_attr[i]=0; ! if ( (np=getnodebyname(nodename)) == NULL) *************** *** 557,561 **** } ! if ( (cnt=read(sockfd,buf,sizeof(buf))) < 0) { int status = 0; --- 559,563 ---- } ! if ( (cnt=dnet_recv(sockfd, buf, sizeof(buf), MSG_EOR)) < 0) { int status = 0; *************** *** 597,601 **** } ! if ( (cnt=read(sockfd,buf,sizeof(buf))) < 0) { printf("ct_setup_link: error receiving bind from host\n"); --- 599,603 ---- } ! if ( (cnt=dnet_recv(sockfd,buf,sizeof(buf),MSG_EOR)) < 0) { printf("ct_setup_link: error receiving bind from host\n"); *************** *** 650,654 **** } ! if ( (cnt=read(sockfd,buf,sizeof(buf))) < 0) { printf("ct_setup_link: error receiving initiate/host\n"); --- 652,656 ---- } ! if ( (cnt=dnet_recv(sockfd,buf,sizeof(buf),MSG_EOR)) < 0) { printf("ct_setup_link: error receiving initiate/host\n"); *************** *** 695,699 **** raw.c_cc[4] = 1; raw.c_cc[5] = 2; ! if ( ioctl(ttyfd,TCSETA,&raw) < 0) { --- 697,701 ---- raw.c_cc[4] = 1; raw.c_cc[5] = 2; ! if ( ioctl(ttyfd,TCSETA,&raw) < 0) { *************** *** 707,716 **** exit(-1); } ! if ( (fcntl(ttyfd,F_SETFL,savflgs|FASYNC)) < 0) ! { ! perror("setflg"); ! ct_reset_term(); ! exit(-1); ! } } /*-------------------------------------------------------------------------*/ --- 709,713 ---- exit(-1); } ! } /*-------------------------------------------------------------------------*/ *************** *** 726,730 **** cntx=read(ttyfd,&buf,80); for (i=0; i < cntx; i++) ! { c=buf[i]; if (c==exit_char) --- 723,727 ---- cntx=read(ttyfd,&buf,80); for (i=0; i < cntx; i++) ! { c=buf[i]; if (c==exit_char) *************** *** 742,746 **** break; case CTRL_O: discard = ~discard; ! if (discard) write(ttyfd,"\n*output off*\n",14); else --- 739,743 ---- break; case CTRL_O: discard = ~discard; ! if (discard) write(ttyfd,"\n*output off*\n",14); else *************** *** 753,757 **** default: if (ct_out_of_band(c)) break; ! if (read_present) { ct_input_proc(c); --- 750,754 ---- default: if (ct_out_of_band(c)) break; ! if (read_present) { ct_input_proc(c); *************** *** 763,768 **** } } ! signal(SIGIO,ct_preinput_proc); /* re-establish itself */ ! } /*-------------------------------------------------------------------------*/ static void rsts_preinput_proc(int x) --- 760,764 ---- } } ! } /*-------------------------------------------------------------------------*/ static void rsts_preinput_proc(int x) *************** *** 775,779 **** cntx=read(ttyfd, &buf[4], 80); for (i=0; i < cntx; i++) ! { c=buf[i + 4]; if (c==exit_char) --- 771,775 ---- cntx=read(ttyfd, &buf[4], 80); for (i=0; i < cntx; i++) ! { c=buf[i + 4]; if (c==exit_char) *************** *** 799,804 **** exit(-1); } ! signal(SIGIO, rsts_preinput_proc); /* re-establish itself */ ! } /*-------------------------------------------------------------------------*/ static void rsx_preinput_proc(int x) --- 795,799 ---- exit(-1); } ! } /*-------------------------------------------------------------------------*/ static void rsx_preinput_proc(int x) *************** *** 817,821 **** cntx=read(ttyfd, &buf, 80); for (i=0; i < cntx; i++) ! { c=buf[i]; if (c==exit_char) --- 812,816 ---- cntx=read(ttyfd, &buf, 80); for (i=0; i < cntx; i++) ! { c=buf[i]; if (c==exit_char) *************** *** 836,841 **** exit(-1); } ! signal(SIGIO, tops_preinput_proc); /* re-establish itself */ ! } /*-------------------------------------------------------------------------*/ static void ct_print_char(char *c) --- 831,835 ---- exit(-1); } ! } /*-------------------------------------------------------------------------*/ static void ct_print_char(char *c) *************** *** 901,905 **** bufptr += 1; flg=buf[bufptr]; ! ee = (flg & 0x03); bufptr += 1; /* Point to next char */ --- 895,899 ---- bufptr += 1; flg=buf[bufptr]; ! ee = (flg & 0x03); bufptr += 1; /* Point to next char */ *************** *** 907,935 **** p=(void *)&buf[bufptr]; max_len=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; end_of_data=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; timeout=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; end_of_prompt=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; start_of_display=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; low_water=dn_ntohs(*p); ! bufptr += 2; termlen = buf[bufptr]; bufptr += 1; procnt=17; ! for (i=0; i < termlen; i++) { term_tab[i]=buf[bufptr]; --- 901,929 ---- p=(void *)&buf[bufptr]; max_len=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; end_of_data=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; timeout=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; end_of_prompt=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; start_of_display=dn_ntohs(*p); ! bufptr += 2; p=(void *)&buf[bufptr]; low_water=dn_ntohs(*p); ! bufptr += 2; termlen = buf[bufptr]; bufptr += 1; procnt=17; ! for (i=0; i < termlen; i++) { term_tab[i]=buf[bufptr]; *************** *** 995,999 **** s = (flgs & 0x400) >> 10; t = (flgs & 0x800) >> 11; ! prefix = buf[bufptr]; bufptr += 1; --- 989,993 ---- s = (flgs & 0x400) >> 10; t = (flgs & 0x800) >> 11; ! prefix = buf[bufptr]; bufptr += 1; *************** *** 1008,1012 **** if (d) discard=FALSE; ! if (pp==1) { for (i=0; i < pp; i++) ct_print_char(&lf); --- 1002,1006 ---- if (d) discard=FALSE; ! if (pp==1) { for (i=0; i < pp; i++) ct_print_char(&lf); *************** *** 1021,1026 **** procnt += 1; ct_print_char(&c); ! } ! if (qq==1) { for (i=0; i < qq; i++) ct_print_char(&lf); --- 1015,1020 ---- procnt += 1; ct_print_char(&c); ! } ! if (qq==1) { for (i=0; i < qq; i++) ct_print_char(&lf); *************** *** 1081,1085 **** { if (debug == 2) { printf(" ct_readchar_req...Phys char!\n");} ! switch (selector & 0xFF) { case 0x01: /* Input speed */ --- 1075,1079 ---- { if (debug == 2) { printf(" ct_readchar_req...Phys char!\n");} ! switch (selector & 0xFF) { case 0x01: /* Input speed */ *************** *** 1212,1216 **** bufptr += 2; break; ! case 0x02: /* Terminal attributes */ p=(void *)&outbuf[ouptr]; --- 1206,1210 ---- bufptr += 2; break; ! case 0x02: /* Terminal attributes */ p=(void *)&outbuf[ouptr]; *************** *** 1643,1647 **** fd_set rdfs; int retval; - long numbytes; if (debug == 2) { printf(" Entered static void ct_read_pkt...\n");} --- 1637,1640 ---- *************** *** 1649,1681 **** FD_ZERO(&rdfs); FD_SET(sockfd,&rdfs); ! retval=select(sockfd+1,&rdfs,NULL,NULL, NULL); ! } while (retval <= 0); ! ioctl(sockfd,FIONREAD,&numbytes); ! cnt=read(sockfd,buf,numbytes); ! if (cnt <= 0) { unbind = TRUE; return; ! } ! /* ! if ( (cnt=read(sockfd,buf,sizeof(buf))) < 0) ! { ! perror("read pkt"); ! ct_reset_term(); ! exit(-1); ! } ! */ ! if (flavor == CTERM) ! { if (buf[0] == 0x09) bufptr = 2; if ( (cnt==3) && (buf[0] == 0x02)) unbind = TRUE; ! } ! else ! { if (cnt == 0) ! unbind = TRUE; bufptr = 0; } } /*-------------------------------------------------------------------------*/ --- 1642,1675 ---- FD_ZERO(&rdfs); FD_SET(sockfd,&rdfs); ! FD_SET(ttyfd,&rdfs); ! retval=select(FD_SETSIZE,&rdfs,NULL,NULL, NULL); ! } while (retval <= 0); ! ! if (FD_ISSET(sockfd, &rdfs)) { + cnt=dnet_recv(sockfd,buf,sizeof(buf),MSG_EOR); + if (cnt <= 0) + { unbind = TRUE; return; ! } ! if (flavor == CTERM) ! { if (buf[0] == 0x09) bufptr = 2; if ( (cnt==3) && (buf[0] == 0x02)) unbind = TRUE; ! } ! else ! { if (cnt == 0) ! unbind = TRUE; bufptr = 0; + } + } + if (FD_ISSET(ttyfd, &rdfs)) + { + kb_handler(0); } + } /*-------------------------------------------------------------------------*/ *************** *** 1705,1709 **** exit(-1); } ! write(ttyfd, buf + 4, data_cnt); } bufptr = cnt; --- 1699,1703 ---- exit(-1); } ! write(ttyfd, buf + 4, data_cnt); } bufptr = cnt; *************** *** 1727,1731 **** blklen=buf[bufptr] | (buf[bufptr+1]<<8); ! bufptr += 2; switch(buf[bufptr]) { --- 1721,1725 ---- blklen=buf[bufptr] | (buf[bufptr+1]<<8); ! bufptr += 2; switch(buf[bufptr]) { *************** *** 1790,1794 **** struct sigaction sa; sigset_t ss; ! int verbosity; /*int debug = 0;*/ --- 1784,1788 ---- struct sigaction sa; sigset_t ss; ! int verbosity; /*int debug = 0;*/ *************** *** 1802,1808 **** while ((opt=getopt(argc,argv,"?Vhdte:")) != EOF) { ! switch(opt) { ! case 'h': usage(argv[0], stdout); exit(0); --- 1796,1802 ---- while ((opt=getopt(argc,argv,"?Vhdte:")) != EOF) { ! switch(opt) { ! case 'h': usage(argv[0], stdout); exit(0); *************** *** 1834,1845 **** { usage(argv[0], stderr); ! exit(2); } nodename = argv[optind]; ! ! ct_setup(); /* Resolve remote node addr*/ /* ct_setup_link may use "cooked" to send terminal characteristics ! * to the other end */ if ( ioctl(ttyfd,TCGETA,&cooked) < 0) --- 1828,1839 ---- { usage(argv[0], stderr); ! exit(2); } nodename = argv[optind]; ! ! ct_setup(); /* Resolve remote node addr*/ /* ct_setup_link may use "cooked" to send terminal characteristics ! * to the other end */ if ( ioctl(ttyfd,TCGETA,&cooked) < 0) *************** *** 1849,1855 **** } ct_setup_link(); /* Setup link */ ! ct_init_term(); /* Set terminal in raw mode*/ ! sigemptyset(&ss); if (debug == 1) --- 1843,1849 ---- } ct_setup_link(); /* Setup link */ ! ct_init_term(); /* Set terminal in raw mode*/ ! sigemptyset(&ss); if (debug == 1) *************** *** 1860,1873 **** { case CTERM: ! sa.sa_handler = ct_preinput_proc; break; case RSTS: ! sa.sa_handler = rsts_preinput_proc; ! break; case RSX: ! sa.sa_handler = rsx_preinput_proc; break; case TOPS20: ! sa.sa_handler = tops_preinput_proc; break; case VMS: --- 1854,1867 ---- { case CTERM: ! kb_handler = ct_preinput_proc; break; case RSTS: ! kb_handler = rsts_preinput_proc; ! break; case RSX: ! kb_handler = rsx_preinput_proc; break; case TOPS20: ! kb_handler = tops_preinput_proc; break; case VMS: *************** *** 1875,1890 **** break; } - sa.sa_mask = ss; - sa.sa_flags = 0; - sigaction(SIGIO, &sa, NULL); /* Setup SIGIO Handler for */ - /* keyboard input */ - sa.sa_handler=ct_timeout_proc; - sigaction(SIGALRM, &sa, NULL); alarm(0); ! ct_proc_pkt(); /* Process input packets */ ! ct_reset_term(); ! return 0; } --- 1869,1878 ---- break; } alarm(0); ! ct_proc_pkt(); /* Process input packets */ ! ct_reset_term(); ! return 0; } |