Exemplo n.º 1
0
const char *
mfn_idle(MFUNARGS)
{
	dbref obj = mesg_dbref_raw(descr, player, what, perms, argv[0]);
	int conn;

	if (obj == PERMDENIED)
		ABORT_MPI("IDLE", "Permission denied.");
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		return "-1";
	if (Typeof(obj) != TYPE_PLAYER)
		obj = OWNER(obj);
	conn = least_idle_player_descr(obj);
	if (!conn)
		return "-1";
	snprintf(buf, BUFFER_LEN, "%d", pidle(conn));
	return buf;
}
Exemplo n.º 2
0
void 
prim_conidle(PRIM_PROTOTYPE)
{
    /* int -- int */
    CHECKOP(1);
    oper1 = POP();
    if (mlev < (tp_compatible_muf ? LM3 : LM2))
	abort_interp(tp_compatible_muf ? "M3 prim" : "M2 prim");
    if (oper1->type != PROG_INTEGER)
	abort_interp("Argument not an integer (1)");
    result = oper1->data.number;
    if ((result < 1) || (result > pcount()))
	abort_interp("Invalid connection number (1)");
    result = pidle(result);
    CHECKOFLOW(1);
    CLEAR(oper1);
    PushInt(result);
}
Exemplo n.º 3
0
/*------------------------------------------------------------------------
 *  lfing  -  print local FINGER info on the given descriptor
 *------------------------------------------------------------------------
 */
int
lfing(char *nam, int output)
{
	struct user	*pue;
	int		tt, uc;
	u_long		now;
	char		*p, buf[128];

	gettime(&now);
	sprintf(buf, "%-9s%-21s%3s%6s  %-12s\n", "Login", "Name", "TTY",
		"Idle", "Login Time");
	if (nam == NULL || *nam == '\0' || *nam == '\r') {
		uc = 0;
		for (tt=0; tt<Ntty; ++tt) {
			struct tty	*ptty = &ttytab[tt];

			if (ptty->tty_state == TTYS_FREE)
				continue;
			if (ptty->tty_uid < 0)
				continue;
			pue = getuser(ptty->tty_uid);
			if (pue == 0)
				continue;
			if (uc++ == 0)
				write(output, buf, strlen(buf));
			sprintf(buf, "%-9s%-21s%2s%c%6s  ",
				pue->ue_login, pue->ue_name,
				tt ? "tt" : " c", tt ? tt + '0' : 'o',
				pidle(now - ptty->tty_ctime));
			p = buf + strlen(buf);
			ascdate(ptty->tty_ltime, p);
			strcat(p, "\n");
			write(output, buf, strlen(buf));
		}
		if (uc == 0)
			write(output, "no one logged in\n", 17);
		return OK;
	}
write(output, "Not implemented\n", 16);
	/* not implemented (yet) */
	return SYSERR;
}