|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 2340 (0x924) Types: TextFile Names: »slave_io.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Bridge/slave_io.c«
#include "talk.h" #include <stdio.h> #include <errno.h> #include <sys/time.h> #define A_LONG_TIME 10000000 #define STDIN_MASK (1<<fileno(stdin)) /* the bit mask for standard input */ extern int errno; /* * The routine to do the actual talking */ talk() { char ch,ins[2][40]; static char *im[2]={"Conversation","Input "}; int rtn, i, ityp,iwn,wn, row, col, readmask,read_template; int sockt_mask,read_set; BMSG buf; int ki[2],nb,nbuf=sizeof buf; struct timeval wait; ityp=1;iwn=12;ki[0]=ki[1]=0; wmove(comwin[18].x_win,0,0); wprintw(comwin[18].x_win,"%s",im[ityp]); wrefresh(comwin[18].x_win); sockt_mask=(1<<sockt); read_template=sockt_mask | STDIN_MASK; forever { read_set=read_template; wait.tv_sec=100000; wait.tv_usec=0; select(32,&read_set,0,0,&wait); if(read_set&sockt_mask){ nb=read(sockt,&buf,nbuf); if(nb==nbuf){ wn=WN;row=ROW;col=COL; if(row<80) wmove(comwin[wn].x_win,row,col); if(wn<14&&STR[0]=='\\'){endwin();exit();} if(STR[0]=='Z'|wn==12) wclear(comwin[wn].x_win); if(STR[0]!='Z') wprintw(comwin[wn].x_win,"%s",STR); wrefresh(comwin[wn].x_win); } } if(read_set&STDIN_MASK){ read(0,&ch,1); if(ityp==1&&ch<='z'&&ch>='a') ch&=223; switch(ch){ case 27: ityp=1-ityp;iwn=28-iwn; wmove(comwin[18].x_win,0,0); wprintw(comwin[18].x_win,"%s",im[ityp]); wrefresh(comwin[18].x_win); break; case '\b': if(ki[ityp]>0){ ki[ityp]--; waddch(comwin[iwn].x_win,ch); wrefresh(comwin[iwn].x_win); } break; default: ins[ityp][ki[ityp]++]=ch; waddch(comwin[iwn].x_win,ch); wrefresh(comwin[iwn].x_win); } if(ki[ityp]>=comwin[iwn].x_ncols-1&&ch!='\n'){ ch='\n';ins[ityp][ki[ityp]++]=ch; waddch(comwin[iwn].x_win,ch); wrefresh(comwin[iwn].x_win); } if(ch=='\n'){ if(ityp){wclear(comwin[iwn].x_win); wrefresh(comwin[iwn].x_win);} TYPE=ityp;ins[ityp][ki[ityp]]='\0'; ROW=81;ki[ityp]=0; strcpy(STR,ins[ityp]); write(sockt,&buf,nbuf); } } } } p_error(string) char *string; { char *sys; sys = "Unknown error"; printf("[%s : %s (%d)]\n", string, sys, errno); quit(); } /* display string in the standard location */ message(string) char *string; { }