#define IFNAIDE if (axlevel<AxAideU)
int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2);
-
march *marchptr = NULL;
+extern char *moreprompt;
/* globals associated with the client program */
char temp[PATH_MAX]; /* Name of general-purpose temp file */
int enable_syslog = 0;
-/*
- * CtdlLogPrintf() ... Write logging information;
- * simple here to have the same
- * symbols in the client.
- */
-
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {
- va_list arg_ptr;
-
- va_start(arg_ptr, format);
- vfprintf(stderr, format, arg_ptr);
- va_end(arg_ptr);
- fflush(stderr);
-}
-
/*
* here is our 'clean up gracefully and exit' routine
*/
/*
* now clean up various things
*/
- screen_delete();
-
unlink(temp);
unlink(temp2);
nukedir(tempdir);
return;
}
if (text) {
- fmout(screenwidth, NULL, text, NULL,
- ((userflags & US_PAGINATOR) ? 1 : 0),
- screenheight, 1, 1);
+ fmout(screenwidth, NULL, text, NULL, 1);
free(text);
}
}
r = CtdlIPCUserListing(ipc, patn, &listing, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
- pprintf(" User Name Num L Last Visit Logins Messages\n");
- pprintf("------------------------- ----- - ---------- ------ --------\n");
+ scr_printf(" User Name Num L Last Visit Logins Messages\n");
+ scr_printf("------------------------- ----- - ---------- ------ --------\n");
if (listing != NULL) while (!IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
if (sigcaught == 0) {
extract_token(fl, buf, 0, '|', sizeof fl);
if (pattern(fl, patn) >= 0) {
- pprintf("%-25s ", fl);
- pprintf("%5ld %d ", extract_long(buf, 2),
+ scr_printf("%-25s ", fl);
+ scr_printf("%5ld %d ", extract_long(buf, 2),
extract_int(buf, 1));
lc = extract_long(buf, 3);
localtime_r(&lc, &tmbuf);
- pprintf("%02d/%02d/%04d ",
+ scr_printf("%02d/%02d/%04d ",
(tmbuf.tm_mon + 1),
tmbuf.tm_mday,
(tmbuf.tm_year + 1900));
- pprintf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
+ scr_printf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
}
}
}
free(listing);
- pprintf("\n");
+ scr_printf("\n");
}
char *pop_march(int desired_floor, struct march *_march)
{
static char TheRoom[ROOMNAMELEN];
- int TheFloor = 0;
- int TheOrder = 32767;
int TheWeight = 0;
int weight;
struct march *mptr = NULL;
if (weight > TheWeight) {
TheWeight = weight;
strcpy(TheRoom, mptr->march_name);
- TheFloor = mptr->march_floor;
- TheOrder = mptr->march_order;
}
}
return (TheRoom);
switch(room->RRdefaultview) {
case VIEW_BBS:
case VIEW_MAILBOX:
+ case VIEW_BLOG:
entmsg_ok = 1;
break;
default:
color(DIM_WHITE);
if (!IsEmptyStr(rc_gotmail_cmd)) {
rv = system(rc_gotmail_cmd);
+ if (rv)
+ scr_printf("*** failed to check for mail calling %s Reason %d.\n",
+ rc_gotmail_cmd, rv);
}
}
free(room);
+
+ if (screenwidth>5) snprintf(&status_line[1], screenwidth-1, "%s | %s | %s | %s | %d new mail |",
+ (secure ? "Encrypted" : "Unencrypted"),
+ ipc->ServInfo.humannode,
+ ipc->ServInfo.site_location,
+ room_name,
+ newmailcount
+ );
}
/* Goto next room having unread messages.
char buf[SIZ];
struct march *mptr, *mptr2;
char next_room[ROOMNAMELEN];
- int r; /* IPC response code */
/* Check to see if the march-mode list is already allocated.
* If it is, pop the first room off the list and go there.
*/
if (marchptr == NULL) {
- r = CtdlIPCKnownRooms(ipc, SubscribedRoomsWithNewMessages,
- AllFloors, &marchptr, buf);
+ CtdlIPCKnownRooms(ipc, SubscribedRoomsWithNewMessages,
+ AllFloors, &marchptr, buf);
/* add _BASEROOM_ to the end of the march list, so the user will end up
* in the system base room (usually the Lobby>) at the end of the loop
int r; /* IPC response code */
scr_printf("Forgetting all rooms on %s...\n", &floorlist[ffloor][0]);
- scr_flush();
remove_march("_FLOOR_", ffloor);
r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, ffloor, &flist, buf);
if (r / 100 != 1) {
/* get misc user info */
r = CtdlIPCGetBio(ipc, fullname, &resp, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
extract_token(_fullname, buf, 1, '|', sizeof fullname);
scr_printf("\n");
/* show preferences */
- scr_printf("Your screen width: "); color(BRIGHT_CYAN); scr_printf("%d", /*user->USscreenwidth*/ screenwidth); color(DIM_WHITE);
- scr_printf(", height: "); color(BRIGHT_CYAN); scr_printf("%d\n", /*user->USscreenheight*/ screenheight); color(DIM_WHITE);
scr_printf("Are you an experienced Citadel user: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No"); color(DIM_WHITE);
scr_printf("Print last old message on New message request: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_LASTOLD)? "Yes" : "No"); color(DIM_WHITE);
scr_printf("Prompt after each message: "); color(BRIGHT_CYAN); scr_printf("%s\n", (!(user->flags & US_NOPROMPT))? "Yes" : "No"); color(DIM_WHITE);
int mrtg_users, mrtg_active_users;
char mrtg_server_uptime[40];
long mrtg_himessage;
- int ret; /* IPC response code */
/* get #users, #active & server uptime */
- ret = CtdlIPCGenericCommand(ipc, "MRTG|users", NULL, 0, &resp, &bytes, buf);
+ CtdlIPCGenericCommand(ipc, "MRTG|users", NULL, 0, &resp, &bytes, buf);
mrtg_users = extract_int(resp, 0);
remove_token(resp, 0, '\n');
mrtg_active_users = extract_int(resp, 0);
remove_token(resp, 0, '\n');
extract_token(mrtg_server_uptime, resp, 0, '\n', sizeof mrtg_server_uptime);
- free(resp);
+ free(resp);
resp = NULL;
/* get high message# */
- ret = CtdlIPCGenericCommand(ipc, "MRTG|messages", NULL, 0, &resp, &bytes, buf);
+ CtdlIPCGenericCommand(ipc, "MRTG|messages", NULL, 0, &resp, &bytes, buf);
mrtg_himessage = extract_long(resp, 0);
free(resp);
resp = NULL;
char buf[SIZ];
CtdlIPCServerInfo(ipc, buf);
+ moreprompt = ipc->ServInfo.moreprompt;
/* be nice and identify ourself to the server */
CtdlIPCIdentifySoftware(ipc, SERVER_TYPE, 0, REV_LEVEL,
/*
- * Record compare function for SortOnlineUsers()
+ * Session username compare function for SortOnlineUsers()
+ */
+int rwho_username_cmp(const void *rec1, const void *rec2) {
+ char *u1, *u2;
+
+ u1 = strchr(rec1, '|');
+ u2 = strchr(rec2, '|');
+
+ return strcasecmp( (u1?++u1:"") , (u2?++u2:"") );
+}
+
+
+/*
+ * Idle time compare function for SortOnlineUsers()
*/
int idlecmp(const void *rec1, const void *rec2) {
time_t i1, i2;
* Sort the list of online users by idle time.
* This function frees the supplied buffer, and returns a new one
* to the caller. The caller is responsible for freeing the returned buffer.
+ *
+ * If 'condense' is nonzero, multiple sessions for the same user will be
+ * combined into one for brevity.
*/
-char *SortOnlineUsers(char *listing) {
+char *SortOnlineUsers(char *listing, int condense) {
int rows;
char *sortbuf;
char *retbuf;
memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
}
- /* Do the sort */
+ /* Sort by idle time */
qsort(sortbuf, rows, SIZ, idlecmp);
+ /* Combine multiple sessions for the same user */
+ if (condense) {
+ qsort(sortbuf, rows, SIZ, rwho_username_cmp);
+ if (rows > 1) for (i=1; i<rows; ++i) if (i>0) {
+ char u1[USERNAME_SIZE];
+ char u2[USERNAME_SIZE];
+ extract_token(u1, &sortbuf[(i-1)*SIZ], 1, '|', sizeof u1);
+ extract_token(u2, &sortbuf[i*SIZ], 1, '|', sizeof u2);
+ if (!strcasecmp(u1, u2)) {
+ memcpy(&sortbuf[i*SIZ], &sortbuf[(i+1)*SIZ], (rows-i-1)*SIZ);
+ --rows;
+ --i;
+ }
+ }
+
+ qsort(sortbuf, rows, SIZ, idlecmp); /* idle sort again */
+ }
+
/* Copy back to a \n delimited list */
strcpy(retbuf, "");
for (i=0; i<rows; ++i) {
- strcat(retbuf, &sortbuf[i*SIZ]);
- if (i<(rows-1)) strcat(retbuf, "\n");
+ if (!IsEmptyStr(&sortbuf[i*SIZ])) {
+ strcat(retbuf, &sortbuf[i*SIZ]);
+ if (i<(rows-1)) strcat(retbuf, "\n");
+ }
}
- free(listing);
- free(sortbuf);
+ free(listing);
+ free(sortbuf);
return(retbuf);
}
if (!longlist) {
color(BRIGHT_WHITE);
- pprintf(" User Name Room ");
- if (screenwidth >= 80) pprintf(" Idle From host");
- pprintf("\n");
+ scr_printf(" User Name Room ");
+ if (screenwidth >= 80) scr_printf(" Idle From host");
+ scr_printf("\n");
color(DIM_WHITE);
- pprintf(" ------------------------- --------------------");
- if (screenwidth >= 80) pprintf(" ---- ------------------------");
- pprintf("\n");
+ scr_printf(" ------------------------- --------------------");
+ if (screenwidth >= 80) scr_printf(" ---- ------------------------");
+ scr_printf("\n");
}
r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
- listing = SortOnlineUsers(listing);
+ listing = SortOnlineUsers(listing, (!longlist));
if (r / 100 == 1) {
while (!IsEmptyStr(listing)) {
int isidle = 0;
extract_token(actual_room, buf, 9, '|', sizeof actual_room);
extract_token(actual_host, buf, 10, '|', sizeof actual_host);
- pprintf(" Flags: %s\n", flags);
- pprintf("Session: %d\n", extract_int(buf, 0));
- pprintf(" Name: %s\n", username);
- pprintf("In room: %s\n", roomname);
- pprintf(" Host: %s\n", fromhost);
- pprintf(" Client: %s\n", clientsoft);
- pprintf(" Idle: %ld:%02ld:%02ld\n",
+ scr_printf(" Flags: %s\n", flags);
+ scr_printf("Session: %d\n", extract_int(buf, 0));
+ scr_printf(" Name: %s\n", username);
+ scr_printf("In room: %s\n", roomname);
+ scr_printf(" Host: %s\n", fromhost);
+ scr_printf(" Client: %s\n", clientsoft);
+ scr_printf(" Idle: %ld:%02ld:%02ld\n",
(long) idlehours,
(long) idlemins,
(long) idlesecs);
if ( (!IsEmptyStr(actual_user)&&
!IsEmptyStr(actual_room)&&
!IsEmptyStr(actual_host))) {
- pprintf("(really ");
- if (!IsEmptyStr(actual_user)) pprintf("<%s> ", actual_user);
- if (!IsEmptyStr(actual_room)) pprintf("in <%s> ", actual_room);
- if (!IsEmptyStr(actual_host)) pprintf("from <%s> ", actual_host);
- pprintf(")\n");
+ scr_printf("(really ");
+ if (!IsEmptyStr(actual_user)) scr_printf("<%s> ", actual_user);
+ if (!IsEmptyStr(actual_room)) scr_printf("in <%s> ", actual_room);
+ if (!IsEmptyStr(actual_host)) scr_printf("from <%s> ", actual_host);
+ scr_printf(")\n");
}
- pprintf("\n");
+ scr_printf("\n");
} else {
if (isidle == 0) {
if (extract_int(buf, 0) == last_session) {
- pprintf(" ");
+ scr_printf(" ");
}
else {
color(BRIGHT_MAGENTA);
- pprintf("%-3s", flags);
+ scr_printf("%-3s", flags);
}
last_session = extract_int(buf, 0);
color(BRIGHT_CYAN);
- pprintf("%-25s ", username);
+ scr_printf("%-25s ", username);
color(BRIGHT_MAGENTA);
roomname[20] = 0;
- pprintf("%-20s", roomname);
+ scr_printf("%-20s", roomname);
if (screenwidth >= 80) {
- pprintf(" ");
+ scr_printf(" ");
if (idletime > rc_idle_threshold) {
/* over 1000d, must be gone fishing */
if (idlehours > 23999) {
- pprintf("fish");
+ scr_printf("fish");
/* over 10 days */
} else if (idlehours > 239) {
- pprintf("%3ldd", idlehours / 24);
+ scr_printf("%3ldd", idlehours / 24);
/* over 10 hours */
} else if (idlehours > 9) {
- pprintf("%1ldd%02ld",
+ scr_printf("%1ldd%02ld",
idlehours / 24,
idlehours % 24);
/* less than 10 hours */
}
else {
- pprintf("%1ld:%02ld", idlehours, idlemins);
+ scr_printf("%1ld:%02ld", idlehours, idlemins);
}
}
else {
- pprintf(" ");
+ scr_printf(" ");
}
- pprintf(" ");
+ scr_printf(" ");
color(BRIGHT_CYAN);
fromhost[24] = '\0';
- pprintf("%-24s", fromhost);
+ scr_printf("%-24s", fromhost);
}
- pprintf("\n");
+ scr_printf("\n");
color(DIM_WHITE);
}
}
static void statusHook(char *s) {
scr_printf(s);
- scr_flush();
}
/*
char *telnet_client_host = NULL;
char *sptr, *sptr2; /* USed to extract the nonce */
char hexstring[MD5_HEXSTRING_SIZE];
- int stored_password = 0;
char password[SIZ];
struct ctdlipcmisc chek;
struct ctdluser *myself = NULL;
eCrash_Init(¶ms);
#endif
- setIPCDeathHook(screen_delete);
setIPCErrorPrintf(scr_printf);
setCryptoStatusHook(statusHook);
scr_printf("Attaching to server...\n");
ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
if (!ipc) {
- screen_delete();
error_printf("Can't connect: %s\n", strerror(errno));
logoff(NULL, 3);
}
+ CtdlIPC_SetNetworkStatusCallback(ipc, scr_wait_indicator);
+
if (!(ipc->isLocal)) {
scr_printf("Connected to %s [%s].\n", ipc->ip_hostname, ipc->ip_address);
}
get_serv_info(ipc, telnet_client_host);
scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
ipc->ServInfo.site_location);
- scr_flush();
screenwidth = 80; /* default screen dimensions */
screenheight = 24;
if (r / 100 == 2) {
load_user_info(aaa);
- stored_password = 1;
goto PWOK;
} else {
set_stored_password(hostbuf, portbuf, "", "");
if (!IsEmptyStr(rc_password)) {
strcpy(password, rc_password);
} else {
- newprompt("\rPlease enter your password: ", password, -19);
+ newprompt("\rPlease enter your password: ", password, -(SIZ-1));
}
if (*nonce) {
color(DIM_WHITE);
if (!IsEmptyStr(rc_gotmail_cmd)) {
rv = system(rc_gotmail_cmd);
+ if (rv)
+ scr_printf("*** failed to check for mail calling %s Reason %d.\n",
+ rc_gotmail_cmd, rv);
+
}
}
if ((axlevel >= AxAideU) && (chek.needvalid > 0)) {
screenwidth = 80;
screenheight = 24;
r = CtdlIPCGetConfig(ipc, &myself, aaa);
- if (r == 2) {
- screenwidth = myself->USscreenwidth;
- screenheight = myself->USscreenheight;
- }
if (getenv("TERM") != NULL)
if (!strcmp(getenv("TERM"), "xterm")) {
have_xterm = 1;
}
-#ifdef TIOCGWINSZ
check_screen_dims();
-#endif
set_floor_mode(ipc);
}
CtdlIPCLogout(ipc);
if ((mcmd == 29) || (mcmd == 15)) {
- screen_delete();
stty_ctdl(SB_RESTORE);
formout(ipc, "goodbye");
logoff(ipc, 0);