Client UTF-8 support.

(login): New parameter utf8.  If set, request option utf-8 from
server.
(expect, recvline): Split recvline() out of expect().  Replace or
remove some unhelpful diagnostics.
(eight_bit_clean): New.
(screen): If eight_bit_clean is set, highlighting is switched with
SO/SI.  Else characters with MSB set are highlighted.
(main): New option -u to request UTF-8 and set eight_bit_clean.
This commit is contained in:
Markus Armbruster 2005-05-27 17:00:25 +00:00
parent baf416652a
commit 7ef7aa83b8
6 changed files with 55 additions and 16 deletions

View file

@ -44,19 +44,31 @@
#endif
int
login(int s, char *uname, char *cname, char *cpass, int kill_proc)
login(int s, char *uname, char *cname, char *cpass, int kill_proc, int utf8)
{
char tmp[128];
char buf[1024];
char *ptr;
char *p;
int len;
int len, code;
if (!expect(s, C_INIT, buf))
return 0;
(void)sendcmd(s, "user", uname);
if (!expect(s, C_CMDOK, buf))
return 0;
if (utf8) {
sendcmd(s, "options", "utf-8");
for (;;) {
code = recvline(s, buf);
if (code == C_CMDOK)
break;
if (code != C_DATA) {
fprintf(stderr, "Server doesn't support UTF-8\n");
return 0;
}
}
}
if (cname == NULL) {
(void)printf("Country name? ");
cname = fgets(tmp, sizeof(tmp), stdin);