struct DLModule_Info *Dynamic_Module_Init(void)
{
+ CtdlSendExpressMessageFunc = send_express_message;
+
CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat");
CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for express messages");
CtdlRegisterProtoHook(cmd_gexp, "GEXP", "Get express messages");
else
un = CC->usersupp.fullname;
if (flag == 1) {
- sprintf(bcast, ":|<%s %s>", un, cmdbuf);
+ snprintf(bcast, sizeof bcast, ":|<%s %s>", un, cmdbuf);
} else if (flag == 0) {
- sprintf(bcast, "%s|%s", un, cmdbuf);
+ snprintf(bcast, sizeof bcast, "%s|%s", un, cmdbuf);
} else if (flag == 2) {
- sprintf(bcast, ":|<%s whispers %s>", un, cmdbuf);
+ snprintf(bcast, sizeof bcast, ":|<%s whispers %s>", un, cmdbuf);
}
if ((strcasecmp(cmdbuf, "NOOP")) && (flag != 2)) {
fp = fopen(CHATLOG, "a");
clnew->chat_username[sizeof clnew->chat_username - 1] = 0;
} else
clnew->chat_username[0] = '\0';
- strcpy(clnew->chat_text, bcast);
+ safestrncpy(clnew->chat_text, bcast, sizeof clnew->chat_text);
/* Here's the critical section.
* First, add the new message to the queue...
}
/*
- * List users in chat. Setting allflag to 1 also lists users elsewhere.
+ * List users in chat.
+ * allflag == 0 = list users in chat
+ * 1 = list users in chat, followed by users not in chat
+ * 2 = display count only
*/
void do_chat_listing(int allflag)
{
struct CitContext *ccptr;
+ int count = 0;
- cprintf(":|\n:| Users currently in chat:\n");
+ if ((allflag == 0) || (allflag == 1))
+ cprintf(":|\n:| Users currently in chat:\n");
begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
+ if (!strcasecmp(ccptr->cs_room, "<chat>")) ++count;
if ((!strcasecmp(ccptr->cs_room, "<chat>"))
&& ((ccptr->cs_flags & CS_STEALTH) == 0)) {
- cprintf(":| %-25s <%s>\n", (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user, ccptr->chat_room);
+ if ((allflag == 0) || (allflag == 1))
+ cprintf(":| %-25s <%s>\n", (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user, ccptr->chat_room);
}
}
}
}
end_critical_section(S_SESSION_TABLE);
+
+ if (allflag == 2) {
+ if (count > 1)
+ cprintf(":|There are %d users here.\n", count);
+ else
+ cprintf(":|Note: you are the only one here.\n");
+ }
+
cprintf(":|\n");
}
}
strcpy(CC->chat_room, "Main room");
- strcpy(hold_cs_room, CC->cs_room);
+ safestrncpy(hold_cs_room, CC->cs_room, sizeof hold_cs_room);
CC->cs_flags = CC->cs_flags | CS_CHAT;
set_wtmpsupp("<chat>");
cprintf("%d Entering chat mode (type '/help' for available commands)\n",
}
strcpy(cmdbuf, "");
+ do_chat_listing(2);
+
while (1) {
int ok_cmd;
mallok(sizeof (struct ExpressMessage));
memset(newmsg, 0,
sizeof (struct ExpressMessage));
- strcpy(newmsg->sender, lun);
+ safestrncpy(newmsg->sender, lun,
+ sizeof newmsg->sender);
if (!strcasecmp(x_user, "broadcast"))
newmsg->flags |= EM_BROADCAST;
newmsg->text = mallok(msglen);
fprintf(fp, "N%s%c", NODENAME, 0);
fprintf(fp, "M%s\n%c", x_msg, 0);
fclose(fp);
- save_message(CC->temp, "", config.c_logpages, M_LOCAL, 1);
+ save_message(CC->temp, "", config.c_logpages, MES_LOCAL, 1);
unlink(CC->temp);
}
return (message_sent);