+ /* compile regexes for iscallsign */
+ {
+ myregex_t *rp;
+ for (rp = iscallreg; rp->in; ++rp) {
+ regex_t reg;
+ int r = regcomp(®, rp->in, REG_EXTENDED|REG_ICASE|REG_NOSUB);
+ if (r)
+ die("regcomp returned %d for '%s'", r, rp->in);
+ rp->regex = malloc(sizeof(regex_t));
+ if (!rp->regex)
+ die("out of room - compiling regexes");
+ *rp->regex = reg;
+ }
+ }
+
+ /* is this a login? */
+ if (eq(call, "LOGIN") || eq(call, "login")) {
+
+ char buf[MAXPACLEN+1];
+ char callsign[MAXCALLSIGN+1];
+ int r, i;
+ int f = xopen("data", "issue", 0);
+ if (f > 0) {
+ while ((r = read(f, buf, paclen)) > 0) {
+ if (nl != '\n') {
+ char *p;
+ for (p = buf; p < &buf[r]; ++p) {
+ if (*p == '\n')
+ *p = nl;
+ }
+ }
+ write(0, buf, r);
+ }
+ close(f);
+ }
+ signal(SIGALRM, login_timeout);
+ alarm(timeout);
+ write(0, "login: ", 7);
+ 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) || *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);
+ callsign[i]= 0;
+ call = strupper(callsign);
+ }
+
+ /* check the callsign */
+ if (!iscallsign(call)) {
+ die("Sorry, %s isn't a valid callsign", call);
+ }
+
+ /* connect up stdin */