X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient.c;h=cd11c78b53b45446b654744c721f4abb7b672b6f;hb=bd95f04650a16c15d5691a7a318d51ed764e8b39;hp=3cd88068d54aa65f282f9230c936b85681a3282b;hpb=7fc04d3328f15fdeca0e86f8771c4b0b2d431df6;p=spider.git diff --git a/src/client.c b/src/client.c index 3cd88068..cd11c78b 100644 --- a/src/client.c +++ b/src/client.c @@ -232,7 +232,12 @@ void send_text(fcb_t *f, char *s, int l) flush_text(f); f->obuf = mp = cmsg_new(paclen+1, f->sort, f); } - *mp->inp++ = '\n'; + if (nl == '\r') + *mp->inp++ = nl; + else { + *mp->inp++ = '\r'; + *mp->inp++ = '\n'; + } if (!f->buffer_it) flush_text(f); } @@ -297,12 +302,14 @@ int fcb_handler(sel_t *sp, int in, int out, int err) default: /* if (f->sort == MSG) send_Z = 0; */ + dbg(DBUF,"got errno %d in input", errno); ending++; return 0; } } else if (r == 0) { /* if (f->sort == MSG) send_Z = 0; */ + dbg(DBUF, "ending normally"); ending++; return 0; } @@ -475,6 +482,7 @@ lout:; default: /* if (f->sort == MSG) send_Z = 0; */ + dbg(DBUF,"got errno %d in output", errno); ending++; return; } @@ -749,7 +757,8 @@ main(int argc, char *argv[]) /* is this a login? */ if (eq(call, "LOGIN")) { char buf[MAXPACLEN+1]; - int r; + char callsign[MAXCALLSIGN+1]; + int r, i; int f = xopen("data", "issue", 0); if (f > 0) { while ((r = read(f, buf, paclen)) > 0) { @@ -767,19 +776,32 @@ main(int argc, char *argv[]) signal(SIGALRM, login_timeout); alarm(timeout); write(0, "login: ", 7); - r = read(0, buf, 20); - if (r <= 0) - die("No login or error (%d)", errno); + dbgdump(DBUF, "<-out", "login: ", 7); + for (i = 0;;) { + char *p; + r = read(0, buf, 20); + dbgdump(DBUF, "in ->", buf, r); + if (r <= 0) + die("No login or error (%d)", errno); + write(0, buf, r); + dbgdump(DBUF, "<-out", buf, r); + for (p = buf; p < buf+r; ++p) { + if (i < MAXCALLSIGN) { + if (*p == '\r' || *p == '\n') + goto lgotcall; + else if (isalnum(*p)) + callsign[i++] = *p; + else + die("%c is not a valid callsign character", *p); + } else + die("callsign entered is too long"); + } + } +lgotcall: signal(SIGALRM, SIG_IGN); alarm(0); - while (r > 0) { - if (buf[r-1] == ' ' || buf[r-1] == '\r' || buf[r-1] == '\n') - --r; - else - break; - } - buf[r] = 0; - call = strupper(buf); + callsign[i]= 0; + call = strupper(callsign); } /* check the callsign */ @@ -791,7 +813,7 @@ main(int argc, char *argv[]) in = fcb_new(0, TEXT); in->sp = sel_open(0, in, "STDIN", fcb_handler, TEXT, SEL_INPUT); if (tcgetattr(0, &in->t) < 0) { - echo = 0; +/* echo = 0; */ in->t_set = 0; } else { struct termios t = in->t;