$Log$
+ Revision 590.72 2002/01/19 09:59:08 error
+ * Full-screen curses support for Citadel text client
+
Revision 590.71 2002/01/17 20:11:05 nbryant
remove lock.c/lock.h; don't need them for what i was planning after all
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
client_crypto.c commands.c config.c control.c $(DATABASE) \
dynloader.c file_ops.c housekeeping.c ipc_c_tcp.c locate_host.c \
logging.c messages.c msgbase.c msgform.c \
- netsetup.c policy.c readlog.c migratenet.c \
+ netsetup.c policy.c readlog.c migratenet.c screen.c \
room_ops.c rooms.c routines.c routines2.c serv_chat.c serv_crypto.c \
serv_info.c serv_test.c setup.c snprintf.c stats.c serv_vcard.c \
support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
#
citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
- routines2$(CX) messages$(CX) \
+ routines2$(CX) messages$(CX) screen$(CX) \
client_passwords$(CX) md5$(CX) client_crypto$(CX) \
commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) $(LIBOBJS)
$(CC) ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
- routines2$(CX) messages$(CX) \
+ routines2$(CX) messages$(CX) screen$(CX) \
commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) \
client_passwords$(CX) md5$(CX) client_crypto$(CX) \
- $(LIBOBJS) $(LDFLAGS) -o citadel $(NETLIBS) $(SSL_LIBS) $(CLIENT_PTLIBS)
+ $(LIBOBJS) $(LDFLAGS) -o citadel $(CURSES) $(NETLIBS) $(SSL_LIBS) $(CLIENT_PTLIBS)
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $<
/* Define if you have OpenSSL. */
#undef HAVE_OPENSSL
+
+/* Define if curses implementation has vw_printw */
+#undef VW_PRINTW_IN_CURSES
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
#include "md5.h"
* now clean up various things
*/
+ screen_delete();
+
unlink(temp);
unlink(temp2);
nukedir(tempdir);
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '1') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
fmout(screenwidth, NULL,
express_msgs = 1;
}
if (!strncmp(aaa, "54", 2)) {
- printf("Wrong password.\n");
+ scr_printf("Wrong password.\n");
return;
}
/*
}
}
if (strlen(bbb) == 0) {
- printf("No room '%s'.\n", towhere);
+ scr_printf("No room '%s'.\n", towhere);
return;
}
snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
express_msgs = 1;
}
if (aaa[0] != '2') {
- printf("%s\n", aaa);
+ scr_printf("%s\n", aaa);
return;
}
extract(room_name, &aaa[4], 0);
if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
if (floorlist[(int) curr_floor][0] == 0)
load_floorlist();
- printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
+ scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
}
if (display_name == 1) {
color(BRIGHT_WHITE);
- printf("%s ", room_name);
+ scr_printf("%s ", room_name);
color(DIM_WHITE);
- printf("- ");
+ scr_printf("- ");
}
if (display_name != 2) {
color(BRIGHT_YELLOW);
- printf("%d ", extract_int(&aaa[4], 1));
+ scr_printf("%d ", extract_int(&aaa[4], 1));
color(DIM_WHITE);
- printf("new of ");
+ scr_printf("new of ");
color(BRIGHT_YELLOW);
- printf("%d ", extract_int(&aaa[4], 2));
+ scr_printf("%d ", extract_int(&aaa[4], 2));
color(DIM_WHITE);
- printf("messages.\n");
+ scr_printf("messages.\n");
}
highest_msg_read = extract_int(&aaa[4], 6);
maxmsgnum = extract_int(&aaa[4], 5);
newmailcount = extract_int(&aaa[4], 9);
if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
color(BRIGHT_RED);
- printf("*** You have new mail\n");
+ scr_printf("*** You have new mail\n");
color(DIM_WHITE);
}
oldmailcount = newmailcount;
char buf[SIZ];
struct march *flist, *fptr;
- printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
- fflush(stdout);
+ scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
+ scr_flush();
snprintf(buf, sizeof buf, "LKRA %d", ffloor);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '1') {
- printf("%-72s\n", &buf[4]);
+ scr_printf("%-72s\n", &buf[4]);
return;
}
flist = NULL;
flist = flist->next;
free(fptr);
}
- printf("%-72s\r", "");
+ scr_printf("%-72s\r", "");
}
tofloor = a;
}
if (tofloor < 0) {
- printf("No floor '%s'.\n", towhere);
+ scr_printf("No floor '%s'.\n", towhere);
return;
}
for (mptr = march; mptr != NULL; mptr = mptr->next) {
if (strlen(targ) > 0) {
gf_toroom(targ, mode);
} else {
- printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
+ scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
}
}
{
if (curr_floor == 0) {
- printf("Can't forget this floor.\n");
+ scr_printf("Can't forget this floor.\n");
return;
}
if (floorlist[0][0] == 0)
load_floorlist();
- printf("Are you sure you want to forget all rooms on %s? ",
+ scr_printf("Are you sure you want to forget all rooms on %s? ",
&floorlist[(int) curr_floor][0]);
if (yesno() == 0)
return;
/*
* Figure out the physical screen dimensions, if we can
+ * WARNING: this is now called from a signal handler!
*/
void check_screen_dims(void)
{
unsigned short ypixels; /* pixels */
} xwinsz;
+ if (scr_set_windowsize())
+ return;
+
if (have_xterm) { /* dynamically size screen if on an xterm */
if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
if (xwinsz.height)
snprintf(buf, sizeof buf, "SETP %s", pass1);
serv_puts(buf);
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
return (0);
} else {
- printf("*** They don't match... try again.\n");
+ scr_printf("*** They don't match... try again.\n");
return (1);
}
}
/* Permissions sanity check - don't run citadel setuid/setgid */
if (getuid() != geteuid()) {
- fprintf(stderr, "Please do not run citadel setuid!\n");
+ err_printf("Please do not run citadel setuid!\n");
logoff(3);
} else if (getgid() != getegid()) {
- fprintf(stderr, "Please do not run citadel setgid!\n");
+ err_printf("Please do not run citadel setgid!\n");
logoff(3);
}
signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
arg_encrypt = RC_DEFAULT;
+ arg_screen = RC_DEFAULT;
/*
* Handle command line options as if we were called like /bin/login
arg_encrypt = RC_YES;
argc = shift(argc, argv, a, 1);
}
+ if (!strcmp(argv[a], "-s")) {
+ arg_screen = RC_NO;
+ argc = shift(argc, argv, a, 1);
+ }
+ if (!strcmp(argv[a], "-S")) {
+ arg_screen = RC_YES;
+ argc = shift(argc, argv, a, 1);
+ }
if (!strcmp(argv[a], "-p")) {
struct stat st;
logoff(3);
}
/*
- printf("Privileges changed to uid %d gid %d\n",
+ scr_printf("Privileges changed to uid %d gid %d\n",
getuid(), getgid());
*/
}
}
}
- printf("Attaching to server... \r");
- fflush(stdout);
- attach_to_server(argc, argv, hostbuf, portbuf);
+ screen_new();
- send_ansi_detect();
+ sln_printf("Attaching to server... \r");
+ sln_flush();
+ attach_to_server(argc, argv, hostbuf, portbuf);
serv_gets(aaa);
if (aaa[0] != '2') {
- printf("%s\n", &aaa[4]);
+ scr_printf("%s\n", &aaa[4]);
logoff(atoi(aaa));
}
get_serv_info(telnet_client_host);
- look_for_ansi();
- cls(0);
- color(7);
-
if (!starttls()) {
- printf("Session will not be encrypted.\n");
+ sln_printf("Session will not be encrypted.\n");
}
- printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
+ scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
serv_info.serv_bbs_city);
screenwidth = 80; /* default screen dimensions */
screenheight = 24;
- printf(" pause next stop\n");
- printf(" ctrl-s ctrl-o ctrl-c\n\n");
+ scr_printf(" pause next stop\n");
+ scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
formout("hello"); /* print the opening greeting */
- printf("\n");
+ scr_printf("\n");
GSTA: /* See if we have a username and password on disk */
if (rc_remember_passwords) {
}
strproc(fullname);
if (!strcasecmp(fullname, "new")) { /* just in case */
- printf("Please enter the name you wish to log in with.\n");
+ scr_printf("Please enter the name you wish to log in with.\n");
}
} while (
(!strcasecmp(fullname, "bbs"))
fullname, password);
goto PWOK;
}
- printf("<< wrong password >>\n");
+ scr_printf("<< wrong password >>\n");
if (strlen(rc_password) > 0)
logoff(0);
goto GSTA;
NEWUSR: if (strlen(rc_password) == 0) {
- printf("No record. Enter as new user? ");
+ scr_printf("No record. Enter as new user? ");
if (yesno() == 0)
goto GSTA;
}
serv_puts(aaa);
serv_gets(aaa);
if (aaa[0] != '2') {
- printf("%s\n", aaa);
+ scr_printf("%s\n", aaa);
goto GSTA;
}
load_user_info(&aaa[4]);
enable_color = 0;
}
- printf("%s\nAccess level: %d (%s)\n"
+ scr_printf("%s\nAccess level: %d (%s)\n"
"User #%ld / Login #%d",
fullname, axlevel, axdefs[(int) axlevel],
usernum, timescalled);
if (lastcall > 0L) {
- printf(" / Last login: %s\n",
+ scr_printf(" / Last login: %s\n",
asctime(localtime(&lastcall)) );
}
- printf("\n");
+ scr_printf("\n");
serv_puts("CHEK");
serv_gets(aaa);
if (b > 0) {
color(BRIGHT_RED);
if (b == 1)
- printf("*** You have a new private message in Mail>\n");
+ scr_printf("*** You have a new private message in Mail>\n");
if (b > 1)
- printf("*** You have %d new private messages in Mail>\n", b);
+ scr_printf("*** You have %d new private messages in Mail>\n", b);
color(DIM_WHITE);
}
if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
- printf("*** Users need validation\n");
+ scr_printf("*** Users need validation\n");
}
if (extract_int(&aaa[4], 1) > 0) {
- printf("*** Please register.\n");
+ scr_printf("*** Please register.\n");
formout("register");
entregis();
}
serv_puts(bbb);
serv_gets(aaa);
if (strncmp("200", aaa, 3))
- printf("\n%s\n", aaa);
+ scr_printf("\n%s\n", aaa);
else
entmsg(0, 0);
break;
serv_puts(bbb);
serv_gets(aaa);
if (strncmp("200", aaa, 3))
- printf("\n%s\n", aaa);
+ scr_printf("\n%s\n", aaa);
break;
case 76:
enternew("hostname", aaa, 25);
serv_puts(bbb);
serv_gets(aaa);
if (strncmp("200", aaa, 3))
- printf("\n%s\n", aaa);
+ scr_printf("\n%s\n", aaa);
break;
case 77:
enternew("username", aaa, 32);
serv_puts(bbb);
serv_gets(aaa);
if (strncmp("200", aaa, 3))
- printf("\n%s\n", aaa);
+ scr_printf("\n%s\n", aaa);
break;
case 35:
break;
case 15:
- printf("Are you sure (y/n)? ");
+ scr_printf("Are you sure (y/n)? ");
if (yesno() == 1) {
updatels();
a = 0;
break;
case 85:
- printf("All users will be disconnected! "
+ scr_printf("All users will be disconnected! "
"Really terminate the server? ");
if (yesno() == 1) {
serv_puts("DOWN");
serv_gets(aaa);
- printf("%s\n", &aaa[4]);
+ scr_printf("%s\n", &aaa[4]);
if (aaa[0]=='2') {
updatels();
a = 0;
break;
case 86:
- printf("Do you really want to schedule a "
+ scr_printf("Do you really want to schedule a "
"server shutdown? ");
if (yesno() == 1) {
serv_puts("SCDN 1");
serv_gets(aaa);
if (aaa[0]=='2') {
if (atoi(&aaa[4])) {
- printf(
+ scr_printf(
"The Citadel server will terminate when all users are logged off.\n"
);
}
else {
- printf(
+ scr_printf(
"The Citadel server will not terminate.\n"
);
}
case 2:
if (server_is_local) {
+ screen_reset();
sttybbs(SB_RESTORE);
snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
"exec ./subsystem %ld %d %d", fullname,
usernum, screenwidth, axlevel);
ka_system(aaa);
sttybbs(SB_NO_INTR);
+ screen_set();
} else {
- printf("*** Can't run doors when server is not local.\n");
+ scr_printf("*** Can't run doors when server is not local.\n");
}
break;
case 8:
knrooms(floor_mode);
- printf("\n");
+ scr_printf("\n");
break;
case 68:
knrooms(2);
- printf("\n");
+ scr_printf("\n");
break;
case 69:
case 19:
listzrooms();
- printf("\n");
+ scr_printf("\n");
break;
case 51:
} /* end switch */
} while (termn8 == 0);
-TERMN8: printf("%s logged out.\n", fullname);
+TERMN8: scr_printf("%s logged out.\n", fullname);
while (march != NULL) {
remove_march(march->march_name, 0);
}
if (mcmd == 30) {
- printf("\n\nType 'off' to disconnect, or next user...\n");
+ sln_printf("\n\nType 'off' to disconnect, or next user...\n");
}
snprintf(aaa, sizeof aaa, "LOUT");
serv_puts(aaa);
serv_gets(aaa);
+ screen_delete();
+ sttybbs(SB_RESTORE);
if ((mcmd == 29) || (mcmd == 15)) {
formout("goodbye");
logoff(0);
# systems on the same machine as the client.
encrypt=default
+# Set FULLSCREN to yes to (attempt to) use full-screen curses mode.
+# This mode presents a status line and a few other niceties. Some
+# people might not like this, so you can turn it off here or with the
+# -s command line option. The default is to use full screen if the
+# terminal supports it.
+#fullscreen=yes
+
# Set EDITOR to the name of an external editor to be used for entering
# messages. If you want the external editor to be used by default, be sure
# to reflect this in the command set below.
# systems, where many messages may be posted while reading. Users
# accustomed to D.O.C. or its variants will want to set this option.
#
-alternate_semantics=no
+alternate_semantics=yes
# COMMAND SET CONFIGURATION
extern char rc_floor_mode;
extern char rc_encrypt; /* from the citadel.rc file */
extern char arg_encrypt; /* from the command line */
+extern char rc_screen;
+extern char arg_screen;
extern char rc_alt_semantics;
extern char express_msgs;
void logoff(int code);
#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("> ");
+ scr_printf("> ");
send_complete_line = 0;
recv_complete_line = 0;
} else if ((ch == 8) || (ch == 127)) {
if (strlen(wbuf) > 0) {
wbuf[strlen(wbuf) - 1] = 0;
- printf("%c %c", 8, 8);
+ scr_printf("%c %c", 8, 8);
}
} else {
putc(ch, stdout);
}
}
if (recv_complete_line) {
- printf("\r%79s\r", "");
+ scr_printf("\r%79s\r", "");
if (!strcmp(buf, "000")) {
color(BRIGHT_WHITE);
- printf("Exiting chat mode\n");
+ scr_printf("Exiting chat mode\n");
- fflush(stdout);
+ scr_flush();
set_keepalives(KA_YES);
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", "");
+ scr_printf("\r%79s\n", "");
strcpy(last_user, c_user);
}
- printf("\r%s\n", buf);
+ scr_printf("\r%s\n", buf);
fflush(stdout);
}
}
color(BRIGHT_YELLOW);
- printf("> %s", wbuf);
+ scr_printf("> %s", wbuf);
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 (client_make_message(temp, touser, 0, 0, 0) != 0) {
- printf("No message sent.\n");
+ 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]);
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("Quiet mode enabled (no other users may page you)\n");
} else {
- printf("Quiet mode disabled (other users may page you)\n");
+ scr_printf("Quiet mode disabled (other users may page you)\n");
}
}
#include <sys/types.h>
#include "citadel.h"
#include "client_crypto.h"
+#include "screen.h"
#ifdef HAVE_OPENSSL
SSL *ssl;
while (len < bytes) {
if (SSL_want_read(ssl)) {
if ((SSL_write(ssl, junk, 0)) < 1) {
- fprintf(stderr, "SSL_write in serv_read:\n");
+ err_printf("SSL_write in serv_read:\n");
ERR_print_errors_fp(stderr);
}
}
serv_read(&buf[len], bytes - len);
return;
}
- fprintf(stderr, "SSL_read in serv_read:\n");
+ err_printf("SSL_read in serv_read:\n");
ERR_print_errors_fp(stderr);
connection_died();
return;
while (bytes_written < nbytes) {
if (SSL_want_write(ssl)) {
if ((SSL_read(ssl, junk, 0)) < 1) {
- fprintf(stderr, "SSL_read in serv_write:\n");
+ err_printf("SSL_read in serv_write:\n");
ERR_print_errors_fp(stderr);
}
}
nbytes - bytes_written);
return;
}
- fprintf(stderr, "SSL_write in serv_write:\n");
+ err_printf("SSL_write in serv_write:\n");
ERR_print_errors_fp(stderr);
connection_died();
return;
ssl_method = SSLv23_client_method();
ssl_ctx = SSL_CTX_new(ssl_method);
if (!ssl_ctx) {
- fprintf(stderr, "SSL_CTX_new failed: %s\n",
+ err_printf("SSL_CTX_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
/* Any reasonable cipher we can get */
if (!(SSL_CTX_set_cipher_list(ssl_ctx, CIT_CIPHERS))) {
- fprintf(stderr, "No ciphers available for encryption\n");
+ err_printf("No ciphers available for encryption\n");
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return 0;
/* Load DH parameters into the context */
dh = DH_new();
if (!dh) {
- fprintf(stderr, "Can't allocate a DH object: %s\n",
+ err_printf("Can't allocate a DH object: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
if (!(BN_hex2bn(&(dh->p), DH_P))) {
- fprintf(stderr, "Can't assign DH_P: %s\n",
+ err_printf("Can't assign DH_P: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
if (!(BN_hex2bn(&(dh->g), DH_G))) {
- fprintf(stderr, "Can't assign DH_G: %s\n",
+ err_printf("Can't assign DH_G: %s\n",
ERR_reason_error_string(ERR_get_error()));
return 0;
}
/* New SSL object */
ssl = SSL_new(ssl_ctx);
if (!ssl) {
- fprintf(stderr, "SSL_new failed: %s\n",
+ err_printf("SSL_new failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
SSL_set_session_id_context(ssl, "Citadel/UX SID", 14);
#endif
if (!RAND_status()) {
- fprintf(stderr, "PRNG not properly seeded\n");
+ err_printf("PRNG not properly seeded\n");
return 0;
}
/* Associate network connection with SSL object */
if (SSL_set_fd(ssl, serv_sock) < 1) {
- fprintf(stderr, "SSL_set_fd failed: %s\n",
+ err_printf("SSL_set_fd failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
return 0;
}
- printf("Requesting encryption...\r");
- fflush(stdout);
+ sln_printf("Requesting encryption...\r");
+ sln_flush();
/* Ready to start SSL/TLS */
serv_puts("STLS");
serv_gets(buf);
if (buf[0] != '2') {
- fprintf(stderr, "Server can't start TLS: %s\n", &buf[4]);
+ err_printf("Server can't start TLS: %s\n", &buf[4]);
return 0;
}
/* Do SSL/TLS handshake */
if ((a = SSL_connect(ssl)) < 1) {
- fprintf(stderr, "SSL_connect failed: %s\n",
+ err_printf("SSL_connect failed: %s\n",
ERR_reason_error_string(ERR_get_error()));
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
int bits, alg_bits;
bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), &alg_bits);
- printf("Encrypting with %s cipher %s (%d of %d bits)\n",
+ sln_printf("Encrypting with %s cipher %s (%d of %d bits)\n",
SSL_CIPHER_get_version(SSL_get_current_cipher(ssl)),
SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)),
bits, alg_bits);
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
struct citcmd {
struct citcmd *next;
va_end(arg_ptr);
for (i=0; i<strlen(buf); ++i) {
- putc(buf[i], stdout);
+ scr_putc(buf[i]);
if (buf[i]==10) {
++lines_printed;
lines_printed = checkpagin(lines_printed,
return;
if (rc_exp_beep) {
- putc(7, stdout);
+ scr_putc(7);
}
if (strlen(rc_exp_cmd) == 0) {
color(BRIGHT_RED);
- printf("\r---");
+ scr_printf("\r---");
}
while (express_msgs != 0) {
}
}
/* fall back to built-in express message display */
- printf("\n");
+ scr_printf("\n");
lines_printed++;
/* Header derived from flags */
if (flags & 2)
- printf("Please log off now, as requested ");
+ scr_printf("Please log off now, as requested ");
else if (flags & 1)
- printf("Broadcast message ");
+ scr_printf("Broadcast message ");
else if (flags & 4)
- printf("Chat request ");
+ scr_printf("Chat request ");
else
- printf("Message ");
+ scr_printf("Message ");
/* Timestamp. Can this be improved? */
if (stamp->tm_hour == 0 || stamp->tm_hour == 12)/* 12am/12pm */
- printf("at 12:%02d%cm", stamp->tm_min,
+ scr_printf("at 12:%02d%cm", stamp->tm_min,
stamp->tm_hour ? 'p' : 'a');
else if (stamp->tm_hour > 12) /* pm */
- printf("at %d:%02dpm",
+ scr_printf("at %d:%02dpm",
stamp->tm_hour - 12, stamp->tm_min);
else /* am */
- printf("at %d:%02dam", stamp->tm_hour, stamp->tm_min);
+ scr_printf("at %d:%02dam", stamp->tm_hour, stamp->tm_min);
/* Sender */
- printf(" from %s", sender);
+ scr_printf(" from %s", sender);
/* Remote node, if any */
if (strncmp(serv_info.serv_nodename, node, 32))
- printf(" @%s", node);
+ scr_printf(" @%s", node);
- printf(":\n");
+ scr_printf(":\n");
lines_printed++;
fmout(screenwidth, NULL, 1, screenheight, -1, 0);
}
- printf("\n---\n");
+ scr_printf("\n---\n");
color(BRIGHT_WHITE);
if (buf[3] == '*') {
express_msgs = 1;
if (ok_to_interrupt == 1) {
- printf("\r%64s\r", "");
+ scr_printf("\r%64s\r", "");
print_express();
- printf("%s%c ", room_name,
+ scr_printf("%s%c ", room_name,
room_prompt(room_flags));
- fflush(stdout);
+ scr_flush();
}
}
}
return;
/* Do a space-backspace to keep telnet sessions from idling out */
- printf(" %c", 8);
- fflush(stdout);
+ scr_printf(" %c", 8);
+ scr_flush();
#ifdef THREADED_CLIENT
if (async_ka_enabled)
fd_set rfds;
struct timeval tv;
time_t start_time, now;
- char inbuf[2];
- fflush(stdout);
+ scr_flush();
lines_printed = 0;
time(&start_time);
/* At this point, there's input, so fetch it.
* (There's a hole in the bucket...)
*/
- read(0, inbuf, 1);
- a = inbuf[0];
+ a = scr_getc();
if (a == 127)
a = 8;
if (a > 126)
a = 0;
- if (a == 10)
- a = 13;
- if (((a != 4) && (a != 13) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
+ if (a == 13)
+ a = 10;
+ if (((a != 4) && (a != 10) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
&& ((a < 32) || (a > 126)))
a = 0;
} while (a == 0);
a = inkey();
a = tolower(a);
if (a == 'y') {
- printf("Yes\n");
+ scr_printf("Yes\n");
return (1);
}
if (a == 'n') {
- printf("No\n");
+ scr_printf("No\n");
return (0);
}
}
while (1) {
a = inkey();
a = tolower(a);
- if (a == 13)
+ if (a == 10)
a = (d ? 'y' : 'n');
if (a == 'y') {
- printf("Yes\n");
+ scr_printf("Yes\n");
return (1);
}
if (a == 'n') {
- printf("No\n");
+ scr_printf("No\n");
return (0);
}
}
a = (a & 127);
if ((a == 8) && (strlen(string) == 0))
goto GLA;
- if ((a != 13) && (a != 8) && (strlen(string) == lim))
+ if ((a != 10) && (a != 8) && (strlen(string) == lim))
goto GLA;
if ((a == 8) && (string[0] != 0)) {
string[strlen(string) - 1] = 0;
- putc(8, stdout);
- putc(32, stdout);
- putc(8, stdout);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
goto GLA;
}
- if ((a == 13) || (a == 10)) {
- putc(13, stdout);
- putc(10, stdout);
+ if ((a == 10)) {
+ scr_putc(10);
async_ka_end();
return;
}
string[b] = a;
string[b + 1] = 0;
if (flag == 0)
- putc(a, stdout);
+ scr_putc(a);
if (flag == 1)
- putc('*', stdout);
+ scr_putc('*');
goto GLA;
}
char buf[128];
print_express();
color(DIM_WHITE);
- printf("%s ", prompt);
+ scr_printf("%s ", prompt);
color(DIM_MAGENTA);
- printf("[");
+ scr_printf("[");
color(BRIGHT_MAGENTA);
- printf("%s", str);
+ scr_printf("%s", str);
color(DIM_MAGENTA);
- printf("]");
+ scr_printf("]");
color(DIM_WHITE);
- printf(": ");
+ scr_printf(": ");
color(BRIGHT_CYAN);
getline(buf, len);
if (buf[0] != 0)
int r;
color(DIM_WHITE);
- printf("%s ", prompt);
+ scr_printf("%s ", prompt);
color(DIM_MAGENTA);
- printf(" [");
+ scr_printf(" [");
color(BRIGHT_MAGENTA);
- printf("%s", (prev_val ? "Yes" : "No"));
+ scr_printf("%s", (prev_val ? "Yes" : "No"));
color(DIM_MAGENTA);
- printf("]: ");
+ scr_printf("]: ");
color(BRIGHT_CYAN);
r = (yesno_d(prev_val));
color(DIM_WHITE);
i = imin - 1;
}
if (i < imin)
- printf("*** Must be no less than %d.\n", imin);
+ scr_printf("*** Must be no less than %d.\n", imin);
if (i > imax)
- printf("*** Must be no more than %d.\n", imax);
+ scr_printf("*** Must be no more than %d.\n", imax);
} while ((i < imin) || (i > imax));
return (i);
}
void newprompt(char *prompt, char *str, int len)
{
color(BRIGHT_MAGENTA);
- printf("%s", prompt);
+ scr_printf("%s", prompt);
color(DIM_MAGENTA);
getline(str, len);
color(DIM_WHITE);
rc_ansi_color = 0;
strcpy(rc_url_cmd, "");
rc_encrypt = RC_DEFAULT;
+ rc_screen = RC_DEFAULT;
rc_alt_semantics = 0;
/* now try to open the citadel.rc file */
rc_encrypt = RC_DEFAULT;
}
+ if (!strncasecmp(buf, "fullscreen=", 11)) {
+ if (!strcasecmp(&buf[11], "yes"))
+ rc_screen = RC_YES;
+ else if (!strcasecmp(&buf[11], "no"))
+ rc_screen = RC_NO;
+ }
+
if (!strncasecmp(buf, "editor=", 7))
strcpy(editor_path, &buf[7]);
/* now the room prompt... */
ok_to_interrupt = 1;
color(BRIGHT_WHITE);
- printf("\n%s", room_name);
+ scr_printf("\n%s", room_name);
color(DIM_WHITE);
- printf("%c ", room_prompt(room_flags));
- fflush(stdout);
+ scr_printf("%c ", room_prompt(room_flags));
+ scr_flush();
while (1) {
ch = inkey();
if (cptr->c_cmdnum == this_lazy_cmd) {
for (a = 0; a < 5; ++a)
if (cptr->c_keys[a][0] != 0)
- printf("%s ", cmd_expand(
+ scr_printf("%s ", cmd_expand(
cptr->c_keys[a], 0));
- printf("\n");
+ scr_printf("\n");
return (this_lazy_cmd);
}
}
- printf("\n");
+ scr_printf("\n");
return (this_lazy_cmd);
}
/* Otherwise, process the command */
for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
if (cmdmatch(cmdbuf, cptr, cmdpos + 1)) {
- printf("%s", cmd_expand(cptr->c_keys[cmdpos], 0));
+ scr_printf("%s", cmd_expand(cptr->c_keys[cmdpos], 0));
cmdspaces[cmdpos] = strlen(
cmd_expand(cptr->c_keys[cmdpos], 0));
if (cmdpos < 4)
if ((cptr->c_keys[cmdpos + 1]) != 0)
- putc(' ', stdout);
+ scr_putc(' ');
++cmdpos;
}
}
if (requires_string(cptr, cmdpos)) {
getline(argbuf, 32);
} else {
- printf("\n");
+ scr_printf("\n");
}
/* If this command is one that changes rooms,
{ /* BSD version of sttybbs() */
struct sgttyb live;
static struct sgttyb saved_settings;
+ static int last_cmd = 0;
+
+ if (cmd == SB_LAST)
+ cmd = last_cmd;
+ else
+ last_cmd = cmd;
if ((cmd == 0) || (cmd == 1)) {
gtty(0, &live);
if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
a = 32;
if (((old == 13) || (old == 10)) && (isspace(real))) {
- printf("\n");
+ scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
c = 1;
if (a > 32) {
if (((strlen(aaa) + c) > (width - 5)) && (strlen(aaa) > (width - 5))) {
- printf("\n%s", aaa);
+ scr_printf("\n%s", aaa);
c = strlen(aaa);
aaa[0] = 0;
++lines_printed;
if (a == 32) {
if ((strlen(aaa) + c) > (width - 5)) {
c = 1;
- printf("\n");
+ scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
}
- printf("%s ", aaa);
+ scr_printf("%s ", aaa);
++c;
c = c + strlen(aaa);
strcpy(aaa, "");
goto FMTA;
}
if ((a == 13) || (a == 10)) {
- printf("%s\n", aaa);
+ scr_printf("%s\n", aaa);
c = 1;
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
serv_gets(aaa);
} while (strcmp(aaa, "000"));
-FMTEND: printf("\n");
+FMTEND: scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, height);
return (sigcaught);
current_color = colornum;
if (enable_color) {
+#ifdef HAVE_CURSES_H
+ if (scr_color(colornum))
+ return;
+#endif
/* When switching to dim white, actually output an 'original
* pair' sequence -- this looks better on black-on-white
* terminals.
printf("\033[0m");
is_bold = 0;
}
- fflush(stdout);
+ scr_flush();
}
}
{
if (enable_color) {
printf("\033[4%dm\033[2J\033[H\033[0m", colornum);
- fflush(stdout);
+ scr_flush();
}
}
{
if (rc_ansi_color == 2) {
printf("\033[c");
- fflush(stdout);
+ scr_flush();
time(&AnsiDetect);
}
}
color(DIM_WHITE);
for (i=0; i<strlen(buf); ++i) {
if (buf[i]=='<') {
- putc(buf[i], stdout);
+ scr_putc(buf[i]);
color(BRIGHT_MAGENTA);
} else {
if (buf[i]=='>') {
color(DIM_WHITE);
}
- putc(buf[i], stdout);
+ scr_putc(buf[i]);
}
}
color(DIM_WHITE);
while (1) {
if (display_prompt) {
if (do_prompt) {
- printf("%s ", menuprompt);
+ scr_printf("%s ", menuprompt);
}
else {
for (i=0; i<choices; ++i) {
extract(buf, menustring, i);
keyopt(buf);
- printf(" ");
+ scr_printf(" ");
}
}
- printf(" -> ");
+ scr_printf(" -> ");
display_prompt = 0;
}
ch = lkey();
if ( (do_prompt) && (ch=='?') ) {
- printf("\rOne of... ");
- printf(" \n");
+ scr_printf("\rOne of... ");
+ scr_printf(" \n");
for (i=0; i<choices; ++i) {
extract(buf, menustring, i);
- printf(" ");
+ scr_printf(" ");
keyopt(buf);
- printf("\n");
+ scr_printf("\n");
}
- printf("\n");
+ scr_printf("\n");
display_prompt = 1;
}
&& (buf[c+1]=='>') ) {
for (a=0; a<strlen(buf); ++a) {
if ( (a!=(c-1)) && (a!=(c+1))) {
- putc(buf[a], stdout);
+ scr_putc(buf[a]);
}
}
- printf("\n\n");
+ scr_printf("\n\n");
return ch;
}
}
AC_SEARCH_LIBS(initscr, [curses ncurses])
CURSES=$LIBS
LIBS=$save_LIBS
+SCURS=`echo $CURSES | sed -e s/-l//`
+AC_CHECK_LIB($SCURS, vw_printw, AC_DEFINE(VW_PRINTW_IN_CURSES))
dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
dnl which the -pthread flag takes care of this.)
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#ifdef CIT_CLIENT
+#include "screen.h"
+#else
+int err_printf(char *fmt, ...);
+int err_printf(char *fmt, ...)
+{
+ va_list ap;
+ int retval;
+ va_start(ap, fmt);
+ retval = fprintf(stderr, fmt, ap);
+ va_end(ap);
+ return retval;
+}
+#endif
/*
* If server_is_local is set to nonzero, the client assumes that it is running
void connection_died(void) {
- fprintf(stderr, "\r"
- "Your connection to this Citadel server is broken.\n"
+ err_printf("\rYour connection to this Citadel server is broken.\n"
"Please re-connect and log in again.\n");
logoff(3);
}
void timeout(int signum)
{
- printf("\rConnection timed out.\n");
+ err_printf("\rConnection timed out.\n");
logoff(3);
}
if (phe) {
memcpy(&sin.sin_addr, phe->h_addr, phe->h_length);
} else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
- fprintf(stderr, "Can't get %s host entry: %s\n",
+ err_printf("Can't get %s host entry: %s\n",
host, strerror(errno));
logoff(3);
}
if ((ppe = getprotobyname(protocol)) == 0) {
- fprintf(stderr, "Can't get %s protocol entry: %s\n",
+ err_printf("Can't get %s protocol entry: %s\n",
protocol, strerror(errno));
logoff(3);
}
s = socket(PF_INET, type, ppe->p_proto);
if (s < 0) {
- fprintf(stderr, "Can't create socket: %s\n", strerror(errno));
+ err_printf("Can't create socket: %s\n", strerror(errno));
logoff(3);
}
signal(SIGALRM, timeout);
alarm(30);
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- fprintf(stderr, "can't connect to %s.%s: %s\n",
+ err_printf("can't connect to %s.%s: %s\n",
host, service, strerror(errno));
logoff(3);
}
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
- fprintf(stderr, "Can't create socket: %s\n",
- strerror(errno));
+ err_printf("Can't create socket: %s\n", strerror(errno));
logoff(3);
}
if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- fprintf(stderr, "can't connect: %s\n",
- strerror(errno));
+ err_printf("can't connect: %s\n", strerror(errno));
logoff(3);
}
*/
void serv_puts(char *buf)
{
- /* printf("< %s\n", buf); */
+ /* err_printf("< %s\n", buf); */
serv_write(buf, strlen(buf));
serv_write("\n", 1);
}
strcpy(citport, argv[a]);
}
else {
- fprintf(stderr,"%s: usage: ",argv[0]);
- fprintf(stderr,"%s [host] [port] ",argv[0]);
+ err_printf("%s: usage: ",argv[0]);
+ err_printf("%s [host] [port] ",argv[0]);
logoff(2);
}
}
int i;
MD5Init(&ctx);
-// printf("MD5@@: Adding nonce: %s\n", nonce);
+// scr_printf("MD5@@: Adding nonce: %s\n", nonce);
MD5Update(&ctx, (u_char*)nonce, strlen(nonce));
-// printf("MD5@@: Adding password %s\n", realpass);
+// scr_printf("MD5@@: Adding password %s\n", realpass);
MD5Update(&ctx, (u_char*)realpass, strlen(realpass));
MD5Final(rawdigest, &ctx);
for (i=0; i<MD5_DIGEST_LEN; i++)
buffer[i*2] = tolower(buffer[i*2]);
buffer[(i*2)+1] = tolower(buffer[(i*2)+1]);
}
-// printf("MD5@@: Result is %s\n", buffer);
+// scr_printf("MD5@@: Result is %s\n", buffer);
return buffer;
}
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
#define MAXWORDBUF SIZ
#define MAXMSGS 512
/******* new ***********/
if ((a > 32) && (a < 127) && (prev == 13)) {
add_word(textlist, "\n");
- printf(" ");
+ scr_printf(" ");
}
/***********************/
if (a == 8) {
if (strlen(wordbuf) > 0) {
wordbuf[strlen(wordbuf) - 1] = 0;
- putc(8, stdout);
- putc(32, stdout);
- putc(8, stdout);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
}
} else if (a == 13) {
- printf("\n");
+ scr_printf("\n");
if (strlen(wordbuf) == 0)
finished = 1;
else {
strcpy(wordbuf, "");
}
} else {
- putc(a, stdout);
+ scr_putc(a);
wordbuf[strlen(wordbuf) + 1] = 0;
wordbuf[strlen(wordbuf)] = a;
}
b = 0;
}
for (b = 0; b < strlen(wordbuf); ++b) {
- putc(8, stdout);
- putc(32, stdout);
- putc(8, stdout);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
}
- printf("\n%s", wordbuf);
+ scr_printf("\n%s", wordbuf);
} else {
add_word(textlist, wordbuf);
strcpy(wordbuf, "");
- printf("\n");
+ scr_printf("\n");
}
}
prev = a;
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '1') {
- printf("*** msg #%ld: %s\n", num, buf);
+ err_printf("*** msg #%ld: %s\n", num, buf);
++lines_printed;
lines_printed =
checkpagin(lines_printed, pagin, screenheight);
strcpy(node, "");
strcpy(rfca, "");
- printf("\n");
+ scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, screenheight);
- printf(" ");
+ scr_printf(" ");
if (pagin == 1) {
color(BRIGHT_CYAN);
}
if (pagin == 2) {
while (serv_gets(buf), strcmp(buf, "000")) {
if (buf[4] == '=') {
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
++lines_printed;
lines_printed =
checkpagin(lines_printed,
if ((!strncasecmp(buf, "msgn=", 5))
&& (rc_display_message_numbers)) {
color(DIM_WHITE);
- printf("[");
+ scr_printf("[");
color(BRIGHT_WHITE);
- printf("#%s", &buf[5]);
+ scr_printf("#%s", &buf[5]);
color(DIM_WHITE);
- printf("] ");
+ scr_printf("] ");
}
if (!strncasecmp(buf, "from=", 5)) {
color(DIM_WHITE);
- printf("from ");
+ scr_printf("from ");
color(BRIGHT_CYAN);
- printf("%s ", &buf[5]);
+ scr_printf("%s ", &buf[5]);
}
if (!strncasecmp(buf, "subj=", 5))
strcpy(m_subject, &buf[5]);
if (!strncasecmp(buf, "rfca=", 5)) {
safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
color(DIM_WHITE);
- printf("<");
+ scr_printf("<");
color(BRIGHT_BLUE);
- printf("%s", &buf[5]);
+ scr_printf("%s", &buf[5]);
color(DIM_WHITE);
- printf("> ");
+ scr_printf("> ");
}
if ((!strncasecmp(buf, "hnod=", 5))
&& (strcasecmp(&buf[5], serv_info.serv_humannode))
&& (strlen(rfca) == 0)) {
color(DIM_WHITE);
- printf("(");
+ scr_printf("(");
color(BRIGHT_WHITE);
- printf("%s", &buf[5]);
+ scr_printf("%s", &buf[5]);
color(DIM_WHITE);
- printf(") ");
+ scr_printf(") ");
}
if ((!strncasecmp(buf, "room=", 5))
&& (strcasecmp(&buf[5], room_name))
&& (strlen(rfca) == 0)) {
color(DIM_WHITE);
- printf("in ");
+ scr_printf("in ");
color(BRIGHT_MAGENTA);
- printf("%s> ", &buf[5]);
+ scr_printf("%s> ", &buf[5]);
}
if (!strncasecmp(buf, "node=", 5)) {
{
if (strlen(rfca) == 0) {
color(DIM_WHITE);
- printf("@");
+ scr_printf("@");
color(BRIGHT_YELLOW);
- printf("%s ", &buf[5]);
+ scr_printf("%s ", &buf[5]);
}
}
}
if (!strncasecmp(buf, "rcpt=", 5)) {
color(DIM_WHITE);
- printf("to ");
+ scr_printf("to ");
color(BRIGHT_CYAN);
- printf("%s ", &buf[5]);
+ scr_printf("%s ", &buf[5]);
}
if (!strncasecmp(buf, "time=", 5)) {
fmt_date(now, atol(&buf[5]), 0);
- printf("%s ", now);
+ scr_printf("%s ", now);
}
}
if (nhdr == 1) {
if (!is_room_aide) {
- printf(" ****");
+ scr_printf(" ****");
} else {
- printf(" %s", from);
+ scr_printf(" %s", from);
}
}
- printf("\n");
+ scr_printf("\n");
if (strlen(rfca) > 0) {
strcpy(reply_to, rfca);
lines_printed = checkpagin(lines_printed, pagin, screenheight);
if (strlen(m_subject) > 0) {
- printf("Subject: %s\n", m_subject);
+ scr_printf("Subject: %s\n", m_subject);
++lines_printed;
lines_printed =
checkpagin(lines_printed, pagin, screenheight);
} else {
while (serv_gets(buf), strcmp(buf, "000")) {
if (sigcaught == 0) {
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
lines_printed = lines_printed + 1 +
(strlen(buf) / screenwidth);
lines_printed =
}
fr = sigcaught;
}
- printf("\n");
+ scr_printf("\n");
+ scr_flush();
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, screenheight);
int substitutions = 0;
long msglen = 0L;
- printf("Enter text to be replaced:\n: ");
+ scr_printf("Enter text to be replaced:\n: ");
getline(srch_str, 128);
if (strlen(srch_str) == 0)
return;
- printf("Enter text to replace it with:\n: ");
+ scr_printf("Enter text to replace it with:\n: ");
getline(rplc_str, 128);
fp = fopen(filename, "r+");
wpos = ftell(fp);
fclose(fp);
truncate(filename, wpos);
- printf("<R>eplace made %d substitution(s).\n\n", substitutions);
+ scr_printf("<R>eplace made %d substitution(s).\n\n", substitutions);
}
/*
if (mode == 2)
if (strlen(editor_path) == 0) {
- printf
+ err_printf
("*** No editor available, using built-in editor\n");
mode = 0;
}
" to %s", recipient);
}
}
- printf("%s\n", header);
+ scr_printf("%s\n", header);
beg = 0L;
if (mode == 1) {
- printf("(Press ctrl-d when finished)\n");
+ scr_printf("(Press ctrl-d when finished)\n");
}
if (mode == 0) {
} else {
fp = fopen(filename, "w");
if (fp == NULL) {
- printf("*** Error opening temp file!\n"
+ err_printf("*** Error opening temp file!\n"
" %s: %s\n",
filename, strerror(errno));
return(1);
case 0:
fp = fopen(filename, "r+");
if (fp == NULL) {
- printf("*** Error opening temp file!\n"
+ err_printf("*** Error opening temp file!\n"
" %s: %s\n",
filename, strerror(errno));
return(1);
case 1:
fp = fopen(filename, "a");
if (fp == NULL) {
- printf("*** Error opening temp file!\n"
+ err_printf("*** Error opening temp file!\n"
" %s: %s\n",
filename, strerror(errno));
return(1);
a = 10;
if (a != 4) {
putc(a, fp);
- putc(a, stdout);
+ scr_putc(a);
}
if (a == 10)
- putc(13, stdout);
+ scr_putc(10);
} while (a != 4);
fclose(fp);
break;
cksum = file_checksum(filename);
if (editor_pid == 0) {
chmod(filename, 0600);
+ screen_reset();
sttybbs(SB_RESTORE);
setenv("WINDOW_TITLE", header, 1);
execlp(editor_path, editor_path, filename, NULL);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
sttybbs(0);
+ screen_set();
break;
}
MECR: if (mode == 2) {
if (file_checksum(filename) == cksum) {
- printf("*** Aborted message.\n");
+ err_printf("*** Aborted message.\n");
e_ex_code = 1;
}
if (e_ex_code == 0)
if (b == 's')
goto MEFIN;
if (b == 'p') {
- printf(" %s from %s", datestr, fullname);
+ scr_printf(" %s from %s", datestr, fullname);
if (strlen(recipient) > 0)
- printf(" to %s", recipient);
- printf("\n");
+ scr_printf(" to %s", recipient);
+ scr_printf("\n");
fp = fopen(filename, "r");
if (fp != NULL) {
fmout(screenwidth, fp,
MEFIN: return (0);
-MEABT: printf("Are you sure? ");
+MEABT: scr_printf("Are you sure? ");
if (yesno() == 0) {
goto ME1;
}
}
if ((time(NULL) - lasttick) > 2L) {
- printf(" %3ld%% completed\r",
+ scr_printf(" %3ld%% completed\r",
((ftell(fp) * 100L) / msglen));
- fflush(stdout);
+ scr_flush();
lasttick = time(NULL);
}
}
serv_puts(buf);
- printf(" \r");
- fflush(stdout);
+ scr_printf(" \r");
+ scr_flush();
}
serv_gets(cmd);
if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return (1);
}
if (is_reply) {
strcpy(buf, reply_to);
} else {
- printf("Enter recipient: ");
+ scr_printf("Enter recipient: ");
getline(buf, (SIZ-100) );
if (strlen(buf) == 0)
return (1);
b = 0;
if (room_flags & QR_ANONOPT) {
- printf("Anonymous (Y/N)? ");
+ scr_printf("Anonymous (Y/N)? ");
if (yesno() == 1)
b = 1;
}
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '2') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return (1);
}
}
serv_puts("MSGS LAST|1");
serv_gets(cmd);
if (cmd[0] != '1') {
- printf("%s\n", &cmd[5]);
+ scr_printf("%s\n", &cmd[5]);
} else {
while (serv_gets(cmd), strcmp(cmd, "000")) {
msg_arr[num_msgs++] = atol(cmd);
unlink(temp);
if (fp == NULL) {
- printf("*** Internal error while trying to save message!\n"
+ err_printf("*** Internal error while trying to save message!\n"
" %s: %s\n",
temp, strerror(errno));
return(errno);
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '4') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return (1);
}
serv_puts("MSGS NEW");
serv_gets(cmd);
if (cmd[0] != '1') {
- printf("%s\n", &cmd[5]);
+ scr_printf("%s\n", &cmd[5]);
} else {
while (serv_gets(cmd), strcmp(cmd, "000")) {
msg_arr[num_msgs++] = atol(cmd);
}
if (b == 1) {
- printf("*** 1 additional message has been entered "
+ scr_printf("*** 1 additional message has been entered "
"in this room by another user.\n");
}
else if (b > 1) {
- printf("*** %d additional messages have been entered "
+ scr_printf("*** %d additional messages have been entered "
"in this room by other users.\n", b);
}
line = 0;
fgets(buf, 128, qfile);
while (fgets(buf, 128, qfile) != NULL) {
- printf("%2d %s", ++line, buf);
+ scr_printf("%2d %s", ++line, buf);
}
- printf("Begin quoting at [ 1] : ");
+ scr_printf("Begin quoting at [ 1] : ");
getline(buf, 3);
qstart = (buf[0] == 0) ? (1) : atoi(buf);
- printf(" End quoting at [%d] : ", line);
+ scr_printf(" End quoting at [%d] : ", line);
getline(buf, 3);
qend = (buf[0] == 0) ? (line) : atoi(buf);
rewind(qfile);
char cmd[SIZ];
if (num_urls == 0) {
- printf("There were no URL's in the previous message.\n\n");
+ scr_printf("There were no URL's in the previous message.\n\n");
return;
}
for (i = 0; i < num_urls; ++i) {
- printf("%3d %s\n", i + 1, urls[i]);
+ scr_printf("%3d %s\n", i + 1, urls[i]);
}
if ((i = num_urls) != 1)
sprintf(cmd, rc_url_cmd, urls[i - 1]);
system(cmd);
- printf("\n");
+ scr_printf("\n");
}
/*
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '1') {
- printf("%s\n", &cmd[5]);
+ scr_printf("%s\n", &cmd[5]);
} else {
while (serv_gets(cmd), strcmp(cmd, "000")) {
if (num_msgs == MAXMSGS) {
if (num_msgs == 0) {
if (c == 3) return;
- printf("*** There are no ");
- if (c == 1) printf("new ");
- if (c == 2) printf("old ");
- printf("messages in this room.\n");
+ scr_printf("*** There are no ");
+ if (c == 1) scr_printf("new ");
+ if (c == 2) scr_printf("old ");
+ scr_printf("messages in this room.\n");
return;
}
if ((quotflag) || (arcflag)) {
screenwidth = hold_sw;
}
-RMSGREAD: fflush(stdout);
+RMSGREAD: scr_flush();
highest_msg_read = msg_arr[a];
if (quotflag) {
freopen("/dev/tty", "r+", stdout);
f = fork();
if (f == 0) {
freopen(prtfile, "r", stdin);
+ screen_reset();
sttybbs(SB_RESTORE);
ka_system(printcmd);
sttybbs(SB_NO_INTR);
+ screen_set();
unlink(prtfile);
exit(0);
}
do {
g = wait(NULL);
} while ((g != f) && (g >= 0));
- printf("Message printed.\n");
+ scr_printf("Message printed.\n");
}
if (rc_alt_semantics && c == 1) {
char buf[SIZ];
e = 'n';
} else {
color(DIM_WHITE);
- printf("(");
+ scr_printf("(");
color(BRIGHT_WHITE);
- printf("%d", num_msgs - a - 1);
+ scr_printf("%d", num_msgs - a - 1);
color(DIM_WHITE);
- printf(") ");
+ scr_printf(") ");
keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
if (rc_url_cmd[0] && num_urls)
&& (e != 'u') && (e != 'c') && (e != 'y'));
switch (e) {
case 's':
- printf("Stop\r");
+ scr_printf("Stop");
break;
case 'a':
- printf("Again\r");
+ scr_printf("Again");
break;
case 'd':
- printf("Delete\r");
+ scr_printf("Delete");
break;
case 'm':
- printf("Move\r");
+ scr_printf("Move");
break;
case 'c':
- printf("Copy\r");
+ scr_printf("Copy");
break;
case 'n':
- printf("Next\r");
+ scr_printf("Next");
break;
case 'p':
- printf("Print\r");
+ scr_printf("Print");
break;
case 'q':
- printf("Quote\r");
+ scr_printf("Quote");
break;
case 'b':
- printf("Back\r");
+ scr_printf("Back");
break;
case 'h':
- printf("Header\r");
+ scr_printf("Header");
break;
case 'r':
- printf("Reply\r");
+ scr_printf("Reply");
break;
case 'f':
- printf("File\r");
+ scr_printf("File");
break;
case 'u':
- printf("URL's\r");
+ scr_printf("URL's");
break;
case 'y':
- printf("mY next\r");
+ scr_printf("mY next");
break;
case '?':
- printf("? <help>\r");
+ scr_printf("? <help>");
break;
}
if (userflags & US_DISAPPEAR)
- printf("\r%79s\r", "");
+ scr_printf("\r%79s\r", "");
else
- printf("\n");
- fflush(stdout);
+ scr_printf("\n");
+ scr_flush();
}
switch (e) {
case '?':
- printf("Options available here:\n");
- printf(" ? Help (prints this message)\n");
- printf(" S Stop reading immediately\n");
- printf(" A Again (repeats last message)\n");
- printf(" N Next (continue with next message)\n");
- printf(" Y My Next (continue with next message you authored)\n");
- printf(" B Back (go back to previous message)\n");
+ scr_printf("Options available here:\n"
+ " ? Help (prints this message)\n"
+ " S Stop reading immediately\n"
+ " A Again (repeats last message)\n"
+ " N Next (continue with next message)\n"
+ " Y My Next (continue with next message you authored)\n"
+ " B Back (go back to previous message)\n");
if ((is_room_aide)
|| (room_flags & QR_MAILBOX)) {
- printf(" D Delete this message\n");
- printf
- (" M Move message to another room\n");
+ scr_printf(" D Delete this message\n"
+ " M Move message to another room\n");
}
- printf(" C Copy message to another room\n");
+ scr_printf(" C Copy message to another room\n");
if (strlen(printcmd) > 0)
- printf(" P Print this message\n");
- printf
- (" Q Quote portions of this message for your next post\n");
- printf
- (" H Headers (display message headers only)\n");
+ scr_printf(" P Print this message\n");
+ scr_printf(
+ " Q Quote portions of this message for your next post\n"
+ " H Headers (display message headers only)\n");
if (is_mail)
- printf(" R Reply to this message\n");
+ scr_printf(" R Reply to this message\n");
if (rc_allow_attachments)
- printf
+ scr_printf
(" F (save attachments to a file)\n");
if (strlen(rc_url_cmd) > 0)
- printf(" U (list URL's for display)\n");
- printf("\n");
+ scr_printf(" U (list URL's for display)\n");
+ scr_printf("\n");
goto RMSGREAD;
case 'p':
- fflush(stdout);
+ scr_flush();
freopen(prtfile, "w", stdout);
arcflag = 1;
hold_color = enable_color;
enable_color = 0;
goto RAGAIN;
case 'q':
- fflush(stdout);
+ scr_flush();
freopen(temp2, "w", stdout);
quotflag = 1;
hold_color = enable_color;
(e == 'c' ? 1 : 0));
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
if (cmd[0] == '2')
msg_arr[a] = 0L;
} else {
extract_int(&cmd[4],
0));
} else {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
}
goto RMSGREAD;
case 'd':
- printf("*** Delete this message? ");
+ scr_printf("*** Delete this message? ");
if (yesno() == 1) {
sprintf(cmd, "DELE %ld", msg_arr[a]);
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
if (cmd[0] == '2')
msg_arr[a] = 0L;
} else {
{
char buf[SIZ];
- printf
+ scr_printf
("Please read the documentation before running this command.\n"
"Having done so, do you still want to check the message base? ");
if (yesno() == 0)
serv_puts("FSCK");
serv_gets(buf);
if (buf[0] != '1') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
while (serv_gets(buf), strcmp(buf, "000")) {
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
}
}
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
#define IFNEXPERT if ((userflags&US_EXPERT)==0)
newfloor = a;
}
if (newfloor < 0) {
- printf("\n One of:\n");
+ scr_printf("\n One of:\n");
for (a = 0; a < 128; ++a) {
if (floorlist[a][0] != 0) {
- printf("%s\n",
+ scr_printf("%s\n",
&floorlist[a][0]);
}
}
serv_puts("GETR");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2')
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
} while (buf[0] != '2');
sprintf(buf, "%d", expire_mode);
strprompt("Message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
- printf("\n");
- printf("0. Use the default for this floor\n");
- printf("1. Never automatically expire messages\n");
- printf("2. Expire by message count\n");
- printf("3. Expire by message age\n");
+ scr_printf("\n"
+ "0. Use the default for this floor\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n"
+ "3. Expire by message age\n");
}
} while ((buf[0] < 48) || (buf[0] > 51));
expire_mode = buf[0] - 48;
}
/* Give 'em a chance to change their minds */
- printf("Save changes (y/n)? ");
+ scr_printf("Save changes (y/n)? ");
if (yesno() == 1) {
snprintf(buf, sizeof buf, "SETA %s", raide);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
snprintf(buf, sizeof buf, "SPEX room|%d|%d",
rorder);
serv_puts(buf);
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
if (buf[0] == '2')
dotgoto(rname, 2);
}
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
sprintf(buf, "SLRP %ld", uglsn);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
safestrncpy(buf, ugname, sizeof buf);
strcpy(ugname, "");
newprompt("Filename: ", filename, 250);
}
- printf("Enter the name of the directory to save '%s'\n", filename);
- printf("to, or press return for the current directory.\n");
+ scr_printf("Enter the name of the directory to save '%s'\n"
+ "to, or press return for the current directory.\n", filename);
newprompt("Directory: ", dbuf, sizeof dbuf);
if (strlen(dbuf) == 0)
strcpy(dbuf, ".");
savefp = fopen(dbuf, "w");
if (savefp == NULL) {
- printf("Cannot open '%s': %s\n", dbuf, strerror(errno));
+ scr_printf("Cannot open '%s': %s\n", dbuf, strerror(errno));
/* close the download file at the server */
serv_puts("CLOS");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
return;
}
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '6') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
packet = extract_int(&buf[4], 0);
serv_puts("CLOS");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
return;
}
int broken = 0;
if ((room_flags & QR_DOWNLOAD) == 0) {
- printf("*** You cannot download from this room.\n");
+ scr_printf("*** You cannot download from this room.\n");
return;
}
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
total_bytes = extract_long(&buf[4], 0);
}
/* Meta-download for public clients */
- printf("Fetching file from Citadel server...\n");
+ scr_printf("Fetching file from Citadel server...\n");
mkdir(tempdir, 0700);
snprintf(tempname, sizeof tempname, "%s/%s", tempdir, filename);
tpipe = fopen(tempname, "wb");
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '6') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
packet = extract_int(&buf[4], 0);
serv_read(dbuf, packet);
serv_puts("CLOS");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
if (proto == 0) {
else
sprintf(transmit_cmd, "exec cat %s", tempname);
+ screen_reset();
sttybbs(SB_RESTORE);
system(transmit_cmd);
sttybbs(SB_NO_INTR);
+ screen_set();
/* clean up the temporary directory */
nukedir(tempdir);
- putc(7, stdout);
+ scr_putc(7);
}
/*
* if ((room_flags & QR_PRIVATE)==0) {
- * printf("This is not a private room.\n");
+ * scr_printf("This is not a private room.\n");
* return;
* }
*/
snprintf(bbb, sizeof bbb, "INVT %s", aaa);
serv_puts(bbb);
serv_gets(bbb);
- printf("%s\n", &bbb[4]);
+ scr_printf("%s\n", &bbb[4]);
}
snprintf(cmd, sizeof cmd, "KICK %s", username);
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
}
serv_puts("KILL 0");
serv_gets(aaa);
if (aaa[0] != '2') {
- printf("%s\n", &aaa[4]);
+ scr_printf("%s\n", &aaa[4]);
return;
}
- printf("Are you sure you want to kill this room? ");
+ scr_printf("Are you sure you want to kill this room? ");
if (yesno() == 0)
return;
serv_puts("KILL 1");
serv_gets(aaa);
- printf("%s\n", &aaa[4]);
+ scr_printf("%s\n", &aaa[4]);
if (aaa[0] != '2')
return;
dotgoto("_BASEROOM_", 0);
{ /* forget the current room */
char cmd[SIZ];
- printf("Are you sure you want to forget this room? ");
+ scr_printf("Are you sure you want to forget this room? ");
if (yesno() == 0)
return;
serv_puts("FORG");
serv_gets(cmd);
if (cmd[0] != '2') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
serv_gets(cmd);
if (cmd[0] != '2') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
IFNEXPERT formout("roomaccess");
do {
- printf("<?>Help\n<1>Public room\n<2>Guess-name room\n"
+ scr_printf("<?>Help\n<1>Public room\n<2>Guess-name room\n"
"<3>Passworded room\n<4>Invitation-only room\n"
- "<5>Personal room\n");
- printf("Enter room type: ");
+ "<5>Personal room\n"
+ "Enter room type: ");
do {
b = inkey();
} while (((b < '1') || (b > '5')) && (b != '?'));
if (b == '?') {
- printf("?\n");
+ scr_printf("?\n");
formout("roomaccess");
}
} while ((b < '1') || (b > '5'));
b = b - 48;
- printf("%d\n", b);
+ scr_printf("%d\n", b);
new_room_type = b - 1;
if (new_room_type == 2) {
newprompt("Enter a room password: ", new_room_pass, 9);
strcpy(new_room_pass, "");
}
- printf("\042%s\042, a", new_room_name);
+ scr_printf("\042%s\042, a", new_room_name);
if (b == 1)
- printf(" public room.");
+ scr_printf(" public room.");
if (b == 2)
- printf(" guess-name room.");
+ scr_printf(" guess-name room.");
if (b == 3)
- printf(" passworded room, password: %s", new_room_pass);
+ scr_printf(" passworded room, password: %s", new_room_pass);
if (b == 4)
- printf("n invitation-only room.");
+ scr_printf("n invitation-only room.");
if (b == 5)
- printf(" personal room.");
- printf("\nInstall it? (y/n) : ");
+ scr_printf(" personal room.");
+ scr_printf("\nInstall it? (y/n) : ");
if (yesno() == 0) {
return;
}
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '2') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
if (strlen(editor_path) == 0) {
- printf("Do you wish to re-enter %s? ", desc);
+ scr_printf("Do you wish to re-enter %s? ", desc);
if (yesno() == 0)
return;
}
serv_puts(check_cmd);
serv_gets(cmd);
if (cmd[0] != '2') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
editor_pid = fork();
if (editor_pid == 0) {
chmod(temp, 0600);
+ screen_reset();
sttybbs(SB_RESTORE);
execlp(editor_path, editor_path, temp, NULL);
exit(1);
b = wait(&editor_exit);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
- printf("Executed %s\n", editor_path);
+ scr_printf("Executed %s\n", editor_path);
sttybbs(0);
+ screen_set();
} else {
- printf("Entering %s. ", desc);
- printf("Press return twice when finished.\n");
+ scr_printf("Entering %s. "
+ "Press return twice when finished.\n", desc);
fp = fopen(temp, "r+");
citedit(fp);
fclose(fp);
}
if (file_checksum(temp) == cksum) {
- printf("*** Aborted.\n");
+ scr_printf("*** Aborted.\n");
}
else {
serv_puts(write_cmd);
serv_gets(cmd);
if (cmd[0] != '4') {
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
return;
}
serv_puts("CFLR xx|0");
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
serv_puts(buf);
serv_gets(buf);
if (buf[0] == '2') {
- printf("Floor has been created.\n");
+ scr_printf("Floor has been created.\n");
} else {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
load_floorlist();
("Floor default essage expire policy (? for list)",
buf, 1);
if (buf[0] == '?') {
- printf("\n");
- printf("0. Use the system default\n");
- printf("1. Never automatically expire messages\n");
- printf("2. Expire by message count\n");
- printf("3. Expire by message age\n");
+ scr_printf("\n"
+ "0. Use the system default\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n"
+ "3. Expire by message age\n");
}
} while ((buf[0] < 48) || (buf[0] > 51));
expire_mode = buf[0] - 48;
&floorlist[(int) curr_floor][0]);
serv_puts(buf);
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
load_floorlist();
}
load_floorlist();
do {
floornum_to_delete = (-1);
- printf("(Press return to abort)\n");
+ scr_printf("(Press return to abort)\n");
newprompt("Delete which floor? ", buf, 255);
if (strlen(buf) == 0)
return;
if (!strcasecmp(&floorlist[a][0], buf))
floornum_to_delete = a;
if (floornum_to_delete < 0) {
- printf("No such floor. Select one of:\n");
+ scr_printf("No such floor. Select one of:\n");
for (a = 0; a < 128; ++a)
if (floorlist[a][0] != 0)
- printf("%s\n", &floorlist[a][0]);
+ scr_printf("%s\n", &floorlist[a][0]);
}
} while (floornum_to_delete < 0);
sprintf(buf, "KFLR %d|1", floornum_to_delete);
serv_puts(buf);
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
load_floorlist();
}
# include <time.h>
# endif
#endif
-
+#ifdef HAVE_LIMITS_H
#include <limits.h>
+#endif
#ifdef HAVE_UTMP_H
#include <utmp.h>
#endif
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#endif
+#include "screen.h"
#ifndef HAVE_GETUTLINE
struct utmp *getutline(struct utmp *ut);
{
int a;
for (a=1; a<=spaces; ++a) {
- putc(8,stdout); putc(32,stdout); putc(8,stdout);
+ scr_putc(8); scr_putc(32); scr_putc(8);
}
}
color(COLOR_PUSH);
color(DIM_RED);
- printf("%s\r",serv_info.serv_moreprompt);
+ scr_printf("%s\r",serv_info.serv_moreprompt);
color(COLOR_POP);
sttybbs(0);
b=inkey();
for (a=0; a<strlen(serv_info.serv_moreprompt); ++a)
- putc(' ',stdout);
- putc(13,stdout);
+ scr_putc(' ');
+ scr_putc(13);
sttybbs(1);
if (b == 'q' || b == 'Q' || b == 's' || b == 'S')
b = STOP_KEY;
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') {
- printf("%s\n",&buf[4]);
+ scr_printf("%s\n",&buf[4]);
return;
}
extract(who, &buf[4], 0);
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') {
- printf("%s\n",&buf[4]);
+ scr_printf("%s\n",&buf[4]);
}
}
temp = sval;
color(DIM_WHITE);
- printf("%45s ", prompt);
+ scr_printf("%45s ", prompt);
color(DIM_MAGENTA);
- printf("[");
+ scr_printf("[");
color(BRIGHT_MAGENTA);
- printf("%3s", ((temp&sbit) ? "Yes":"No"));
+ scr_printf("%3s", ((temp&sbit) ? "Yes":"No"));
color(DIM_MAGENTA);
- printf("]? ");
+ scr_printf("]? ");
color(BRIGHT_CYAN);
a=yesno_d(temp&sbit);
color(DIM_WHITE);
serv_puts(buf);
serv_gets(buf);
if (buf[0]!='2') {
- printf("%s\n",&buf[4]);
+ scr_printf("%s\n",&buf[4]);
return;
}
if (mode==2) {
if (flags & US_EXPERT) {
flags = (flags ^ US_EXPERT);
- printf("Expert mode now OFF\n");
+ scr_printf("Expert mode now OFF\n");
}
else {
flags = (flags | US_EXPERT);
- printf("Expert mode now ON\n");
+ scr_printf("Expert mode now ON\n");
}
}
if (mode==3) {
if (flags & US_FLOORS) {
flags = (flags ^ US_FLOORS);
- printf("Floor mode now OFF\n");
+ scr_printf("Floor mode now OFF\n");
}
else {
flags = (flags | US_FLOORS);
- printf("Floor mode now ON\n");
+ scr_printf("Floor mode now ON\n");
}
}
sprintf(buf,"SETU %d|%d|%d|%d",width,height,flags,filter);
serv_puts(buf);
serv_gets(buf);
- if (buf[0]!='2') printf("%s\n",&buf[4]);
+ if (buf[0]!='2') scr_printf("%s\n",&buf[4]);
userflags = flags;
}
void interr(int errnum) /* display internal error as defined in errmsgs */
{
- printf("*** INTERNAL ERROR %d\n",errnum);
- printf("(Press any key to continue)\n");
+ scr_printf("*** INTERNAL ERROR %d\n"
+ "(Press any key to continue)\n", errnum);
inkey();
logoff(errnum);
}
*/
char *strerror(int e)
{
- static char buf[32];
+ static char buf[128];
sprintf(buf,"errno = %d",e);
return(buf);
long a;
if (curr==0) {
- printf(".......................................");
- printf(".......................................\r");
- fflush(stdout);
+ scr_printf(".......................................");
+ scr_printf(".......................................\r");
+ scr_flush();
dots_printed = 0;
}
else if (curr==cmax) {
- printf("\r%79s\n","");
+ scr_printf("\r%79s\n","");
}
else {
a=(curr * 100) / cmax;
a=a*78; a=a/100;
while (dots_printed < a) {
- printf("*");
+ scr_printf("*");
++dots_printed;
- fflush(stdout);
+ scr_flush();
}
}
}
serv_puts(cmd);
serv_gets(buf);
- printf("%s\n",buf);
+ scr_printf("%s\n",buf);
if (buf[0]=='1') {
set_keepalives(KA_NO);
while (serv_gets(buf), strcmp(buf,"000")) {
- printf("%s\n",buf);
+ scr_printf("%s\n",buf);
}
set_keepalives(KA_YES);
return;
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
+#include "screen.h"
void interr(int errnum);
void strprompt(char *prompt, char *str, int len);
int ret;
ret = open(name, mode);
if (ret < 0) {
- fprintf(stderr, "Cannot open file '%s', mode=%d, errno=%d\n",
+ err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
name, mode, errno);
interr(errno);
}
serv_puts("REGI");
serv_gets(buf);
if (buf[0] != '4') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
serv_puts(tmpname);
serv_puts(tmpemail);
serv_puts(tmpcountry);
serv_puts("000");
- printf("\n");
+ scr_printf("\n");
}
void updatels(void)
if (rc_alt_semantics) {
if (maxmsgnum == highest_msg_read == 0) {
- /* fprintf(stderr, "maxmsgnum == highest_msg_read == 0\n"); */
+ /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
return;
}
snprintf(buf, sizeof(buf), "SLRP %ld",
}
serv_gets(buf);
if (buf[0] != '2')
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
/*
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2')
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
bytes_expected = atoi(&buf[4]);
serv_write(tbuf, bytes_expected);
} else {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
}
transmitted_bytes = transmitted_bytes + (long) bytes_to_send;
close(fd);
serv_puts("UCLS 1");
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
int fd;
if ((room_flags & QR_UPLOAD) == 0) {
- printf("*** You cannot upload to this room.\n");
+ scr_printf("*** You cannot upload to this room.\n");
return;
}
newprompt("File to be uploaded: ", flnm, 55);
fd = open(flnm, O_RDONLY);
if (fd < 0) {
- printf("Cannot open '%s': %s\n", flnm, strerror(errno));
+ scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
return;
}
- printf("Enter a description of this file:\n");
+ scr_printf("Enter a description of this file:\n");
newprompt(": ", desc, 75);
/* keep generating filenames in hope of finding a unique one */
serv_puts(tbuf);
serv_gets(buf);
if (buf[0] != '2')
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
++a;
} while (buf[0] != '2');
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
newprompt("Image file to be uploaded: ", flnm, 55);
fd = open(flnm, O_RDONLY);
if (fd < 0) {
- printf("Cannot open '%s': %s\n", flnm, strerror(errno));
+ scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
return;
}
sprintf(buf, "UIMG 1|%s", keyname);
serv_puts(buf);
serv_gets(buf);
if (buf[0] != '2') {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
return;
}
do_upload(fd);
int fd;
if ((room_flags & QR_UPLOAD) == 0) {
- printf("*** You cannot upload to this room.\n");
+ scr_printf("*** You cannot upload to this room.\n");
return;
}
/* we don't need a filename when receiving batch y/z modem */
/* create a temporary directory... */
if (mkdir(tempdir, 0700) != 0) {
- printf("*** Could not create temporary directory %s: %s\n",
+ scr_printf("*** Could not create temporary directory %s: %s\n",
tempdir, strerror(errno));
return;
}
switch (c) {
case 0:
sttybbs(0);
- printf("Receiving %s - press Ctrl-D to end.\n", flnm);
+ scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
fp = fopen(flnm, "w");
do {
b = inkey();
if (b == 13) {
b = 10;
- printf("\r");
}
if (b != 4) {
- printf("%c", b);
+ scr_printf("%c", b);
putc(b, fp);
}
} while (b != 4);
fclose(fp);
exit(0);
case 1:
+ screen_reset();
sttybbs(3);
execlp("rx", "rx", flnm, NULL);
exit(1);
case 2:
+ screen_reset();
sttybbs(3);
execlp("rb", "rb", NULL);
exit(1);
case 3:
+ screen_reset();
sttybbs(3);
execlp("rz", "rz", NULL);
exit(1);
b = ka_wait(&a);
} while ((b != xfer_pid) && (b != (-1)));
sttybbs(0);
+ screen_set();
if (a != 0) {
- printf("\r*** Transfer unsuccessful.\n");
+ scr_printf("\r*** Transfer unsuccessful.\n");
nukedir(tempdir);
return;
}
- printf("\r*** Transfer successful. Sending file(s) to server...\n");
+ scr_printf("\r*** Transfer successful. Sending file(s) to server...\n");
sprintf(buf, "cd %s; ls", tempdir);
lsfp = popen(buf, "r");
if (lsfp != NULL) {
close(fd);
serv_puts("UCLS 1");
serv_gets(buf);
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
}
pclose(lsfp);
serv_gets(buf);
++a;
if (a == 1)
- printf("User #%s - %s ", buf, &cmd[4]);
+ scr_printf("User #%s - %s ", buf, &cmd[4]);
if (a == 2)
- printf("PW: %s\n", buf);
+ scr_printf("PW: %s\n", buf);
if (a == 3)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
if (a == 4)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
if (a == 5)
- printf("%s, ", buf);
+ scr_printf("%s, ", buf);
if (a == 6)
- printf("%s ", buf);
+ scr_printf("%s ", buf);
if (a == 7)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
if (a == 8)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
if (a == 9)
ax = atoi(buf);
if (a == 10)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
if (a == 11)
- printf("%s\n", buf);
+ scr_printf("%s\n", buf);
} while (strcmp(buf, "000"));
- printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
+ scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
} else {
- printf("%-30s\n%s\n", user, &cmd[4]);
+ scr_printf("%-30s\n%s\n", user, &cmd[4]);
}
if (do_validate) {
serv_puts(cmd);
serv_gets(cmd);
if (cmd[0] != '2')
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
}
- printf("\n");
+ scr_printf("\n");
}
if (cmd[0] != '3')
finished = 1;
if (cmd[0] == '2')
- printf("%s\n", &cmd[4]);
+ scr_printf("%s\n", &cmd[4]);
if (cmd[0] == '3') {
extract(buf, cmd, 0);
val_user(&buf[4], 1);
int a, b;
a = fork();
if (a == 0) {
+ screen_reset();
sttybbs(SB_RESTORE);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
execlp(getenv("SHELL"), getenv("SHELL"), NULL);
- printf("Could not open a shell: %s\n", strerror(errno));
+ err_printf("Could not open a shell: %s\n", strerror(errno));
exit(errno);
}
do {
b = ka_wait(NULL);
} while ((a != b) && (a != (-1)));
sttybbs(0);
+ screen_set();
}
/*
sprintf(cmd, "DELF %s", filename);
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ err_printf("%s\n", &cmd[4]);
}
/*
sprintf(cmd, "NETF %s|%s", filename, destsys);
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ err_printf("%s\n", &cmd[4]);
return;
}
sprintf(cmd, "MOVF %s|%s", filename, newroom);
serv_puts(cmd);
serv_gets(cmd);
- printf("%s\n", &cmd[4]);
+ err_printf("%s\n", &cmd[4]);
}
strprompt("System default message expire policy (? for list)",
buf, 1);
if (buf[0] == '?') {
- printf("\n");
- printf("1. Never automatically expire messages\n");
- printf("2. Expire by message count\n");
- printf("3. Expire by message age\n");
+ scr_printf("\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n"
+ "3. Expire by message age\n");
}
} while ((buf[0] < 49) || (buf[0] > 51));
expire_mode = buf[0] - 48;
expire_value = atol(buf);
}
/* Save it */
- printf("Save this configuration? ");
+ scr_printf("Save this configuration? ");
if (yesno()) {
serv_puts("CONF set");
serv_gets(buf);
}
do {
- printf("\n");
+ scr_printf("\n");
color(BRIGHT_WHITE);
- printf("### ");
- printf(" Host or domain ");
- printf(" Record type \n");
+ scr_printf("### Host or domain Record type \n");
color(DIM_WHITE);
- printf("--- ");
- printf("-------------------------------------------------- ");
- printf("--------------------\n");
+ scr_printf("--- -------------------------------------------------- --------------------\n");
for (i=0; i<num_recs; ++i) {
color(DIM_WHITE);
- printf("%3d ", i+1);
+ scr_printf("%3d ", i+1);
extract(buf, recs[i], 0);
color(BRIGHT_CYAN);
- printf("%-50s ", buf);
+ scr_printf("%-50s ", buf);
extract(buf, recs[i], 1);
color(BRIGHT_MAGENTA);
- printf("%-20s\n", buf);
+ scr_printf("%-20s\n", buf);
color(DIM_WHITE);
}
serv_puts("000");
}
else {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
quitting = 1;
break;
FILE *changefp;
if (strlen(editor_path) == 0) {
- printf("You must have an external editor configured in order"
- " to use this function.\n");
+ scr_printf("You must have an external editor configured in"
+ " order to use this function.\n");
return;
}
tempfp = fopen(filename, "w");
if (tempfp == NULL) {
- printf("Cannot open %s: %s\n", filename, strerror(errno));
+ err_printf("Cannot open %s: %s\n", filename, strerror(errno));
return;
}
cksum = file_checksum(filename);
if (editor_pid == 0) {
chmod(filename, 0600);
+ screen_reset();
sttybbs(SB_RESTORE);
setenv("WINDOW_TITLE", "Network configuration", 1);
execlp(editor_path, editor_path, filename, NULL);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
sttybbs(0);
+ screen_set();
}
if (file_checksum(filename) == cksum) {
- printf("*** Not saving changes.\n");
+ err_printf("*** Not saving changes.\n");
e_ex_code = 1;
}
}
do {
- printf("\n");
+ scr_printf("\n");
color(BRIGHT_WHITE);
- printf( "### "
+ scr_printf( "### "
" Node "
" Secret "
" Host or IP "
"Port#\n");
color(DIM_WHITE);
- printf( "--- "
+ scr_printf( "--- "
"---------------- "
"------------------ "
"-------------------------------- "
"-----\n");
for (i=0; i<num_recs; ++i) {
color(DIM_WHITE);
- printf("%3d ", i+1);
+ scr_printf("%3d ", i+1);
extract(buf, recs[i], 0);
color(BRIGHT_CYAN);
- printf("%-16s ", buf);
+ scr_printf("%-16s ", buf);
extract(buf, recs[i], 1);
color(BRIGHT_MAGENTA);
- printf("%-18s ", buf);
+ scr_printf("%-18s ", buf);
extract(buf, recs[i], 2);
color(BRIGHT_CYAN);
- printf("%-32s ", buf);
+ scr_printf("%-32s ", buf);
extract(buf, recs[i], 3);
color(BRIGHT_MAGENTA);
- printf("%-3s\n", buf);
+ scr_printf("%-3s\n", buf);
color(DIM_WHITE);
}
serv_puts("000");
}
else {
- printf("%s\n", &buf[4]);
+ scr_printf("%s\n", &buf[4]);
}
quitting = 1;
break;
--- /dev/null
+/* $Id$ */
+
+/*
+ * Handle full-screen curses stuff
+ */
+
+#include "sysdep.h"
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/types.h>
+#ifdef VW_PRINTW_IN_CURSES
+#define _vwprintw vw_printw
+#else
+/* Ancient curses implementations, this needs testing. Anybody got XENIX? */
+#define _vwprintw vwprintw
+#endif
+#include "citadel.h"
+#include "commands.h"
+#include "screen.h"
+
+#ifdef HAVE_CURSES_H
+static SCREEN *myscreen = NULL;
+static WINDOW *mainwindow = NULL;
+static WINDOW *statuswindow = NULL;
+
+char rc_screen;
+char arg_screen;
+
+extern int screenheight;
+extern int screenwidth;
+extern void check_screen_dims(void);
+#endif
+
+
+/*
+ * Initialize the screen. If newterm() fails, myscreen will be NULL and
+ * further handlers will assume we should be in line mode.
+ */
+void screen_new(void)
+{
+#ifdef HAVE_CURSES_H
+ if (arg_screen != RC_NO && rc_screen != RC_NO)
+ myscreen = newterm(NULL, stdout, stdin);
+ if (myscreen) {
+ cbreak();
+ noecho();
+ nonl();
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
+ } else
+#endif /* HAVE_CURSES_H */
+ {
+ send_ansi_detect();
+ look_for_ansi();
+ cls(0);
+ color(1+DIM_WHITE);
+ }
+#ifdef HAVE_CURSES_H
+ if (myscreen) {
+ /* Setup all our colors */
+ start_color();
+ init_pair(1+DIM_BLACK, COLOR_BLACK, COLOR_BLACK);
+ init_pair(1+DIM_RED, COLOR_RED, COLOR_BLACK);
+ init_pair(1+DIM_GREEN, COLOR_GREEN, COLOR_BLACK);
+ init_pair(1+DIM_YELLOW, COLOR_YELLOW, COLOR_BLACK);
+ init_pair(1+DIM_BLUE, COLOR_BLUE, COLOR_BLACK);
+ init_pair(1+DIM_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
+ init_pair(1+DIM_CYAN, COLOR_CYAN, COLOR_BLACK);
+ init_pair(1+DIM_WHITE, COLOR_WHITE, COLOR_BLACK);
+ init_pair(17, COLOR_WHITE, COLOR_BLUE);
+ }
+#endif /* HAVE_CURSES_H */
+ screen_set();
+ windows_new();
+}
+
+
+/*
+ * Kill the screen completely (used at exit). It is safe to call this
+ * function more than once.
+ */
+void screen_delete(void)
+{
+ windows_delete();
+ screen_reset();
+#ifdef HAVE_CURSES_H
+ if (myscreen)
+ delscreen(myscreen);
+ myscreen = NULL;
+#endif
+}
+
+
+/*
+ * Set screen/IO parameters, e.g. at start of program or return from external
+ * program run.
+ */
+int screen_set(void)
+{
+#ifdef HAVE_CURSES_H
+ if (myscreen) {
+ set_term(myscreen);
+ wrefresh(curscr);
+ return 1;
+ }
+#endif /* HAVE_CURSES_H */
+ return 0;
+}
+
+
+/*
+ * Reset screen/IO parameters, e.g. at exit or fork of external program.
+ */
+int screen_reset(void)
+{
+#ifdef HAVE_CURSES_H
+ if (myscreen) {
+ endwin();
+ return 1;
+ }
+#endif /* HAVE_CURSES_H */
+ return 0;
+}
+
+
+/*
+ * scr_printf() outputs to the main window (or screen if not in curses)
+ */
+int scr_printf(char *fmt, ...)
+{
+ va_list ap;
+ register int retval;
+
+ va_start(ap, fmt);
+#ifdef HAVE_CURSES_H
+ if (mainwindow) {
+ retval = _vwprintw(mainwindow, fmt, ap);
+ /*
+ if (fmt[strlen(fmt) - 1] == '\n')
+ wrefresh(mainwindow);
+ */
+ } else
+#endif
+ retval = vprintf(fmt, ap);
+ va_end(ap);
+ return retval;
+}
+
+
+/*
+ * err_printf() outputs to error status window (or stderr if not in curses)
+ */
+int err_printf(char *fmt, ...)
+{
+ va_list ap;
+ register int retval;
+
+ va_start(ap, fmt);
+#ifdef HAVE_CURSES_H
+ if (mainwindow) { /* FIXME: direct to error window */
+ retval = _vwprintw(mainwindow, fmt, ap);
+ if (fmt[strlen(fmt) - 1] == '\n')
+ wrefresh(mainwindow);
+ } else
+#endif
+ retval = vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ return retval;
+}
+
+
+/*
+ * sln_printf() outputs to error status window (or stderr if not in curses)
+ */
+int sln_printf(char *fmt, ...)
+{
+ va_list ap;
+ register int retval;
+
+ va_start(ap, fmt);
+#ifdef HAVE_CURSES_H
+ if (statuswindow) {
+ retval = _vwprintw(statuswindow, fmt, ap);
+ if (fmt[strlen(fmt) - 1] == '\n')
+ wrefresh(mainwindow);
+ } else
+#endif
+ retval = vprintf(fmt, ap);
+ va_end(ap);
+ return retval;
+}
+
+
+int scr_getc(void)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow)
+ return wgetch(mainwindow);
+#endif
+ return getchar();
+}
+
+
+/*
+ * scr_putc() outputs a single character
+ */
+int scr_putc(int c)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow)
+ return ((waddch(mainwindow, c) == OK) ? c : EOF);
+#endif
+ return putc(c, stdout);
+}
+
+
+/*
+ * scr_color() sets the window color for mainwindow
+ */
+int scr_color(int colornum)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow) {
+ wcolor_set(mainwindow, 1 + (colornum & 7), NULL);
+ if (colornum & 8) {
+ wattron(mainwindow, A_BOLD);
+ } else {
+ wattroff(mainwindow, A_BOLD);
+ }
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+
+void scr_flush(void)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow)
+ wrefresh(mainwindow);
+ else
+#endif
+ fflush(stdout);
+}
+
+
+void err_flush(void)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow) /* FIXME: error status window needed */
+ wrefresh(mainwindow);
+ else
+#endif
+ fflush(stderr);
+}
+
+
+void sln_flush(void)
+{
+#ifdef HAVE_CURSES_H
+ if (statuswindow)
+ wrefresh(statuswindow);
+ else
+#endif
+ fflush(stdout);
+}
+
+
+int scr_set_windowsize(void)
+{
+#ifdef HAVE_CURSES_H
+ int y, x;
+
+ if (mainwindow) {
+ getmaxyx(mainwindow, y, x);
+ screenheight = y;
+ screenwidth = x;
+ return 1;
+ }
+#endif /* HAVE_CURSES_H */
+ return 0;
+}
+
+
+/*
+ * scr_winch() handles window size changes from SIGWINCH
+ * resizes all our windows for us
+ */
+RETSIGTYPE scr_winch(void)
+{
+#ifdef HAVE_CURSES_H
+ /* FIXME: not implemented */
+#endif
+ check_screen_dims();
+}
+
+
+/*
+ * Initialize the window(s) we will be using.
+ */
+void windows_new(void)
+{
+#ifdef HAVE_CURSES_H
+ register int x, y;
+
+ if (myscreen) {
+ getmaxyx(stdscr, y, x);
+ mainwindow = newwin(y - 1, x, 0, 0);
+ screenwidth = x;
+ screenheight = y - 1;
+ immedok(mainwindow, FALSE);
+ leaveok(mainwindow, FALSE);
+ scrollok(mainwindow, TRUE);
+ statuswindow = newwin(1, x, y - 1, 0);
+ wbkgdset(statuswindow, COLOR_PAIR(17));
+ werase(statuswindow);
+ immedok(statuswindow, TRUE);
+ leaveok(statuswindow, FALSE);
+ scrollok(statuswindow, FALSE);
+ wrefresh(statuswindow);
+ }
+#else /* HAVE_CURSES_H */
+
+#endif /* HAVE_CURSES_H */
+}
+
+
+/*
+ * Deinitialize the window(s) we were using (at exit).
+ */
+void windows_delete(void)
+{
+#ifdef HAVE_CURSES_H
+ if (mainwindow)
+ delwin(mainwindow);
+ mainwindow = NULL;
+ if (statuswindow)
+ delwin(statuswindow);
+ statuswindow = NULL;
+#else /* HAVE_CURSES_H */
+
+#endif /* HAVE_CURSES_H */
+}
--- /dev/null
+/* $Id$ */
+
+void screen_new(void);
+void screen_delete(void);
+int screen_set(void);
+int screen_reset(void);
+int scr_printf(char *fmt, ...);
+int err_printf(char *fmt, ...);
+int sln_printf(char *fmt, ...);
+int scr_getc(void);
+int scr_putc(int c);
+int scr_color(int colornum);
+void scr_flush(void);
+void err_flush(void);
+void sln_flush(void);
+int scr_set_windowsize(void);
+void windows_new(void);
+void windows_delete(void);
#include "tools.h"
#include "citadel.h"
+#ifdef CIT_CLIENT
+#include "screen.h"
+#else
+extern int err_printf(char *fmt, ...);
+#endif
+
#define TRUE 1
#define FALSE 0
char *safestrncpy(char *dest, const char *src, size_t n)
{
if (dest == NULL || src == NULL) {
- fprintf(stderr, "safestrncpy: NULL argument\n");
+ err_printf("safestrncpy: NULL argument\n");
abort();
}
strncpy(dest, src, n);