Beispiel #1
0
static void pool_err
(
    __in const UTF8 *logsys,
    int              logflag,
    int              poolnum,
    __in const UTF8 *tag,
    __in POOLHDR    *ph,
    __in const UTF8 *action,
    __in const UTF8 *reason,
    __in const UTF8 *file,
    const int        line
)
{
    if (0 == mudstate.logging)
    {
        STARTLOG(logflag, logsys, "ALLOC");
        Log.tinyprintf(T("%s[%d] (tag %s) %s in %s line %d at %p. (%s)"), action,
            pools[poolnum].pool_client_size, tag, reason, file, line, ph,
            mudstate.debug_cmd);
        ENDLOG;
    }
    else if (LOG_ALLOCATE != logflag)
    {
        Log.tinyprintf(T(ENDLINE "***< %s[%d] (tag %s) %s in %s line %d at %p. >***"),
            action, pools[poolnum].pool_client_size, tag, reason, file, line, ph);
    }
}
void hs_log(char *str)
{
  time_t  tt;
  struct tm *ttm;
  char    timebuf[256];
  char    tbuf[512];

#ifdef TM3
  char    *text, *newstr;

  /* We make a lot of modifications in this one function, so we don't have
   * to change all of the hs_log calls. Otherwise, future mainline patches
   * would be harder to apply.
   */

  newstr = strdup(str);
  text = strchr(newstr, ':');
  if (text) {
  	*text = '\0';

	/* Skip over the colon and space */
	text += 2;

	STARTLOG(LOG_ALWAYS, "HSPACE", newstr)
		log_text(text);
	ENDLOG 
  } else {
Beispiel #3
0
static int sql_init(dbref player) {
  MYSQL *result;
  
  /* If we are already connected, drop and retry the connection, in
   * case for some reason the server went away.
   */
  
  if (mysql_struct)
    sql_shutdown(player);
  
  /* Try to connect to the database host. If we have specified
   * localhost, use the Unix domain socket instead.
   */
  
  mysql_init(mysql_struct);
  
  result = mysql_real_connect(mysql_struct, DB_HOST, DB_USER, DB_PASS, DB_BASE,
 			      3306, DB_SOCKET, 0);
  
  if (!result) {
    STARTLOG(LOG_PROBLEMS, "SQL", "ERR");
    log_text(unsafe_tprintf("DB connect by %s : ", player < 0 ? "SYSTEM" : Name(player)));
    log_text("Failed to connect to SQL database.");
    ENDLOG
    return -1;
  } else {
Beispiel #4
0
void pool_free(int poolnum, __in UTF8 *buf, __in const UTF8 *file, const int line)
{
    if (buf == NULL)
    {
        STARTLOG(LOG_PROBLEMS, "BUG", "ALLOC")
        log_printf(T("Attempt to free null pointer in %s line %d."), file, line);
        ENDLOG
        return;
    }
Beispiel #5
0
void NDECL(init_version)
{
#ifdef BETA
#define INDEVEL_TAG "Beta"
#endif
#ifdef ALPHA
#define INDEVEL_TAG "Alpha"
#endif

#ifdef INDEVEL_TAG
#if PATCHLEVEL > 0
	sprintf(mudstate.version, "RhostMUSH %s version %.30s%.10s patchlevel %d%s #%.10s",
		INDEVEL_TAG, MUSH_VERSION, EXT_MUSH_VER, PATCHLEVEL, PATCHLEVELEXT, MUSH_BUILD_NUM);
	sprintf(mudstate.short_ver, "RhostMUSH %s %.30s%.10s.p%d%s",
		INDEVEL_TAG, MUSH_VERSION, EXT_MUSH_VER, PATCHLEVEL, PATCHLEVELEXT);
#else
	sprintf(mudstate.version, "RhostMUSH %s version %.30s%.10s #%.10s",
		INDEVEL_TAG, MUSH_VERSION, EXT_MUSH_VER, MUSH_BUILD_NUM);
	sprintf(mudstate.short_ver, "RhostMUSH %s %.30s%.10s", INDEVEL_TAG,
		MUSH_VERSION, EXT_MUSH_VER);
#endif	/* PATCHLEVEL */
#else	/* not BETA or ALPHA */
#if PATCHLEVEL > 0
	sprintf(mudstate.version, "RhostMUSH version %.30s%.10s patchlevel %d%s #%.10s [%.30s]",
		MUSH_VERSION, EXT_MUSH_VER, PATCHLEVEL, PATCHLEVELEXT, MUSH_BUILD_NUM, MUSH_RELEASE_DATE);
	sprintf(mudstate.short_ver, "RhostMUSH %.30s%.10s.p%d%s",
		MUSH_VERSION, EXT_MUSH_VER, PATCHLEVEL, PATCHLEVELEXT);
#else
	sprintf(mudstate.version, "RhostMUSH version %.30s%.10s #%.10s [%.30s]",
		MUSH_VERSION, EXT_MUSH_VER, MUSH_BUILD_NUM, MUSH_RELEASE_DATE);
	sprintf(mudstate.short_ver, "RhostMUSH %.30s%.10s",
		MUSH_VERSION, EXT_MUSH_VER);
#endif	/* PATCHLEVEL */
#endif	/* BETA */
	STARTLOG(LOG_ALWAYS,"INI","START")
		log_text((char *)"Starting: ");
		log_text(mudstate.version);
	ENDLOG
	STARTLOG(LOG_ALWAYS,"INI","START")
		log_text((char *)"Build date: ");
		log_text((char *)MUSH_BUILD_DATE);
	ENDLOG	
}
Beispiel #6
0
void local_sqlite_init(void) {
   FUN *fp;
   char *buff, *cp, *dp;
   struct stat sb;

   if( stat( mudconf.sqlite_db_path, &sb ) == -1 ) {
      getcwd( tempbuff2, LBUF_SIZE );
      STARTLOG(LOG_ALWAYS, "SQL", "FAIL")
         sprintf( tempbuff, "stat - unable to read database path '%s/%s'", tempbuff2, mudconf.sqlite_db_path );
         log_text(tempbuff);
      ENDLOG
      return;
   }
Beispiel #7
0
// ---------------------------------------------------------------------------
// do_query: Command interface to sql_que
//
void do_query
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int   key,
    char *dbref_attr,
    char *dbname_query,
    char *cargs[],
    int   ncargs
)
{
    if (key & QUERY_SQL)
    {
        // SQL Query.
        //
        dbref thing;
        ATTR *pattr;

        if (!( parse_attrib(executor, dbref_attr, &thing, &pattr)
            && pattr))
        {
            notify_quiet(executor, "No match.");
            return;
        }

        if (!Controls(executor, thing))
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }

        char *pQuery = dbname_query;
        char *pDBName = parse_to(&pQuery, '/', 0);

        if (NULL == pQuery)
        {
            notify(executor, "QUERY: No Query.");
            return;
        }

        STARTLOG(LOG_ALWAYS, "CMD", "QUERY");
        Log.tinyprintf("Thing=#%d, Attr=%s, dbname=%s, query=%s", thing, pattr->name, pDBName, pQuery);
        ENDLOG;
    }
    else
    {
        notify_quiet(executor, "At least one query option is required.");
    }
}
Beispiel #8
0
static bool ValidateHelpFileIndex(int iHelpfile)
{
    if (  iHelpfile < 0
       || mudstate.mHelpDesc <= iHelpfile)
    {
        UTF8 *buf = alloc_mbuf("do_help.LOG");
        STARTLOG(LOG_BUGS, "BUG", "HELP");
        mux_sprintf(buf, MBUF_SIZE, T("Unknown help file number: %d"), iHelpfile);
        log_text(buf);
        ENDLOG;
        free_mbuf(buf);
        return false;
    }
    return true;
}
Beispiel #9
0
void
sql_shutdown()
{
    PGconn *pgsql;

    if (!pgsql_struct)
        return;
    pgsql = pgsql_struct;
    STARTLOG(LOG_ALWAYS, "SQL", "DISC")
    log_printf
    ("Disconnected from SQL server %s, SQL database selected: %s",
     PQhost(pgsql), PQdb(pgsql));
    ENDLOG PQfinish(pgsql);
    pgsql_struct = NULL;
    mudstate.sql_socket = -1;
}
Beispiel #10
0
int
sql_init()
{
    PGconn *pgsql;

    PGresult *result;

    char connect_string[CONNECT_STRING_SIZE];

    /*
     * Make sure we have valid config options.
     */

    if (!mudconf.sql_host || !*mudconf.sql_host)
        return -1;
    if (!mudconf.sql_db || !*mudconf.sql_db)
        return -1;

    /*
     * If we are already connected, drop and retry the connection, in
     * case for some reason the server went away.
     */

    if (pgsql_struct)
        sql_shutdown();

    /*
     * Try to connect to the database host. If we have specified
     * localhost, use the Unix domain socket instead.
     */
    snprintf(connect_string, CONNECT_STRING_SIZE,
             "host = '%s' dbname = '%s' user = '******' password = '******'",
             mudconf.sql_host, mudconf.sql_db, mudconf.sql_username,
             mudconf.sql_password);
    pgsql = PQconnectdb(connect_string);

    if (!pgsql)
    {
        STARTLOG(LOG_ALWAYS, "SQL", "CONN")
        log_printf("Failed connection to SQL server %s: %s",
                   mudconf.sql_host, PQerrorMessage(pgsql));
        ENDLOG return -1;
    }
Beispiel #11
0
void 
do_link(dbref player, dbref cause, int key, char *what, char *where)
{
    dbref thing, room;
    char *buff;
    int nomtest;

    if ( (key & SIDEEFFECT) && !SideFX(player) ) {
       notify(player, "#-1 FUNCTION DISABLED");
       return;
    }

    /* Find the thing to link */

    init_match(player, what, TYPE_EXIT);
    match_everything(0);
    thing = noisy_match_result();
    if (thing == NOTHING)
	return;

    nomtest = ((NoMod(thing) && !WizMod(player)) || (DePriv(player,Owner(thing),DP_MODIFY,POWER7,NOTHING) && (Owner(thing) != Owner(player))) || (Backstage(player) && NoBackstage(thing) && !Immortal(player)));
    /* Allow unlink if where is not specified */

    if (!where || !*where) {
      if (!nomtest)
	do_unlink(player, cause, key, what);
      else
	notify(player,"Permission denied.");
      return;
    }
    switch (Typeof(thing)) {
    case TYPE_EXIT:

	/* Set destination */

	room = parse_linkable_room(player, where);
	if (room != NOTHING) {
	  if (!nomtest)
	    link_exit(player, thing, room, key);
	  else
	    notify(player,"Permission denied.");
	}
	break;
    case TYPE_PLAYER:
    case TYPE_THING:

	/* Set home */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	init_match(player, where, NOTYPE);
	match_everything(MAT_NO_EXITS);
	room = noisy_match_result();
	if (!Good_obj(room))
	    break;
	if (!Has_contents(room)) {
	    notify_quiet(player, "Can't link to an exit.");
	    break;
	}
	if (!can_set_home(player, thing, room) ||
	    !could_doit(player, room, A_LLINK, 1, 0)) {
	    notify_quiet(player, "Permission denied.");
	} else if (room == HOME) {
	    notify_quiet(player, "Can't set home to home.");
	} else {
	    s_Home(thing, room);
	    if (!(Quiet(player) || (key & SIDEEFFECT)) )
		notify_quiet(player, "Home set.");
	}
	break;
    case TYPE_ROOM:

	/* Set dropto */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	room = parse_linkable_room(player, where);
	if (!Good_obj(room) && (room != HOME)) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}

	if ((room != HOME) && !isRoom(room)) {
	    notify_quiet(player, "That is not a room!");
	} else if ((room != HOME) &&
		   ((!controls(player, room) && !Link_ok(room)) ||
		    !could_doit(player, room, A_LLINK, 1, 0))) {
	    notify_quiet(player, "Permission denied.");
	} else {
	    s_Dropto(thing, room);
	    if (!Quiet(player))
		notify_quiet(player, "Dropto set.");
	}
	break;
    default:
	STARTLOG(LOG_BUGS, "BUG", "OTYPE")
	    buff = alloc_mbuf("do_link.LOG.badtype");
	sprintf(buff, "Strange object type: object #%d = %d",
		thing, Typeof(thing));
	log_text(buff);
	free_mbuf(buff);
	ENDLOG
    }
}
Beispiel #12
0
// This Task assumes that pEntry is already unlinked from any lists it may
// have been related to.
//
static void Task_RunQueueEntry(void *pEntry, int iUnused)
{
    UNUSED_PARAMETER(iUnused);

    BQUE *point = (BQUE *)pEntry;
    dbref executor = point->executor;

    if (  Good_obj(executor)
       && !Going(executor))
    {
        giveto(executor, mudconf.waitcost);
        mudstate.curr_enactor = point->enactor;
        mudstate.curr_executor = executor;
        a_Queue(Owner(executor), -1);
        point->executor = NOTHING;
        if (!Halted(executor))
        {
            // Load scratch args.
            //
            for (int i = 0; i < MAX_GLOBAL_REGS; i++)
            {
                if (mudstate.global_regs[i])
                {
                    RegRelease(mudstate.global_regs[i]);
                    mudstate.global_regs[i] = NULL;
                }
                mudstate.global_regs[i] = point->scr[i];
                point->scr[i] = NULL;
            }

            char *command = point->comm;

            mux_assert(!mudstate.inpipe);
            mux_assert(mudstate.pipe_nest_lev == 0);
            mux_assert(mudstate.poutobj == NOTHING);
            mux_assert(!mudstate.pout);

            break_called = false;
            while (  command
                  && !break_called)
            {
                mux_assert(!mudstate.poutnew);
                mux_assert(!mudstate.poutbufc);

                char *cp = parse_to(&command, ';', 0);

                if (  cp
                   && *cp)
                {
                    // Will command be piped?
                    //
                    if (  command
                       && *command == '|'
                       && mudstate.pipe_nest_lev < mudconf.ntfy_nest_lim)
                    {
                        command++;
                        mudstate.pipe_nest_lev++;
                        mudstate.inpipe = true;

                        mudstate.poutnew  = alloc_lbuf("process_command.pipe");
                        mudstate.poutbufc = mudstate.poutnew;
                        mudstate.poutobj  = executor;
                    }
                    else
                    {
                        mudstate.inpipe = false;
                        mudstate.poutobj = NOTHING;
                    }

                    CLinearTimeAbsolute ltaBegin;
                    ltaBegin.GetUTC();
                    MuxAlarm.Set(mudconf.max_cmdsecs);
                    CLinearTimeDelta ltdUsageBegin = GetProcessorUsage();

                    char *log_cmdbuf = process_command(executor, point->caller,
                        point->enactor, point->eval, false, cp, point->env,
                        point->nargs);

                    CLinearTimeAbsolute ltaEnd;
                    ltaEnd.GetUTC();
                    if (MuxAlarm.bAlarmed)
                    {
                        notify(executor, "GAME: Expensive activity abbreviated.");
                        s_Flags(point->enactor, FLAG_WORD1, Flags(point->enactor) | HALT);
                        s_Flags(point->executor, FLAG_WORD1, Flags(point->executor) | HALT);
                        halt_que(point->enactor, NOTHING);
                        halt_que(executor, NOTHING);
                    }
                    MuxAlarm.Clear();

                    CLinearTimeDelta ltdUsageEnd = GetProcessorUsage();
                    CLinearTimeDelta ltd = ltdUsageEnd - ltdUsageBegin;
                    db[executor].cpu_time_used += ltd;

                    ltd = ltaEnd - ltaBegin;
                    if (ltd > mudconf.rpt_cmdsecs)
                    {
                        STARTLOG(LOG_PROBLEMS, "CMD", "CPU");
                        log_name_and_loc(executor);
                        char *logbuf = alloc_lbuf("do_top.LOG.cpu");
                        mux_sprintf(logbuf, LBUF_SIZE, " queued command taking %s secs (enactor #%d): ",
                            ltd.ReturnSecondsString(4), point->enactor);
                        log_text(logbuf);
                        free_lbuf(logbuf);
                        log_text(log_cmdbuf);
                        ENDLOG;
                    }
                }

                // Transition %| value.
                //
                if (mudstate.pout)
                {
                    free_lbuf(mudstate.pout);
                    mudstate.pout = NULL;
                }
                if (mudstate.poutnew)
                {
                    *mudstate.poutbufc = '\0';
                    mudstate.pout = mudstate.poutnew;
                    mudstate.poutnew  = NULL;
                    mudstate.poutbufc = NULL;
                }
            }

            // Clean up %| value.
            //
            if (mudstate.pout)
            {
                free_lbuf(mudstate.pout);
                mudstate.pout = NULL;
            }
            mudstate.pipe_nest_lev = 0;
            mudstate.inpipe = false;
            mudstate.poutobj = NOTHING;
        }
    }

    for (int i = 0; i < MAX_GLOBAL_REGS; i++)
    {
        if (point->scr[i])
        {
            RegRelease(point->scr[i]);
            point->scr[i] = NULL;
        }

        if (mudstate.global_regs[i])
        {
            RegRelease(mudstate.global_regs[i]);
            mudstate.global_regs[i] = NULL;
        }
    }

    MEMFREE(point->text);
    point->text = NULL;
    free_qentry(point);
}
Beispiel #13
0
static bool ReportTopic(dbref executor, struct help_entry *htab_entry, int iHelpfile,
    UTF8 *result)
{
    UTF8 szTextFilename[SBUF_SIZE+8];
    mux_sprintf(szTextFilename, sizeof(szTextFilename), T("%s.txt"),
        mudstate.aHelpDesc[iHelpfile].pBaseFilename);

    size_t offset = htab_entry->pos;
    FILE *fp;
    if (!mux_fopen(&fp, szTextFilename, T("rb")))
    {
        STARTLOG(LOG_PROBLEMS, "HLP", "OPEN");
        UTF8 *line = alloc_lbuf("ReportTopic.open");
        mux_sprintf(line, LBUF_SIZE, T("Can\xE2\x80\x99t open %s for reading."), szTextFilename);
        log_text(line);
        free_lbuf(line);
        ENDLOG;
        return false;
    }
    DebugTotalFiles++;

    if (fseek(fp, static_cast<long>(offset), 0) < 0L)
    {
        STARTLOG(LOG_PROBLEMS, "HLP", "SEEK");
        UTF8 *line = alloc_lbuf("ReportTopic.seek");
        mux_sprintf(line, LBUF_SIZE, T("Seek error in file %s."), szTextFilename);
        log_text(line);
        free_lbuf(line);
        ENDLOG;
        if (fclose(fp) == 0)
        {
            DebugTotalFiles--;
        }
        return false;
    }
    UTF8 *line = alloc_lbuf("ReportTopic");
    UTF8 *bp = result;
    bool bInTopicAliases = true;
    for (;;)
    {
        if (  fgets((char *)line, LBUF_SIZE - 2, fp) == NULL
           || '\0' == line[0])
        {
            break;
        }

        if ('&' == line[0])
        {
            if (bInTopicAliases)
            {
                continue;
            }
            else
            {
                break;
            }
        }
        bInTopicAliases = false;

        // Transform LF into CRLF to be telnet-friendly.
        //
        size_t len = strlen((char *)line);
        if (  0 < len
           && '\n' == line[len-1]
           && (  1 == len
              || '\r' != line[len-2]))
        {
            line[len-1] = '\r';
            line[len  ] = '\n';
            line[++len] = '\0';
        }

        bool bEval = mudstate.aHelpDesc[iHelpfile].bEval;
        if (bEval)
        {
            dbref executor_for_help = executor;
            if (Good_obj(mudconf.help_executor))
            {
                executor_for_help = mudconf.help_executor;
            }
            mux_exec(line, len, result, &bp, executor_for_help, executor, executor,
                    EV_NO_COMPRESS | EV_FIGNORE | EV_EVAL, NULL, 0);
        }
        else
        {
            safe_str(line, result, &bp);
        }
    }

    // Zap trailing CRLF if present.
    //
    if (  result < bp - 1
       && '\r' == bp[-2]
       && '\n' == bp[-1])
    {
        bp -= 2;
    }
    *bp = '\0';

    if (fclose(fp) == 0)
    {
        DebugTotalFiles--;
    }
    free_lbuf(line);
    return true;
}
Beispiel #14
0
static void helpindex_read(int iHelpfile)
{
    helpindex_clean(iHelpfile);

    mudstate.aHelpDesc[iHelpfile].ht = new CHashTable;
    CHashTable *htab = mudstate.aHelpDesc[iHelpfile].ht;

    UTF8 szTextFilename[SBUF_SIZE+8];
    mux_sprintf(szTextFilename, sizeof(szTextFilename), T("%s.txt"),
        mudstate.aHelpDesc[iHelpfile].pBaseFilename);

    FILE *fp;
    if (!mux_fopen(&fp, szTextFilename, T("rb")))
    {
        STARTLOG(LOG_PROBLEMS, "HLP", "RINDX");
        UTF8 *p = alloc_lbuf("helpindex_read.LOG");
        mux_sprintf(p, LBUF_SIZE, T("Can\xE2\x80\x99t open %s for reading."), szTextFilename);
        log_text(p);
        free_lbuf(p);
        ENDLOG;
        return;
    }
    DebugTotalFiles++;

    size_t pos   = 0;
    size_t nTopicOriginal = 0;
    UTF8   topic[TOPIC_NAME_LEN+1];

    HelpIndex_Start(fp);
    while (HelpIndex_Read(&pos, &nTopicOriginal, topic))
    {
        // Convert the entry to all lowercase letters and add all leftmost
        // substrings.
        //
        // Topic names which appear earlier in the help file have priority
        // over topics names which appear later in the help file.  That is,
        // we do not associate prefixes with this topic if they have already
        // been used on a previous topic.
        //
        size_t nCased;
        UTF8  *pCased = mux_strlwr(topic, nCased);

        bool bOriginal = true; // First is the longest.

        for (size_t nTopic = nCased; 0 < nTopic; nTopic--)
        {
            // Avoid adding any entries with a trailing space.
            //
            if (mux_isspace(pCased[nTopic-1]))
            {
                continue;
            }

            struct help_entry *htab_entry =
              (struct help_entry *)hashfindLEN(pCased, nTopic, htab);

            if (htab_entry)
            {
                if (!bOriginal)
                {
                    continue;
                }

                hashdeleteLEN(pCased, nTopic, htab);

                if (htab_entry->key)
                {
                    MEMFREE(htab_entry->key);
                    htab_entry->key = NULL;
                    Log.tinyprintf(T("helpindex_read: duplicate %s entries for %s" ENDLINE),
                        szTextFilename, pCased);
                }
                delete htab_entry;
                htab_entry = NULL;
            }

            try
            {
                htab_entry = new struct help_entry;
            }
            catch (...)
            {
                ; // Nothing.
            }

            if (htab_entry)
            {
                htab_entry->pos = pos;
                htab_entry->key = bOriginal ? StringCloneLen(pCased, nTopic) : NULL;
                bOriginal = false;

                hashaddLEN(pCased, nTopic, htab_entry, htab);
            }
        }
    }
    HelpIndex_End();

    if (fclose(fp) == 0)
    {
        DebugTotalFiles--;
    }
    hashreset(htab);
}
void boot_slave()
{
	int sv[2];
	int i;
	int maxfds;

#ifdef HAVE_GETDTABLESIZE
	maxfds = getdtablesize();
#else
	maxfds = sysconf(_SC_OPEN_MAX);
#endif

	if (slave_socket != -1) {
		close(slave_socket);
		slave_socket = -1;
	}
	if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) < 0) {
		return;
	}
	/*
	 * set to nonblocking 
	 */
	if (fcntl(sv[0], F_SETFL, FNDELAY) == -1) {
		close(sv[0]);
		close(sv[1]);
		return;
	}
	slave_pid = vfork();
	switch (slave_pid) {
	case -1:
		close(sv[0]);
		close(sv[1]);
		return;

	case 0:		/*
			 * child
			 */
		close(sv[0]);
		if (dup2(sv[1], 0) == -1) {
			_exit(1);
		}
		if (dup2(sv[1], 1) == -1) {
			_exit(1);
		}
		for (i = 3; i < maxfds; ++i) {
			close(i);
		}
		execlp("bin/slave", "slave", NULL);
		_exit(1);
	}
	close(sv[1]);

	if (fcntl(sv[0], F_SETFL, FNDELAY) == -1) {
		close(sv[0]);
		return;
	}
	slave_socket = sv[0];
	STARTLOG(LOG_ALWAYS, "NET", "SLAVE")
	    log_text((char *) "DNS lookup slave started on fd ");
	    log_number(slave_socket);
	ENDLOG
}
Beispiel #16
0
void do_quota
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int   key,
    int   nargs,
    UTF8 *arg1,
    UTF8 *arg2,
    const UTF8 *cargs[],
    int ncargs
)
{
    UNUSED_PARAMETER(caller);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(eval);
    UNUSED_PARAMETER(nargs);
    UNUSED_PARAMETER(cargs);
    UNUSED_PARAMETER(ncargs);

    if (!(mudconf.quotas || Quota(executor)))
    {
        notify_quiet(executor, T("Quotas are not enabled."));
        return;
    }
    if ((key & QUOTA_TOT) && (key & QUOTA_REM))
    {
        notify_quiet(executor, T("Illegal combination of switches."));
        return;
    }

    dbref who;
    int value = 0, i;
    bool set = false;

    // Show or set all quotas if requested.
    //
    if (key & QUOTA_ALL)
    {
        if (arg1 && *arg1)
        {
            value = mux_atol(arg1);
            set = true;
        }
        else if (key & (QUOTA_SET | QUOTA_FIX))
        {
            value = 0;
            set = true;
        }
        if (set)
        {
            STARTLOG(LOG_WIZARD, "WIZ", "QUOTA");
            log_name(executor);
            log_text(T(" changed everyone\xE2\x80\x99s quota"));
            ENDLOG;
        }
        DO_WHOLE_DB(i)
        {
            if (isPlayer(i))
            {
                if (set)
                {
                    mung_quotas(i, key, value);
                }
                show_quota(executor, i);
            }
        }
        return;
    }

    // Find out whose quota to show or set.
    //
    if (!arg1 || *arg1 == '\0')
    {
        who = Owner(executor);
    }
    else
    {
        who = lookup_player(executor, arg1, true);
        if (!Good_obj(who))
        {
            notify_quiet(executor, T("Not found."));
            return;
        }
    }

    // Make sure we have permission to do it.
    //
    if (!Quota(executor))
    {
        if (arg2 && *arg2)
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }
        if (Owner(executor) != who)
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }
    }
    if (arg2 && *arg2)
    {
        set = true;
        value = mux_atol(arg2);
    }
    else if (key & QUOTA_FIX)
    {
        set = true;
        value = 0;
    }
    if (set)
    {
        STARTLOG(LOG_WIZARD, "WIZ", "QUOTA");
        log_name(executor);
        log_text(T(" changed the quota of "));
        log_name(who);
        ENDLOG;
        mung_quotas(who, key, value);
    }
    show_quota(executor, who);
}