From owner-freebsd-hackers Thu Oct 12 06:21:07 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id GAA10558 for hackers-outgoing; Thu, 12 Oct 1995 06:21:07 -0700 Received: from frya.zgik.zaporizhzhe.ua (ZGIK-1-ELIS-14.4K.zgik.zaporizhzhe.ua [193.124.62.253]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id GAA10455 for ; Thu, 12 Oct 1995 06:19:56 -0700 Received: from zgik.UUCP by frya.zgik.zaporizhzhe.ua with UUCP id PAA20381; (8.6.11/vak/1.8e) Thu, 12 Oct 1995 15:11:28 +0200 Received: by relay1.bcs.zaporizhzhe.ua (uumail v1.5/ache) id AA28473; Thu, 12 Oct 1995 15:04:23 +0200 Received: from bcs1.bcs.zaporizhzhe.ua (bcs1.bcs.zaporizhzhe.ua [193.124.62.29]) by bcs.zaporizhzhe.ua (8.6.11/8.6.9) with SMTP id PAA28470; Thu, 12 Oct 1995 15:04:22 +0200 Received: by bcs1.bcs.zaporizhzhe.ua id AA07744 (5.65c8/IDA-1.4.4 for eugen@zgik.zaporizhzhe.ua); Thu, 12 Oct 1995 15:02:40 +0200 From: Sergey Shkonda Message-Id: <199510121302.AA07744@bcs1.bcs.zaporizhzhe.ua> Subject: Patch to talk client To: hackers@freebsd.org Date: Thu, 12 Oct 1995 15:02:36 +0200 (UKR) Cc: eugen@zgik.zaporizhzhe.ua (Eugen Polovnikow) X-Mailer: ELM [version 2.4 PL0] Content-Type: text Content-Length: 6482 Sender: owner-hackers@freebsd.org Precedence: bulk There are patch to talk client for support 8-bit talking (for example in russian language) -- Sergey Shkonda serg@bcs1.bcs.zaporizhzhe.ua **************************************************** **************************************************** Sample.tbl: # Syntax: # # from: # [ table from remote to local ] # # to: # [ table from local to remote ] from: 0x7e 0x5e # "~" -> "^" 0x60 0x27 # "`" -> "'" to: 0x5e 0x7e # "^" -> "~" 0x27 0x60 # "'" -> "`" **************************************************** **************************************************** Only in talk.n: Sample.tbl diff -c -r talk.o/display.c talk.n/display.c *** talk.o/display.c Thu Oct 12 14:43:51 1995 --- talk.n/display.c Thu Oct 12 14:43:42 1995 *************** *** 144,150 **** text++; continue; } ! if (!isprint(*text) && *text != '\t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); cch = (*text & 63) + 64; --- 144,151 ---- text++; continue; } ! /* if (!isprint(*text) && *text != '\t') { */ ! if ((*text<' ') && *text != '\t') { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); cch = (*text & 63) + 64; diff -c -r talk.o/get_names.c talk.n/get_names.c *** talk.o/get_names.c Thu Oct 12 14:43:51 1995 --- talk.n/get_names.c Thu Oct 12 14:43:42 1995 *************** *** 60,66 **** register char *cp; if (argc < 2 ) { ! printf("Usage: talk user [ttyname]\n"); exit(-1); } if (!isatty(0)) { --- 60,66 ---- register char *cp; if (argc < 2 ) { ! printf("Usage: talk [-t table] user [ttyname]\n"); exit(-1); } if (!isatty(0)) { diff -c -r talk.o/io.c talk.n/io.c *** talk.o/io.c Thu Oct 12 14:43:51 1995 --- talk.n/io.c Thu Oct 12 14:43:42 1995 *************** *** 44,51 **** --- 44,53 ---- #include #include #include + #include #include #include + #include #include "talk.h" #define A_LONG_TIME 10000000 *************** *** 53,64 **** input */ /* * The routine to do the actual talking */ talk() { register int read_template, sockt_mask; ! int read_set, nb; char buf[BUFSIZ]; struct timeval wait; --- 55,170 ---- input */ /* + * the tables for input/oupput mapping + */ + unsigned char to_his_table[256]; + unsigned char from_his_table[256]; + + /* + * The routine for init tables + */ + init_tables() + { + int k; + for ( k=0; k<256; k++) + to_his_table[k]=from_his_table[k]=k; + } + + #define xdigtonum(a) ((toupper(a)>='A')?((toupper(a))-'7'):(a)-'0') + + int + _txt_to_char(s) + char* s; + { + int k; + if(!isdigit(*s)) + return -1; + if((s[0]=='0') && (s[1]=='x')) /* hex notation */ + { + if(!isxdigit(s[2]) || !isxdigit(s[3])) + return 0; + k=xdigtonum(s[2])*16+xdigtonum(s[3]); + return k; + } + k=0; + while(isdigit(*s)) + k=k*10+(*(s++))-'0'; + return k; + } + + /* + * The routine for load tables from file + */ + + load_tables(table) + char* table; + { + FILE* f; + int stat; + char s[200]; /* no more 200 chars in line */ + f=fopen(table,"r"); + if (!f) + { + char fname[PATH_MAX]; + strcpy(fname,"/usr/share/misc/"); + strcat(fname,table); + f=fopen(fname,"r"); + } + if (!f) + return 0; + stat=0; /* begin read table */ + while (!feof(f)) + { + int ich,och,k; + if (!fgets(s,200,f)) + s[0]=0; + if(!s[0]) + continue; + if(s[strlen(s)-1]=='\n') + s[strlen(s)-1]=0; + if((s[0]=='#')||(!s[0])) /* comment or void line */ + continue; + if(!strncmp(s,"from:",5)) + { + stat=1; + continue; + } + if(!strncmp(s,"to:",3)) + { + stat=2; + continue; + } + ich=_txt_to_char(s); + /* search second parameter */ + for( k=1; s[k] && !( isdigit(s[k]) && + ((s[k-1]==' ') || (s[k-1]=='\t')) + ); k++) { } + if (!stat||(ich>=0x100)||(ich<0)||(!s[k]) ) /* error */ + { + init_tables(); + break; + } + och=_txt_to_char(s+k); + if((och>=0x100) || (och<0)) + { + init_tables(); + break; + } + if (stat==1) /* _from_ mapping */ + from_his_table[ich]=och; + else /* _to_ mapping */ + to_his_table[ich]=och; + } + fclose(f); + } + + /* * The routine to do the actual talking */ talk() { register int read_template, sockt_mask; ! int read_set, nb, k; char buf[BUFSIZ]; struct timeval wait; *************** *** 92,97 **** --- 198,206 ---- message("Connection closed. Exiting"); quit(); } + /* translate using from_his_table[] */ + for (k=0; k 2) + if (!strcmp(argv[1],"-t")) + { + load_tables(argv[2]); + argv+=2; + argc-=2; + } get_names(argc, argv); check_writeable(); init_display();