#endif
#endif
extern pid_t forked_dump_pid; /**< Process id of forking dump process */
-static void dump_users(DESC * call_by, char *match, int doing);
+static void dump_users(DESC *call_by, char *match);
static const char *time_format_1(long int dt);
static const char *time_format_2(long int dt);
queue_eol(d); \
}
+static void
+dump_users(DESC *call_by, char *match)
+{
+ DESC *d;
+ int count = 0;
+ time_t now;
+ char tbuf1[BUFFER_LEN];
+ char tbuf2[BUFFER_LEN];
+
+ if (!GoodObject(call_by->player)) {
+ do_rawlog(LT_ERR, T("Bogus caller #%d of dump_users"), call_by->player);
+ return;
+ }
+ while (*match && *match == ' ')
+ match++;
+ now = mudtime;
+
+ if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
+ queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=html>", 19);
+ queue_newwrite(call_by, (const unsigned char *) "<PRE>", 5);
+ }
+
+ if (poll_msg[0] == '\0')
+ strcpy(poll_msg, "Doing");
+ snprintf(tbuf2, BUFFER_LEN, "%-16s %10s %6s %s\n",
+ T("Player Name"), T("On For"), T("Idle"), poll_msg);
+ queue_string(call_by, tbuf2);
+
+ for (d = descriptor_list; d; d = d->next) {
+ if (!d->connected || !GoodObject(d->player))
+ continue;
+ if (COUNT_ALL || !Hidden(d))
+ count++;
+ if (Hidden(d) || (match && !(string_prefix(Name(d->player), match))))
+ continue;
+
+ sprintf(tbuf1, "%-16s %10s %4s%c %s", Name(d->player),
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time),
+ (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' '))
+ , d->doing);
+ queue_string(call_by, tbuf1);
+ queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
+ }
+ switch (count) {
+ case 0:
+ mush_strncpy(tbuf1, T("There are no players connected."), BUFFER_LEN);
+ break;
+ case 1:
+ mush_strncpy(tbuf1, T("There is 1 player connected."), BUFFER_LEN);
+ break;
+ default:
+ snprintf(tbuf1, BUFFER_LEN, T("There are %d players connected."), count);
+ break;
+ }
+ queue_string(call_by, tbuf1);
+ if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
+ queue_newwrite(call_by, (const unsigned char *) "\n</PRE>\n", 8);
+ queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=purehtml>",
+ 23);
+ } else
+ queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
+}
+
+
int
do_command(DESC * d, char *command)
{
send_prefix(d);
dump_info(d);
send_suffix(d);
- } else if (!strncmp(command, WHO_COMMAND, strlen(WHO_COMMAND))) {
- send_prefix(d);
- dump_users(d, command + strlen(WHO_COMMAND), 0);
- send_suffix(d);
- } else if (!strncmp(command, DOING_COMMAND, strlen(DOING_COMMAND))) {
- send_prefix(d);
- dump_users(d, command + strlen(DOING_COMMAND), 1);
- send_suffix(d);
- } else if (!strncmp(command, SESSION_COMMAND, strlen(SESSION_COMMAND))) {
- send_prefix(d);
- dump_users(d, command + strlen(SESSION_COMMAND), 2);
- send_suffix(d);
- } else if (!strncmp(command, PREFIX_COMMAND, strlen(PREFIX_COMMAND))) {
+ } else if (!strncmp(command, PREFIX_COMMAND, strlen(PREFIX_COMMAND))) {
set_userstring(&d->output_prefix, command + strlen(PREFIX_COMMAND));
} else if (!strncmp(command, SUFFIX_COMMAND, strlen(SUFFIX_COMMAND))) {
set_userstring(&d->output_suffix, command + strlen(SUFFIX_COMMAND));
strcpy(global_eval_context.ucom, "");
global_eval_context.cplr = NOTHING;
} else {
- if (!check_connect(d, command))
+ j = 0;
+ if (!strncmp(command, WHO_COMMAND, strlen(WHO_COMMAND)))
+ j = strlen(WHO_COMMAND);
+ else if (!strncmp(command, DOING_COMMAND, strlen(DOING_COMMAND)))
+ j = strlen(DOING_COMMAND);
+ else if (!strncmp(command, SESSION_COMMAND, strlen(SESSION_COMMAND)))
+ j = strlen(SESSION_COMMAND);
+ if (j) {
+ send_prefix(d);
+ dump_users(d, command + j);
+ send_suffix(d);
+ } else if (!check_connect(d, command))
return 0;
}
}
queue_string_eol(call_by, "### End INFO");
}
-static void
-dump_users(DESC * call_by, char *match, int doing)
- /* doing: 0 if normal WHO, 1 if DOING, 2 if SESSION */
-{
+COMMAND(cmd_dump_users) {
DESC *d;
#ifdef COLOREDWHO
int tcount = 0;
#endif
int count = 0;
+ int doing;
time_t now;
char tbuf1[BUFFER_LEN];
- char tbuf2[BUFFER_LEN];
int csite;
+ char *match;
+ PUEBLOBUFF;
- if (!GoodObject(call_by->player)) {
+
+ match = arg_left;
+
+ if(!strcasecmp(cmd->name, "WHO"))
+ doing = 0;
+ else if(!strcasecmp(cmd->name, "SESSION"))
+ doing = 2;
+ else /* Otherwise.. whatever is called us give them the doing */
+ doing = 3;
+
+ if (!GoodObject(player)) {
do_rawlog(LT_ERR, T("Bogus caller #%d of dump_users"),
- call_by->player);
+ player);
return;
}
while (*match && *match == ' ')
* BUT flags are not shown. Privileged WHO does not show @doings.
*/
- if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
- queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=html>",
- 19);
- queue_newwrite(call_by, (const unsigned char *) "<PRE>", 5);
+ if (SUPPORT_PUEBLO) {
+ PUSE;
+ tag("PRE");
+ PEND;
+ notify_noenter(player, pbuff);
}
- if ((doing == 1) || !call_by->player || !Priv_Who(call_by->player)) {
+ if ((doing == 1) || !Priv_Who(player)) {
if (poll_msg[0] == '\0')
strcpy(poll_msg, "Doing");
- if (ShowAnsi(call_by->player))
- snprintf(tbuf2, BUFFER_LEN, "%s%-16s %4s %10s %6s %s%s\n",
+ notify_format(player, "%s%-16s %4s %10s %6s %s%s",
ANSI_HILITE, T("Player Name"), T("Aff"), T("On For"),
T("Idle"), poll_msg, ANSI_END);
- else
- snprintf(tbuf2, BUFFER_LEN, "%-16s %4s %10s %6s %s\n",
- T("Player Name"), T("Aff"), T("On For"), T("Idle"),
- poll_msg);
- queue_string(call_by, tbuf2);
} else if (doing == 2) {
- snprintf(tbuf2, BUFFER_LEN,
- "%s%-16s %6s %9s %5s %5s Des Sent Recv Pend%s\n",
- ShowAnsi(call_by->player) ? ANSI_HILITE : "",
- T("Player Name"), T("Loc #"), T("On For"), T("Idle"),
- T("Cmds"), ShowAnsi(call_by->player) ? ANSI_END : "");
- queue_string(call_by, tbuf2);
+ notify_format(player, "%s%-16s %6s %9s %5s %5s Des Sent Recv Pend%s",
+ ANSI_HILITE, T("Player Name"), T("Loc #"), T("On For"), T("Idle"),
+ T("Cmds"), ANSI_END);
} else {
- snprintf(tbuf2, BUFFER_LEN, "%s%-16s %6s %9s %5s %5s Des Host%s\n",
- ShowAnsi(call_by->player) ? ANSI_HILITE : "",
+ notify_format(player, "%s%-16s %6s %9s %5s %5s Des Host%s",
+ ANSI_HILITE,
T("Player Name"), T("Loc #"), T("On For"), T("Idle"),
- T("Cmds"), ShowAnsi(call_by->player) ? ANSI_END : "");
- queue_string(call_by, tbuf2);
+ T("Cmds"), ANSI_END);
}
for (d = descriptor_list; d; d = d->next) {
if (d->connected) {
if (!GoodObject(d->player))
continue;
- if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player
- || (call_by->player
- && Priv_Who(call_by->player)))) {
+ if (COUNT_ALL || (!Hidden(d) || player == d->player
+ || Priv_Who(player))) {
count++;
#ifdef COLOREDWHO
tcount++;
}
if (match && !(string_prefix(Name(d->player), match)))
continue;
- csite = CanSee(call_by->player, d->player);
+ csite = CanSee(player, d->player);
- if (call_by->connected && doing == 0 && call_by->player
- && Priv_Who(call_by->player)) {
+ if (doing == 0 && player && Priv_Who(player)) {
if (Hidden(d) && !csite)
continue;
sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s",
tprintf("%s%s", Name(d->player),
InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player,
- d->player) ? unparse_dbref(Location(d->
+ Can_Locate(player, d->player) ? unparse_dbref(Location(d->
player)) :
"#-1", time_format_1(now - d->connected_at),
time_format_2(now - d->last_time), csite ? d->cmds : 0,
tbuf1[71] = '\0';
strcat(tbuf1, " (Hide)");
}
- } else if (call_by->connected && doing == 2 && call_by->player
- && Priv_Who(call_by->player)) {
+ } else if (doing == 2 && Priv_Who(player)) {
sprintf(tbuf1, "%-16s %6s %9s %5s %5d %3d%c %5lu %7lu %5d",
tprintf("%s%s", Name(d->player),
InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player,
- d->player) ? unparse_dbref(Location(d->
- player)) :
+ Can_Locate(player, d->player) ? unparse_dbref(Location(d->player)) :
"#-1", time_format_1(now - d->connected_at),
time_format_2(now - d->last_time), csite ? d->cmds : 0,
csite ? d->descriptor : 0,
csite ? d->output_size : 0);
} else {
if (!Hidden(d)
- || call_by->player == d->player ||
- (call_by->player && Priv_Who(call_by->player) && (doing))) {
+ || player == d->player || (Priv_Who(player) && doing)) {
snprintf(tbuf1, BUFFER_LEN, "%-16s %4s %10s %4s%c %s",
tprintf("%s%s", Name(d->player),
InProg(d->player) ? "(P)" : ""),
}
}
- if (!Hidden(d) || (call_by->player && Priv_Who(call_by->player))) {
+ if (!Hidden(d) || Priv_Who(player)) {
#ifdef COLOREDWHO
- if (ShowAnsiColor(call_by->player))
- queue_string(call_by,
- tprintf("%s%s%s%s%s", ANSI_END,
+ notify_format(player,
+ "%s%s%s%s%s", ANSI_END,
(tcount % 2 ? "" : ANSI_HILITE),
(tcount % 2 ? ANSI_CYAN : ANSI_WHITE),
- tbuf1, ANSI_NORMAL));
+ tbuf1, ANSI_NORMAL);
+
+#else
+ notify(player, tbuf1);
- else
#endif
- queue_string(call_by, tbuf1);
- queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
}
- } else if (call_by->player && Priv_Who(call_by->player) && doing != 1
- && (!match || !*match)) {
+ } else if (Priv_Who(player) && doing != 1 && (!match || !*match)) {
#ifdef COLOREDWHO
tcount++;
#endif
d->input_chars, d->output_chars, d->output_size);
}
#ifdef COLOREDWHO
- if (ShowAnsiColor(call_by->player))
- queue_string(call_by,
- tprintf("%s%s%s%s%s", ANSI_NORMAL,
+ notify_format(player,
+ "%s%s%s%s%s", ANSI_NORMAL,
tcount % 2 ? "" : ANSI_HILITE,
tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1,
- ANSI_NORMAL));
- else
+ ANSI_NORMAL);
+#else
+ notify(player, tbuf1);
#endif
- queue_string(call_by, tbuf1);
- queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
}
}
switch (count) {
}
#ifdef COLOREDWHO
- if (ShowAnsiColor(call_by->player))
- queue_string(call_by,
- tprintf("%s%s%s%s%s", ANSI_NORMAL,
- (tcount + 1) % 2 ? "" : ANSI_HILITE,
+ notify_format(player, "%s%s%s%s%s", ANSI_NORMAL, (tcount + 1) % 2 ? "" : ANSI_HILITE,
(tcount + 1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1,
- ANSI_NORMAL));
- else
+ ANSI_NORMAL);
+#else
+ notify(player, tbuf1);
#endif
- queue_string(call_by, tbuf1);
- if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
- queue_newwrite(call_by, (const unsigned char *) "\n</PRE>\n", 8);
- queue_newwrite(call_by,
- (const unsigned char *) "<img xch_mode=purehtml>", 23);
- } else
- queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
+ if (SUPPORT_PUEBLO) {
+ PUSE;
+ tag_cancel("PRE");
+ PEND;
+ notify_noenter(player, pbuff);
+ }
+
}
static const char *