Ejemplo n.º 1
0
static UTF8 *AcquireColorLetters(dbref player, dbref target)
{
    int   aflags;
    dbref aowner;

    // Get the value of the object's '@color' attribute (or on a parent).
    //
    UTF8 *color_attr = alloc_lbuf("AcquireColor.1");
    atr_pget_str(color_attr, target, A_COLOR, &aowner, &aflags);

    if ('\0' == color_attr[0])
    {
        free_lbuf(color_attr);
        return NULL;
    }
    else
    {
        UTF8 *AnsiCodes = alloc_lbuf("AcquireColor.2");
        UTF8 *ac = AnsiCodes;
        mux_exec(color_attr, LBUF_SIZE-1, AnsiCodes, &ac, player, target, target,
                AttrTrace(aflags, EV_EVAL|EV_TOP|EV_FCHECK), NULL, 0);
        *ac = '\0';
        free_lbuf(color_attr);
        return AnsiCodes;
    }
}
Ejemplo n.º 2
0
static void show_quota(dbref player, dbref victim)
{
    dbref aowner;
    int aflags;
    UTF8 *buff = alloc_lbuf("show_quota");

    atr_get_str(buff, victim, A_QUOTA, &aowner, &aflags);
    int aq = mux_atol(buff);
    atr_get_str(buff, victim, A_RQUOTA, &aowner, &aflags);
    int rq = aq - mux_atol(buff);

    mux_field fldName = StripTabsAndTruncate(Name(victim), buff, LBUF_SIZE-1, 16);

    if (!Free_Quota(victim))
    {
        mux_sprintf(buff + fldName.m_byte, LBUF_SIZE - fldName.m_byte,
                    T(" Quota: %9d  Used: %9d"), aq, rq);
    }
    else
    {
        mux_sprintf(buff + fldName.m_byte, LBUF_SIZE - fldName.m_byte,
                     T(" Quota: UNLIMITED  Used: %9d"), rq);
    }
    notify_quiet(player, buff);
    free_lbuf(buff);
}
Ejemplo n.º 3
0
void interp_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix,
					char *true_text, char *false_text)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;

	buf = alloc_lbuf("interp_nametab");
	bp = buf;
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	nt = ntab;
	while (nt->name) {
		if(God(player) || check_access(player, nt->perm)) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			*bp++ = '.';
			*bp++ = '.';
			*bp++ = '.';
			if((flagword & nt->flag) != 0)
				cp = true_text;
			else
				cp = false_text;
			while (*cp)
				*bp++ = *cp++;
			if((++nt)->name)
				*bp++ = ';';
		}
	}
	*bp = '\0';
	notify(player, buf);
	free_lbuf(buf);
}
Ejemplo n.º 4
0
static void 
open_exit(dbref player, dbref loc, char *direction, char *linkto, int key)
{
    dbref exit;
    char *tpr_buff, *tprp_buff;

    if (!Good_obj(loc))
	return;

    if (!direction || !*direction) {
	notify_quiet(player, "Open where?");
	return;
    } else if (!controls(player, loc) && !could_doit(player, loc, A_LOPEN, 0, 0)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    exit = create_obj(player, TYPE_EXIT, direction, 0);
    if (exit == NOTHING)
	return;

    /* Initialize everything and link it in. */

    s_Exits(exit, loc);
    s_Next(exit, Exits(loc));
    s_Exits(loc, exit);

    /* and we're done */

    if ( !(key & SIDEEFFECT ) )
       notify_quiet(player, "Opened.");

    /* See if we should do a link */

    if (!linkto || !*linkto)
	return;

    loc = parse_linkable_room(player, linkto);
    if (loc != NOTHING) {

	/* Make sure the player passes the link lock */

	if ((loc != HOME) && !could_doit(player, loc, A_LLINK, 1, 0)) {
	    notify_quiet(player, "You can't link to there.");
	    return;
	}
	/* Link it if the player can pay for it */

	if (!payfor(player, mudconf.linkcost)) {
            tprp_buff = tpr_buff = alloc_lbuf("open_exit");
	    notify_quiet(player,
			 safe_tprintf(tpr_buff, &tprp_buff, "You don't have enough %s to link.",
				 mudconf.many_coins));
            free_lbuf(tpr_buff);
	} else {
	    s_Location(exit, loc);
	    if ( !(key & SIDEEFFECT ) )
	       notify_quiet(player, "Linked.");
	}
    }
}
Ejemplo n.º 5
0
// Check for a matching named reference.
//
static dbref absolute_named_reference(UTF8 *name)
{
    if (  NULL == name
       || '\0' == name[0])
    {
        return NOTHING;
    }

    mux_string sRef(name);
    if ('_' != name[0])
    {
        sRef.append(T("."));
        sRef.append(md.player);
    }

    UTF8 *pReferenceName = alloc_lbuf("absolute_named_reference");
    size_t nReferenceName = 0;
    nReferenceName = sRef.export_TextPlain(pReferenceName);

    struct reference_entry *result = (reference_entry *)hashfindLEN(
        pReferenceName, nReferenceName, &mudstate.reference_htab);
    free_lbuf(pReferenceName);

    if (  NULL != result
       && Good_obj(result->target))
    {
        return result->target;
    }
    else
    {
        return NOTHING;
    }
}
Ejemplo n.º 6
0
void listset_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix,
					 int list_if_none)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;
	int got_one;

	buf = bp = alloc_lbuf("listset_nametab");
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	nt = ntab;
	got_one = 0;
	while (nt->name) {
		if(((flagword & nt->flag) != 0) && (God(player) ||
											check_access(player, nt->perm))) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			got_one = 1;
		}
		nt++;
	}
	*bp = '\0';
	if(got_one || list_if_none)
		notify(player, buf);
	free_lbuf(buf);
}
Ejemplo n.º 7
0
void display_nametab(dbref player, NAMETAB * ntab, char *prefix,
					 int list_if_none)
{
	char *buf, *bp, *cp;
	NAMETAB *nt;
	int got_one;

	buf = alloc_lbuf("display_nametab");
	bp = buf;
	got_one = 0;
	for(cp = prefix; *cp; cp++)
		*bp++ = *cp;
	for(nt = ntab; nt->name; nt++) {
		if(God(player) || check_access(player, nt->perm)) {
			*bp++ = ' ';
			for(cp = nt->name; *cp; cp++)
				*bp++ = *cp;
			got_one = 1;
		}
	}
	*bp = '\0';
	if(got_one || list_if_none)
		notify(player, buf);
	free_lbuf(buf);
}
Ejemplo n.º 8
0
void display_flagtab(dbref player)
{
    UTF8 *buf, *bp;
    FLAGNAMEENT *fp;

    bp = buf = alloc_lbuf("display_flagtab");
    safe_str(T("Flags:"), buf, &bp);
    for (fp = gen_flag_names; fp->flagname; fp++)
    {
        FLAGBITENT *fbe = fp->fbe;
        if (  (  (fbe->listperm & CA_WIZARD)
              && !Wizard(player))
           || (  (fbe->listperm & CA_GOD)
              && !God(player)))
        {
            continue;
        }
        safe_chr(' ', buf, &bp);
        safe_str(fp->flagname, buf, &bp);
        if (fbe->flaglett != ' ')
        {
            safe_chr('(', buf, &bp);
            if (!fp->bPositive)
            {
                safe_chr('!', buf, &bp);
            }
            safe_chr(fbe->flaglett, buf, &bp);
            safe_chr(')', buf, &bp);
        }
    }
    *bp = '\0';
    notify(player, buf);
    free_lbuf(buf);
}
Ejemplo n.º 9
0
Archivo: eval.c Proyecto: gtaylor/btmux
static void tcache_finish(dbref player)
{
	TCENT *xp;

	while (tcache_head != NULL) {
		xp = tcache_head;
		tcache_head = xp->next;
		notify_printf(Owner(player), "%s(#%d)} '%s' -> '%s'",
					  Name(player), player, xp->orig, xp->result);
		free_lbuf(xp->orig);
		free_lbuf(xp->result);
		free_sbuf(xp);
	}
	tcache_top = 1;
	tcache_count = 0;
}
Ejemplo n.º 10
0
Archivo: eval.c Proyecto: gtaylor/btmux
int get_gender(dbref player)
{
	char first, *atr_gotten;
	dbref aowner;
	long aflags;

	atr_gotten = atr_pget(player, A_SEX, &aowner, &aflags);
	first = *atr_gotten;
	free_lbuf(atr_gotten);
	switch (first) {
	case 'P':
	case 'p':
		return 4;
	case 'M':
	case 'm':
		return 3;
	case 'F':
	case 'f':
	case 'W':
	case 'w':
		return 2;
	default:
		return 1;
	}
}
Ejemplo n.º 11
0
// Fetch attribute text. Use a revolving queue of LBUFFS
//
char *my_atr_get(dbref obj, const char *atrname)
{
    int atr, aflags;
    dbref aowner;
    char *value;
    char name[SBUF_SIZE];
    static char buff[LBUF_SIZE][NUM_BUFFS];
    static int x = 0;

    x = (x + 1) % NUM_BUFFS;

    // Crashes and burns without this. Dunno why.
    strncpy(name, atrname, SBUF_SIZE - 1);
#ifdef TM3
    int alen;
    atr = mkattr(name);
    value = atr_pget(obj, atr, &aowner, &aflags, &alen);
#endif

#ifdef MUX
    atr = mkattr(GOD, name);
    value = atr_pget(obj, atr, &aowner, &aflags);
#endif

    strncpy(buff[x], value, LBUF_SIZE - 1);
    free_lbuf(value);

    return buff[x];
}
Ejemplo n.º 12
0
void help_helper(dbref executor, int iHelpfile, UTF8 *topic_arg,
    UTF8 *buff, UTF8 **bufc)
{
    if (!ValidateHelpFileIndex(iHelpfile))
    {
        return;
    }

    size_t nTopic;
    const UTF8 *topic = MakeCanonicalTopicName(topic_arg, nTopic);

    CHashTable *htab = mudstate.aHelpDesc[iHelpfile].ht;
    struct help_entry *htab_entry =
        (struct help_entry *)hashfindLEN(topic, nTopic, htab);

    if (htab_entry)
    {
        UTF8 *result = alloc_lbuf("help_helper");
        if (ReportTopic(executor, htab_entry, iHelpfile, result))
        {
            safe_str(result, buff, bufc);
        }
        else
        {
            safe_str(T("#-1 ERROR"), buff, bufc);
        }
        free_lbuf(result);
    }
    else
    {
        safe_str(T("#-1 TOPIC DOES NOT EXIST"), buff, bufc);
    }
}
Ejemplo n.º 13
0
static void help_write(dbref executor, UTF8 *topic_arg, int iHelpfile)
{
    size_t nTopic;
    const UTF8 *topic = MakeCanonicalTopicName(topic_arg, nTopic);

    CHashTable *htab = mudstate.aHelpDesc[iHelpfile].ht;
    struct help_entry *htab_entry =
        (struct help_entry *)hashfindLEN(topic, nTopic, htab);

    if (htab_entry)
    {
        UTF8 *result = alloc_lbuf("help_write");
        if (ReportTopic(executor, htab_entry, iHelpfile, result))
        {
            notify(executor, result);
        }
        else
        {
            notify(executor, T("Sorry, that function is temporarily unavailable."));
        }
        free_lbuf(result);
    }
    else
    {
        ReportMatchedTopics(executor, topic, htab);
        return;
    }
}
Ejemplo n.º 14
0
Archivo: db_rw.c Proyecto: chazu/btmux
static int get_list(FILE * f, dbref i, int new_strings)
{
	dbref atr;
	int c;
	char *buff;

	buff = alloc_lbuf("get_list");
	while (1) {
		switch (c = getc(f)) {
		case '>':				/*
								 * read # then string 
								 */
			atr = getref(f);
			if(atr > 0) {
				/*
				 * Store the attr 
				 */

				atr_add_raw(i, atr, (char *) getstring_noalloc(f,
															   new_strings));
			} else {
				/*
				 * Silently discard 
				 */

				getstring_noalloc(f, new_strings);
			}
			break;
		case '\n':				/*
								 * ignore newlines. They're due to v(r). 
								 */
			break;
		case '<':				/*
								 * end of list 
								 */
			free_lbuf(buff);
			c = getc(f);
			if(c != '\n') {
				ungetc(c, f);
				fprintf(stderr, "No line feed on object %d\n", i);
				return 1;
			}
			return 1;
		default:
			fprintf(stderr,
					"Bad character '%c' when getting attributes on object %d\n",
					c, i);
			/*
			 * We've found a bad spot.  I hope things aren't * *
			 * * * * * too bad. 
			 */

			(void) getstring_noalloc(f, new_strings);
		}
	}
}
Ejemplo n.º 15
0
int mushDoorOpen(DESC *d, int nArgs, char *args[], int id) {
  dbref loc, player = d->player;
  int sock, i_found, retval;
  char *t_buff, *t_bufptr, *s_addy, *s_port, *s_strtok;

  i_found = 1;
  t_bufptr = t_buff = alloc_lbuf("mush_doors");
  s_port = s_strtok = NULL;
  retval = parse_dynhelp(player, player, 0, (char *)"doors", args[0], t_buff, t_bufptr, 1); 
  if ( t_buff && *t_buff && 
       ((strstr(t_buff, (char *)"No entry for") != NULL) ||
        (strstr(t_buff, (char *)"Here are the entries which match") != NULL) ||
        (strstr(t_buff, (char *)"Sorry, that file") != NULL)) ) 
     i_found = 0;
  loc = Location(player);
  if ( i_found && *t_buff && args[0] && *args[0]) {
     s_addy = strtok_r(t_buff, " \t\r\n", &s_strtok);
     if ( s_addy )
        s_port = strtok_r(NULL, " \t\r\n", &s_strtok);
     if ( s_addy && s_port )
        sock = door_tcp_connect(s_addy, s_port, d, id);
     else
        sock = -1;
     if (sock < 0) {
       queue_string(desc_in_use, "Mush connection failed\r\n");
       free_lbuf(t_buff);
       return -1;
     } else {
       queue_string(desc_in_use, "*** CONNECTED ***\r\n");
     }
  } else if ( !i_found || (i_found && args[0] && *args[0]) ) {
     if ( strstr(t_buff, (char *)"Sorry, that file") != NULL )
        queue_string(desc_in_use, "There are currently no mush doors configured.\r\n");
     else
        queue_string(desc_in_use, "Unrecognized mush.  Can not establish connection.\r\n");
     free_lbuf(t_buff);
     return -1;
  } else if ( i_found && (!args[0] || !*args[0]) && t_buff ) {
     queue_string(desc_in_use, t_buff);
  }
  free_lbuf(t_buff);
  return 1;
}
Ejemplo n.º 16
0
static void ShowPsLine(BQUE *tmp)
{
    char *bufp = unparse_object(Show_Player, tmp->executor, false);
    if (tmp->IsTimed && (Good_obj(tmp->sem)))
    {
        CLinearTimeDelta ltd = tmp->waittime - Show_lsaNow;
        notify(Show_Player, tprintf("[#%d/%d]%s:%s", tmp->sem, ltd.ReturnSeconds(), bufp, tmp->comm));
    }
    else if (tmp->IsTimed)
    {
        CLinearTimeDelta ltd = tmp->waittime - Show_lsaNow;
        notify(Show_Player, tprintf("[%d]%s:%s", ltd.ReturnSeconds(), bufp, tmp->comm));
    }
    else if (Good_obj(tmp->sem))
    {
        notify(Show_Player, tprintf("[#%d]%s:%s", tmp->sem, bufp, tmp->comm));
    }
    else
    {
        notify(Show_Player, tprintf("%s:%s", bufp, tmp->comm));
    }
    char *bp = bufp;
    if (Show_Key == PS_LONG)
    {
        for (int i = 0; i < tmp->nargs; i++)
        {
            if (tmp->env[i] != NULL)
            {
                safe_str("; Arg", bufp, &bp);
                safe_chr((char)(i + '0'), bufp, &bp);
                safe_str("='", bufp, &bp);
                safe_str(tmp->env[i], bufp, &bp);
                safe_chr('\'', bufp, &bp);
            }
        }
        *bp = '\0';
        bp = unparse_object(Show_Player, tmp->enactor, false);
        notify(Show_Player, tprintf("   Enactor: %s%s", bp, bufp));
        free_lbuf(bp);
    }
    free_lbuf(bufp);
}
Ejemplo n.º 17
0
void do_report(dbref executor, dbref caller, dbref enactor, int extra)
{
    UNUSED_PARAMETER(caller);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(extra);

    char *buff = alloc_mbuf("do_report");
    int nBin[NPERIODS];
    int i;

    for (i = 0; i < NPERIODS; i++)
    {
        nBin[i] = 0;
    }

    CLinearTimeAbsolute ltaNow, ltaPlayer;
    ltaNow.GetLocal();

    const int PeriodInSeconds = 28800;

    int iPlayer;
    DO_WHOLE_DB(iPlayer)
    {
        if (isPlayer(iPlayer))
        {
            int aowner, aflags;
            char *player_last = atr_get(iPlayer, A_LAST, &aowner, &aflags);

            if (ltaPlayer.SetString(player_last))
            {
                CLinearTimeDelta ltd(ltaPlayer, ltaNow);
                int ltdSeconds = ltd.ReturnSeconds();
                int iBin = ltdSeconds / PeriodInSeconds;
                if (0 <= iBin && iBin < NPERIODS)
                {
                    nBin[iBin]++;
                }
            }
            free_lbuf(player_last);
        }
    }

    int iHour, nSum = 0;
    notify(executor, "Day   Hours     Players  Total");
    for (i = 0, iHour = 0; i < NPERIODS; i++, iHour += 8)
    {
        nSum += nBin[i];
        mux_sprintf(buff, MBUF_SIZE, "%3d %03d - %03d: %6d %6d",
            iHour/24 + 1, iHour, iHour+8, nBin[i], nSum);
        notify(executor, buff);
    }
    free_mbuf(buff);
}
Ejemplo n.º 18
0
Archivo: eval.c Proyecto: gtaylor/btmux
static void tcache_add(char *orig, char *result)
{
	char *tp;
	TCENT *xp;

	if(strcmp(orig, result)) {
		tcache_count++;
		if(tcache_count <= mudconf.trace_limit) {
			xp = (TCENT *) alloc_sbuf("tcache_add.sbuf");
			tp = alloc_lbuf("tcache_add.lbuf");
			StringCopy(tp, result);
			xp->orig = orig;
			xp->result = tp;
			xp->next = tcache_head;
			tcache_head = xp;
		} else {
			free_lbuf(orig);
		}
	} else {
		free_lbuf(orig);
	}
}
Ejemplo n.º 19
0
void decompile_powers(dbref player, dbref thing, char *thingname)
{
    POWER f1, f2;
    POWERENT *fp;
    char *buf;
    /*
     * Report generic powers
     */
    f1 = Powers(thing);
    f2 = Powers2(thing);

    for (fp = gen_powers; fp->powername; fp++) {
	/*
	 * Skip if we shouldn't decompile this power
	 */
	if (fp->listperm & CA_NO_DECOMP) {
	    continue;
	}

	/*
	 * Skip if this power is not set
	 */

	if (fp->powerpower & POWER_EXT) {
	    if (!(f2 & fp->powervalue)) {
		continue;
	    }
	} else {
	    if (!(f1 & fp->powervalue)) {
		continue;
	    }
	}

	/*
	 * Skip if we can't see this power
	 */

	if (!check_access(player, fp->listperm)) {
	    continue;
	}

	/*
	 * We made it this far, report this power
	 */
	buf = strip_ansi(thingname);
	notify_check(player, player, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN, "@power %s=%s", buf, fp->powername);
	free_lbuf(buf);
    }
}
Ejemplo n.º 20
0
dbref absolute_nref(char *str)
{
    char *p, *q, *buf, *bp;
    dbref *np, nref;
    /*
     * Global or local reference? Global references are automatically
     * * prepended with an additional underscore. i.e., #__foo_ is a global
     * * reference, and #_foo_ is a local reference.
     * * Our beginning and end underscores have already been stripped, so
     * * we would see only _foo or foo.
     * *
     * * We are not allowed to nibble our buffer, because we've got a
     * * pointer into the match string. Therefore we must copy it.
     * * If we're matching locally we copy the dbref of the owner first,
     * * which means that we then need to worry about buffer size.
     */
    buf = alloc_lbuf("absolute_nref");

    if (*str == '_') {
	for (p = buf, q = str; *q; p++, q++) {
	    *p = tolower(*q);
	}

	*p = '\0';
    } else {
	bp = buf;
	safe_ltos(buf, &bp, Owner(md.player), LBUF_SIZE);
	safe_chr('.', buf, &bp);

	for (q = str; *q; q++) {
	    safe_chr(tolower(*q), buf, &bp);
	}

	*bp = '\0';
    }

    np = (int *) hashfind(buf, &mudstate.nref_htab);

    if (np && Good_obj(*np)) {
	nref = *np;
    } else {
	nref = NOTHING;
    }

    free_lbuf(buf);
    return nref;
}
Ejemplo n.º 21
0
dbref create_guest(char *name, char *password)
{
	dbref player;
	char *buff;

	if(!Wizard(mudconf.guest_nuker) || !Good_obj(mudconf.guest_nuker))
		mudconf.guest_nuker = 1;

	buff = alloc_lbuf("create_guest");

	/*
	 * Make the player. 
	 */

	player = create_player(name, password, mudconf.guest_nuker, 0, 1);

	if(player == NOTHING) {
		log_text("GUEST: failed in create_player\n");
		return NOTHING;
	}
	/*
	 * Turn the player into a guest. 
	 */

	s_Guest(player);
	move_object(player, mudconf.start_room);
	s_Flags(player, Flags(player) & ~WIZARD);
	s_Pennies(player, Pennies(mudconf.guest_char));
	s_Zone(player, Zone(mudconf.guest_char));
	s_Parent(player, Parent(mudconf.guest_char));

	/*
	 * Make sure the guest is locked. 
	 */
	do_lock(player, player, A_LOCK, tprintf("#%d", player), "me");
	do_lock(player, player, A_LENTER, tprintf("#%d", player), "me");

	/*
	 * Copy all attributes. 
	 */
	atr_cpy(GOD, player, mudconf.guest_char);
	free_lbuf(buff);
	return player;
}
Ejemplo n.º 22
0
int nfy_que(dbref sem, int attr, int key, int count)
{
    int cSemaphore = 1;
    if (attr)
    {
        int   aflags;
        dbref aowner;
        char *str = atr_get(sem, attr, &aowner, &aflags);
        cSemaphore = mux_atol(str);
        free_lbuf(str);
    }

    Notify_Num_Done = 0;
    if (cSemaphore > 0)
    {
        Notify_Key     = key;
        Notify_Sem     = sem;
        Notify_Attr    = attr;
        Notify_Num_Max = count;
        if (  key == NFY_NFY
           || key == NFY_QUIET)
        {
            scheduler.TraverseOrdered(CallBack_NotifySemaphoreFirstOrQuiet);
        }
        else
        {
            scheduler.TraverseUnordered(CallBack_NotifySemaphoreDrainOrAll);
        }
    }

    // Update the sem waiters count.
    //
    if (  NFY_NFY == key
       || NFY_QUIET == key)
    {
        add_to(sem, -count, attr);
    }
    else
    {
        atr_clr(sem, attr);
    }

    return Notify_Num_Done;
}
Ejemplo n.º 23
0
HS_DBREF CHSInterface::GetLock(int objnum, HS_LOCKTYPE lock)
{
#ifdef PENNMUSH                 // No change in code between versions
    boolexp boolExp = getlock(objnum, Use_Lock);

    if (boolExp == TRUE_BOOLEXP)
    {
        return NOTHING;
    }
    else
    {
        return strtodbref(unparse_boolexp(objnum, boolExp, UB_DBREF));
    }
#endif

#if defined(TM3) || defined(MUX)
    char *value;
    BOOLEXP *key;
    int aowner, aflags;
    dbref lockobj;

#ifdef TM3
    int alen;
    value = atr_get((dbref) objnum, A_LUSE, &aowner, &aflags, &alen);
#else
    value = atr_get((dbref) objnum, A_LUSE, &aowner, &aflags);
#endif
    key = parse_boolexp((dbref) objnum, value, 1);
    free_lbuf(value);
    if (key == TRUE_BOOLEXP)
    {
        free_boolexp(key);
        return NOTHING;
    }
    else
    {
        lockobj = key->thing;
        free_boolexp(key);
        return lockobj;
    }
#endif
}
Ejemplo n.º 24
0
// ---------------------------------------------------------------------------
// add_to: Adjust an object's queue or semaphore count.
//
static int add_to(dbref executor, int am, int attrnum)
{
    int aflags;
    dbref aowner;

    char *atr_gotten = atr_get(executor, attrnum, &aowner, &aflags);
    int num = mux_atol(atr_gotten);
    free_lbuf(atr_gotten);
    num += am;

    char buff[20];
    size_t nlen = 0;
    *buff = '\0';
    if (num)
    {
        nlen = mux_ltoa(num, buff);
    }
    atr_add_raw_LEN(executor, attrnum, buff, nlen);
    return num;
}
Ejemplo n.º 25
0
static void NDECL(check_cron)
{
    struct tm *ltime;
    int minute, hour, dom, month, dow;
    CRONTAB *crp;
    char *cmd;
    dbref aowner;
    int aflags, alen;

    /* Convert our time to a zero basis, so the elements can be used
     * as indices.
     */

    ltime = localtime(&mudstate.events_counter);
    minute = ltime->tm_min - FIRST_MINUTE;
    hour = ltime->tm_hour - FIRST_HOUR;
    dom = ltime->tm_mday - FIRST_DOM;
    month = ltime->tm_mon + 1 - FIRST_MONTH; /* must convert 0-11 to 1-12 */
    dow = ltime->tm_wday - FIRST_DOW;

    /* Do it if the minute, hour, and month match, plus a day selection
     * matches. We handle stars and the day-of-month vs. day-of-week
     * exactly like Unix (Vixie) cron does.
     */

    for (crp = cron_head; crp != NULL; crp = crp->next) {
	if (bit_test(crp->minute, minute) &&
	    bit_test(crp->hour, hour) &&
	    bit_test(crp->month, month) &&
	    (((crp->flags & DOM_STAR) || (crp->flags & DOW_STAR)) ?
	     (bit_test(crp->dow, dow) && bit_test(crp->dom, dom)) :
	     (bit_test(crp->dow, dow) || bit_test(crp->dom, dom)))) {
	    cmd = atr_pget(crp->obj, crp->atr, &aowner, &aflags, &alen);
	    if (*cmd && Good_obj(crp->obj)) {
		wait_que(crp->obj, crp->obj, 0, NOTHING, 0, cmd,
			 (char **) NULL, 0, NULL);
	    }
	    free_lbuf(cmd);
	}
    }
}
Ejemplo n.º 26
0
static void ReportMatchedTopics(dbref executor, const UTF8 *topic, CHashTable *htab)
{
    bool matched = false;
    UTF8 *topic_list = NULL;
    UTF8 *buffp = NULL;
    struct help_entry *htab_entry;
    for (htab_entry = (struct help_entry *)hash_firstentry(htab);
         htab_entry != NULL;
         htab_entry = (struct help_entry *)hash_nextentry(htab))
    {
        mudstate.wild_invk_ctr = 0;
        if (  htab_entry->key
           && quick_wild(topic, htab_entry->key))
        {
            if (!matched)
            {
                matched = true;
                topic_list = alloc_lbuf("help_write");
                buffp = topic_list;
            }
            safe_str(htab_entry->key, topic_list, &buffp);
            safe_chr(' ', topic_list, &buffp);
            safe_chr(' ', topic_list, &buffp);
        }
    }

    if (!matched)
    {
        notify(executor, tprintf(T("No entry for \xE2\x80\x98%s\xE2\x80\x99."), topic));
    }
    else
    {
        notify(executor, tprintf(T("Here are the entries which match \xE2\x80\x98%s\xE2\x80\x99:"), topic));
        *buffp = '\0';
        notify(executor, topic_list);
        free_lbuf(topic_list);
    }
}
Ejemplo n.º 27
0
void display_flagtab( dbref player ) {
    char *buf, *bp;

    FLAGENT *fp;

    bp = buf = alloc_lbuf( "display_flagtab" );
    safe_str( ( char * ) "Flags:", buf, &bp );
    for( fp = gen_flags; fp->flagname; fp++ ) {
        if( ( fp->listperm & CA_WIZARD ) && !Wizard( player ) ) {
            continue;
        }
        if( ( fp->listperm & CA_GOD ) && !God( player ) ) {
            continue;
        }
        safe_chr( ' ', buf, &bp );
        safe_str( ( char * ) fp->flagname, buf, &bp );
        safe_chr( '(', buf, &bp );
        safe_chr( fp->flaglett, buf, &bp );
        safe_chr( ')', buf, &bp );
    }
    *bp = '\0';
    notify( player, buf );
    free_lbuf( buf );
}
Ejemplo n.º 28
0
void display_powertab(dbref player)
{
    char *buf, *bp;
    POWERENT *fp;
    bp = buf = alloc_lbuf("display_powertab");
    safe_str((char *) "Powers:", buf, &bp);

    for (fp = gen_powers; fp->powername; fp++) {
	if ((fp->listperm & CA_WIZARD) && !Wizard(player)) {
	    continue;
	}

	if ((fp->listperm & CA_GOD) && !God(player)) {
	    continue;
	}

	safe_chr(' ', buf, &bp);
	safe_str((char *) fp->powername, buf, &bp);
    }

    *bp = '\0';
    notify(player, buf);
    free_lbuf(buf);
}
Ejemplo n.º 29
0
void do_plusemail(dbref executor, dbref cause, dbref enactor, int eval, int key,
                 int nargs, UTF8 *arg1, UTF8 *arg2, const UTF8 *cargs[], int ncargs)
{
    UNUSED_PARAMETER(cause);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(eval);
    UNUSED_PARAMETER(key);
    UNUSED_PARAMETER(nargs);
    UNUSED_PARAMETER(cargs);
    UNUSED_PARAMETER(ncargs);

    UTF8 inputline[LBUF_SIZE];

    if ('\0' == mudconf.mail_server[0])
    {
        notify(executor, T("@email: Not configured"));
        return;
    }

    if (!arg1 || !*arg1)
    {
        notify(executor, T("@email: I don\xE2\x80\x99t know who you want to e-mail!"));
        return;
    }

    if (!arg2 || !*arg2)
    {
        notify(executor, T("@email: Not sending an empty e-mail!"));
        return;
    }

    UTF8 *addy = alloc_lbuf("mod_email_do_email.headers");
    UTF8 *bp = addy;
    safe_str(arg1, addy, &bp);
    *bp = '\0';

    UTF8 *subject = (UTF8 *)strchr((char *)addy, '/');
    if (subject)
    {
        *subject = '\0';
        subject++;
    }
    else
    {
        subject = mudconf.mail_subject;
    }

    UTF8 *pMailServer = ConvertCRLFtoSpace(mudconf.mail_server);
    SOCKET mailsock = INVALID_SOCKET;
    int result = mod_email_sock_open(pMailServer, 25, &mailsock);

    if (-1 == result)
    {
        notify(executor, tprintf(T("@email: Unable to resolve hostname %s!"),
            pMailServer));
        free_lbuf(addy);
        return;
    }
    else if (-2 == result)
    {
        // Periodically, we get a failed connect, for reasons which elude me.
        // In almost every case, an immediate retry works.  Therefore, we give
        // it one more shot, before we give up.
        //
        result = mod_email_sock_open(pMailServer, 25, &mailsock);
        if (0 != result)
        {
            notify(executor, T("@email: Unable to connect to mailserver, aborting!"));
            free_lbuf(addy);
            return;
        }
    }

    UTF8 *body = alloc_lbuf("mod_email_do_email.body");
    UTF8 *bodyptr = body;
    mux_exec(arg2, LBUF_SIZE-1, body, &bodyptr, executor, executor, executor,
        EV_TOP | EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, NULL, 0);
    *bodyptr = '\0';

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('2' != inputline[0])
    {
        mod_email_sock_close(mailsock);
        notify(executor, tprintf(T("@email: Invalid mailserver greeting (%s)"),
            inputline));
    }

    mod_email_sock_printf(mailsock, T("EHLO %s\r\n"), ConvertCRLFtoSpace(mudconf.mail_ehlo));

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('2' != inputline[0])
    {
        notify(executor, tprintf(T("@email: Error response on EHLO (%s)"),
            inputline));
    }

    mod_email_sock_printf(mailsock, T("MAIL FROM:<%s>\r\n"), ConvertCRLFtoSpace(mudconf.mail_sendaddr));

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('2' != inputline[0])
    {
        notify(executor, tprintf(T("@email: Error response on MAIL FROM (%s)"),
            inputline));
    }

    mod_email_sock_printf(mailsock, T("RCPT TO:<%s>\r\n"), ConvertCRLFtoSpace(addy));

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('2' != inputline[0])
    {
        notify(executor, tprintf(T("@email: Error response on RCPT TO (%s)"),
            inputline));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    mod_email_sock_printf(mailsock, T("DATA\r\n"));

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('3' != inputline[0])
    {
        notify(executor, tprintf(T("@email: Error response on DATA (%s)"),
            inputline));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    UTF8 *pSendName = StringClone(ConvertCRLFtoSpace(mudconf.mail_sendname));
    mod_email_sock_printf(mailsock, T("From: %s <%s>\r\n"),  pSendName, ConvertCRLFtoSpace(mudconf.mail_sendaddr));
    MEMFREE(pSendName);

    mod_email_sock_printf(mailsock, T("To: %s\r\n"), ConvertCRLFtoSpace(addy));
    mod_email_sock_printf(mailsock, T("X-Mailer: TinyMUX %s\r\n"), mudstate.short_ver);
    mod_email_sock_printf(mailsock, T("Subject: %s\r\n\r\n"), ConvertCRLFtoSpace(subject));

    // The body is encoded to include the CRLF.CRLF at the end.
    //
    mod_email_sock_printf(mailsock, T("%s"), EncodeBody(body));

    do
    {
        result = mod_email_sock_readline(mailsock, inputline, LBUF_SIZE - 1);

        // Remove trailing CR and LF characters.
        //
        while (  0 < result
              && (  '\n' == inputline[result-1]
                 || '\r' == inputline[result-1]))
        {
            result--;
            inputline[result] = '\0';
        }
    } while (  0 == result
            || (  3 < result
               && '-' == inputline[3]));

    if (-1 == result)
    {
        mod_email_sock_close(mailsock);
        notify(executor, T("@email: Connection to mailserver lost."));
        free_lbuf(body);
        free_lbuf(addy);
        return;
    }

    if ('2' != inputline[0])
    {
        notify(executor, tprintf(T("@email: Message rejected (%s)"), inputline));
    }
    else
    {
        notify(executor, tprintf(T("@email: Mail sent to %s (%s)"), ConvertCRLFtoSpace(addy), &inputline[4]));
    }

    mod_email_sock_printf(mailsock, T("QUIT\n"));
    mod_email_sock_close(mailsock);

    free_lbuf(body);
    free_lbuf(addy);
}
Ejemplo n.º 30
0
int empire_from_empsrv(DESC *d, char *text)
{
  char *pt1, *pt2, *pt3, *tstrtokr;
  int code;

  pt1 = strtok_r(text,"\n", &tstrtokr);
  if (pt1 != NULL) {
    do {
      pt2 = pt1;
      while (*pt2 && !isspace((int)*pt2))
	pt2++;
      *pt2++ = '\0';
      if (isalpha((int)*pt1))
	code = 10 + (*pt1 - 'a');
      else
	code = *pt1 - '0';
      switch (code) {
	case C_PROMPT:
	  if (sscanf(pt2,"%d %d", &(d->door_int2), &(d->door_int3)) != 2)
	    queue_string(d, "empire: bad server prompt.\r\n");
	  d->door_int1 = code;
	  sprintf(d->door_lbuf, "[%d:%d] Command : ", d->door_int2, d->door_int3);
	  empire_prompt(d);
	  break;
	case C_REDIR:
	  queue_string(d,"empire: redirection not supported.\r\n");
	  break;
	case C_PIPE:
	  queue_string(d,"empire: pipe not supported.\r\n");
	  break;
	case C_FLUSH:
	  d->door_int1 = code;
	  strcpy(d->door_lbuf, pt2);
	  empire_prompt(d);
	  break;
	case C_EXECUTE:
	  pt3 = alloc_lbuf("door_exec_temp");
	  if (pt3 == NULL) {
	    queue_string(d,"Door exec failed.\r\n");
	    break;
	  }
	  strcpy(pt3,pt2);
	  do_command(d,pt3);
	  free_lbuf(pt3);
	  if (!(d->flags & DS_HAS_DOOR)) {
	    queue_string(d,"Exec send EOF failed; Empire door was closed.\r\n");
	    return -1;
	  }
	  else if (WRITE(d->door_desc,"ctld\n", 5) < 5) {
	    queue_string(d,"Exec send EOF failed\r\n");
	    return -1;
	  }
	  break;
	case C_INFORM:
	  if (*pt2) {
	    pt2[strlen(pt2)-1] = '\0';
	    sprintf(d->door_mbuf, "(%s)", pt2+1);
	    empire_prompt(d);
	  }
	  else
	    *(d->door_mbuf) = '\0';
	  break;
	default:
	  empire_output(d, code, pt2);
	  break;
      }
    } while ((pt1 = strtok_r(NULL,"\n", &tstrtokr)) != NULL);
  }
  return 1;
}