f->sp->flags |= SEL_OUTPUT;
}
+/*
+ * send a file out to the user
+ */
+void send_file(char *name)
+{
+ int i;
+ char buf[MAXPACLEN+1];
+
+ FILE *f = xopen("data", name, "r");
+ if (f) {
+ while (fgets(buf, paclen, f)) {
+ i = strlen(buf);
+ if (i && buf[i-1] == '\n')
+ buf[--i] = 0;
+ send_text(in, buf, i, 1);
+ }
+ fclose(f);
+ }
+}
+
/*
* the callback (called by sel_run) that handles all the inputs and outputs
*/
case 1:
mp->state = 2;
- if (ch >= '2' && ch <= '9')
+ if (ch >= '0' && ch <= '9')
c = (ch - '0') << 4;
else if (ch >= 'A' && ch <= 'F')
c = (ch - 'A' + 10) << 4;
else {
- dbg(DMSG, "Illegal hex char (%c) received in state %d", ch, mp->state);
+ dbg(DMSG, "Illegal hex char (%c) received in state 1", ch);
mp->inp = mp->data;
mp->state = 0;
}
else if (ch >= 'A' && ch <= 'F')
*mp->inp++ = c | (ch - 'A' + 10);
else {
- dbg(DMSG, "Illegal hex char (%c) received in state %d", ch, mp->state);
+ dbg(DMSG, "Illegal hex char (%c) received in state 2", ch);
mp->inp = mp->data;
}
mp->state = 0;
send_msg(node, 'A', connsort, strlen(connsort));
chgstate(CONNECTED);
+ send_file("connected");
}
cmsg_callback(mp, 0);
/* is this a login? */
if (eq(call, "LOGIN") || eq(call, "login")) {
-
- char buf[MAXPACLEN+1];
- int r, i;
- FILE *f = xopen("data", "issue", "r");
- if (f) {
- while (fgets(buf, paclen, f)) {
- i = strlen(buf);
- if (i && buf[i-1] == '\n')
- buf[--i] = 0;
- send_text(in, buf, i, 1);
- }
- fclose(f);
- }
+ send_file("issue");
signal(SIGALRM, login_timeout);
alarm(timeout);
send_text(in, "login: ", 7, 0);
send_msg(node, 'A', connsort, strlen(connsort));
chgstate(CONNECTED);
+ send_file("connected");
}