#include <string.h>
#include <signal.h>
#include <errno.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
#include <sys/types.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
#define MIN(a, b) ((a) < (b) ? (a) : (b))
serv_puts("CHAT");
serv_gets(buf);
if (buf[0] != '8') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
- printf("Entering chat mode (type /quit to exit, /help for other cmds)\n");
+ scr_printf("Entering chat mode (type /quit to exit, /help for other cmds)\n");
set_keepalives(KA_NO);
last_transmit = time(NULL);
strcpy(buf, "");
strcpy(wbuf, "");
color(BRIGHT_YELLOW);
- printf("> ");
+ sln_printf_if("\n");
+ sln_printf("> ");
send_complete_line = 0;
recv_complete_line = 0;
while (1) {
- fflush(stdout);
+ sln_flush();
FD_ZERO(&rfds);
FD_SET(0, &rfds);
FD_SET(getsockfd(), &rfds);
goto RCL;
}
if (FD_ISSET(0, &rfds)) {
- ch = inkey();
+ ch = scr_getc(SCR_BLOCK);
if ((ch == 10) || (ch == 13)) {
send_complete_line = 1;
} else if ((ch == 8) || (ch == 127)) {
if (strlen(wbuf) > 0) {
wbuf[strlen(wbuf) - 1] = 0;
- printf("%c %c", 8, 8);
+ sln_printf("%c %c", 8, 8);
}
} else {
- putc(ch, stdout);
+ sln_putc(ch);
wbuf[strlen(wbuf) + 1] = 0;
wbuf[strlen(wbuf)] = ch;
}
}
}
if (recv_complete_line) {
- printf("\r%79s\r", "");
+ sln_printf("\r%79s\r", "");
if (!strcmp(buf, "000")) {
color(BRIGHT_WHITE);
- printf("Exiting chat mode\n");
-
- fflush(stdout);
+ sln_printf("\rExiting chat mode\n");
+ sln_flush();
set_keepalives(KA_YES);
-
/* Some users complained about the client and server
* losing protocol synchronization when exiting chat.
* This little dialog forces everything to be
extract(c_text, buf, 1);
if (num_parms(buf) > 2) {
extract(c_room, buf, 2);
- printf("Got room %s\n", c_room);
+ scr_printf("Got room %s\n", c_room);
}
if (strcasecmp(c_text, "NOOP")) {
if (!strcmp(c_user, fullname)) {
while (strlen(buf) < 79)
strcat(buf, " ");
if (strcmp(c_user, last_user)) {
- printf("\r%79s\n", "");
+ sln_printf("\r%79s\n", "");
strcpy(last_user, c_user);
}
- printf("\r%s\n", buf);
- fflush(stdout);
+ scr_printf("\r%s\n", buf);
+ scr_flush();
}
}
color(BRIGHT_YELLOW);
- printf("> %s", wbuf);
+ sln_printf("\r> %s", wbuf);
+ sln_flush();
recv_complete_line = 0;
strcpy(buf, "");
}
if (!strncmp(buf, "200", 3)) {
strcpy(last_paged, touser);
}
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
/* new server -- use extended paging */
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
- if (make_message(temp, touser, 0, 0, 0) != 0) {
- printf("No message sent.\n");
+ if (client_make_message(temp, touser, 0, 0, 0, NULL) != 0) {
+ scr_printf("No message sent.\n");
return;
}
pagefp = fopen(temp, "r");
}
fclose(pagefp);
serv_puts("000");
- printf("Message sent.\n");
+ scr_printf("Message sent.\n");
} else {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
}
}
serv_puts("DEXP 2");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
+ return;
+ }
+ qstate = atoi(&buf[4]);
+ if (qstate == 0)
+ qstate = 1;
+ else
+ qstate = 0;
+ snprintf(buf, sizeof buf, "DEXP %d", qstate);
+ serv_puts(buf);
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ scr_printf("%s\n", &buf[4]);
+ return;
+ }
+ qstate = atoi(&buf[4]);
+ if (qstate) {
+ scr_printf("Quiet mode enabled (no other users may page you)\n");
+ } else {
+ scr_printf("Quiet mode disabled (other users may page you)\n");
+ }
+}
+
+
+void stealth_mode(void)
+{
+ int qstate;
+ char buf[SIZ];
+
+ serv_puts("STEL 2");
+ serv_gets(buf);
+ if (buf[0] != '2') {
+ scr_printf("%s\n", &buf[4]);
return;
}
qstate = atoi(&buf[4]);
qstate = 1;
else
qstate = 0;
- sprintf(buf, "DEXP %d", qstate);
+ snprintf(buf, sizeof buf, "STEL %d", qstate);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
qstate = atoi(&buf[4]);
if (qstate) {
- printf("Quiet mode enabled (no other users may page you)\n");
+ scr_printf("Stealth mode enabled (you are invisible)\n");
} else {
- printf("Quiet mode disabled (other users may page you)\n");
+ scr_printf("Stealth mode disabled (you are listed as online)\n");
}
}