Exemplo n.º 1
0
/*       someone calls ControlService in reference to our service. */
static VOID WINAPI
service_ctrl(DWORD dwCtrlCode)
{
  DWORD dwState = SERVICE_RUNNING;

  /*  Handle the requested control code. */
  switch (dwCtrlCode) {

    /*  Pause the service if it is running. */
  case SERVICE_CONTROL_PAUSE:

    if (ssStatus.dwCurrentState == SERVICE_RUNNING) {
      SuspendThread(threadHandle);
      dwState = SERVICE_PAUSED;
    }
    break;

    /*  Resume the paused service. */
  case SERVICE_CONTROL_CONTINUE:

    if (ssStatus.dwCurrentState == SERVICE_PAUSED) {
      ResumeThread(threadHandle);
      dwState = SERVICE_RUNNING;
    }
    break;

    /*  Stop the service. */
  case SERVICE_CONTROL_STOP:

    dwState = SERVICE_STOP_PENDING;

    /*  Report the status, specifying the checkpoint and waithint, */
    /*   before setting the termination event. */
    ReportStatusToSCMgr(SERVICE_STOP_PENDING,   /*  current state */
                        NO_ERROR,       /*  exit code */
                        1,      /*  checkpoint */
                        10000); /*  waithint (10 secs) */

    shutdown_flag = 1;

    flag_broadcast(0, 0, T("GAME: Game shutdown by system operator"));

    return;

    /*  Update the service status. */
  case SERVICE_CONTROL_INTERROGATE:
    break;

    /*  invalid control code */
  default:
    break;

  }                             /*  end of switch */

  /*  send a status response. */
  ReportStatusToSCMgr(dwState, NO_ERROR, 0, 0);
}                               /*  end of service_ctrl */
Exemplo n.º 2
0
    void CHSInterface::BroadcastWithFlags(HS_INT32 iFlags,
                                          HS_INT32 iToggles,
                                          const HS_INT8 * pcFormat, ...)
#endif
{
    va_list args;

    static char buff[HSPACE_MAX_HSPRINTF_LEN];

    va_start(args, pcFormat);
    vsnprintf(buff, HSPACE_MAX_HSPRINTF_LEN, pcFormat, args);

    buff[HSPACE_MAX_HSPRINTF_LEN - 1] = '\0';
    va_end(args);


#ifdef PENNMUSH
    flag_broadcast(iFlags, iToggles, buff);
#endif
#if defined(TM3) || defined(MUX)
    raw_broadcast(iToggles, buff);
#endif
}
Exemplo n.º 3
0
/** Rename something.
 * \verbatim
 * This implements @name.
 * \endverbatim
 * \param player the enactor.
 * \param name current name of object to rename.
 * \param newname_ new name for object.
 */
void
do_name(dbref player, const char *name, char *newname_)
{
  dbref thing;
  char oldname[BUFFER_LEN];
  char *newname = NULL;
  char *alias = NULL;
  PE_REGS *pe_regs;

  if ((thing = match_controlled(player, name)) == NOTHING)
    return;

  /* check for bad name */
  if ((*newname_ == '\0') || strchr(newname_, '[')) {
    notify(player, T("Give it what new name?"));
    return;
  }
  switch (Typeof(thing)) {
  case TYPE_PLAYER:
    switch (ok_object_name
            (newname_, player, thing, TYPE_PLAYER, &newname, &alias)) {
    case OPAE_INVALID:
    case OPAE_NULL:
      notify(player, T("You can't give a player that name or alias."));
      if (newname)
        mush_free(newname, "name.newname");
      if (alias)
        mush_free(alias, "name.newname");
      return;
    case OPAE_TOOMANY:
      notify(player, T("Too many aliases."));
      mush_free(newname, "name.newname");
      return;
    case OPAE_SUCCESS:
      break;
    }
    break;
  case TYPE_EXIT:
    if (ok_object_name(newname_, player, thing, TYPE_EXIT, &newname, &alias) !=
        OPAE_SUCCESS) {
      notify(player, T("That is not a reasonable name."));
      if (newname)
        mush_free(newname, "name.newname");
      if (alias)
        mush_free(alias, "name.newname");
      return;
    }
    break;
  case TYPE_THING:
  case TYPE_ROOM:
    if (!ok_name(newname_, 0)) {
      notify(player, T("That is not a reasonable name."));
      return;
    }
    newname = mush_strdup(trim_space_sep(newname_, ' '), "name.newname");
    break;
  default:
    /* Should never occur */
    notify(player, T("I don't see that here."));
    return;
  }

  /* Actually change it */
  mush_strncpy(oldname, Name(thing), BUFFER_LEN);

  if (IsPlayer(thing)) {
    do_log(LT_CONN, 0, 0, "Name change by %s(#%d) to %s",
           Name(thing), thing, newname);
    if (Suspect(thing) && strcmp(Name(thing), newname) != 0)
      flag_broadcast("WIZARD", 0,
                     T("Broadcast: Suspect %s changed name to %s."),
                     Name(thing), newname);
    reset_player_list(thing, Name(thing), NULL, newname, NULL);
  }
  set_name(thing, newname);
  if (alias) {
    if (*alias == ALIAS_DELIMITER) {
      do_set_atr(thing, "ALIAS", NULL, player, 0);
    } else {
      /* New alias to set */
      do_set_atr(thing, "ALIAS", alias, player, 0);
    }
    mush_free(alias, "name.newname");
  }

  queue_event(player, "OBJECT`RENAME", "%s,%s,%s",
              unparse_objid(thing), newname, oldname);

  if (!AreQuiet(player, thing))
    notify(player, T("Name set."));
  pe_regs = pe_regs_create(PE_REGS_ARG, "do_name");
  pe_regs_setenv_nocopy(pe_regs, 0, oldname);
  pe_regs_setenv_nocopy(pe_regs, 1, newname);
  real_did_it(player, thing, NULL, NULL, "ONAME", NULL, "ANAME", NOTHING,
              pe_regs, NA_INTER_PRESENCE, AN_SYS);
  pe_regs_free(pe_regs);
  mush_free(newname, "name.newname");
}
Exemplo n.º 4
0
/** Handle events that may need handling.
 * This routine is polled from bsd.c. At any call, it can handle
 * the HUP and USR1 signals. At calls that are 'on the second',
 * it goes on to perform regular every-second processing and to
 * check whether it's time to do other periodic processes like
 * purge, dump, or inactivity checks.
 */
void
dispatch(void)
{
  static int idle_counter = 0;
  struct module_entry_t *m;
  void (*handle)(void);

  /* A HUP reloads configuration and reopens logs */
  if (hup_triggered) {
    do_rawlog(LT_ERR, T("SIGHUP received: reloading .txt and .cnf files"));
    config_file_startup(NULL, 0);
    config_file_startup(NULL, 1);
    fcache_load(NOTHING);
    help_reindex(NOTHING);
    read_access_file();
    reopen_logs();
    hup_triggered = 0;
  }
  /* A USR1 does a shutdown/reboot */
  if (usr1_triggered) {
    do_reboot(NOTHING, 0);      /* We don't return from this */
    usr1_triggered = 0;         /* But just in case */
  }
  if (!globals.on_second)
    return;
  globals.on_second = 0;

  mudtime = time(NULL);

  do_second();

  migrate_stuff(CHUNK_MIGRATE_AMOUNT);

  if (options.purge_counter <= mudtime) {
    /* Free list reconstruction */
    options.purge_counter = options.purge_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "purge");
    purge();
    strcpy(global_eval_context.ccom, "");
  }

  if (options.dbck_counter <= mudtime) {
    /* Database consistency check */
    options.dbck_counter = options.dbck_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dbck");
    dbck();
    strcpy(global_eval_context.ccom, "");
  }

  if (idle_counter <= mudtime) {
    /* Inactivity check */
    idle_counter = 30 + mudtime;
    inactivity_check();
  }

  /* Database dump routines */
  if (options.dump_counter <= mudtime) {
    log_mem_check();
    options.dump_counter = options.dump_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dump");
    fork_and_dump(1);
    strcpy(global_eval_context.ccom, "");
    flag_broadcast(0, "ON-VACATION", "%s",
                   T
                   ("Your ON-VACATION flag is set! If you're back, clear it."));
  } else if (NO_FORK &&
             (options.dump_counter - 60 == mudtime) &&
             *options.dump_warning_1min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_1min);
  } else if (NO_FORK &&
             (options.dump_counter - 300 == mudtime) &&
             *options.dump_warning_5min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_5min);
  }
  if (options.warn_interval && (options.warn_counter <= mudtime)) {
    options.warn_counter = options.warn_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "warnings");
    run_topology();
    strcpy(global_eval_context.ccom, "");
  }
#ifdef MUSHCRON
  if((mudtime % 60) == 0)
    run_cron(); /* Run the MUSH Cron Daemon */
#endif /* MUSHCRON */
#ifdef _SWMP_
  sql_timer();
#endif
#ifdef RPMODE_SYS 
  rplog_reset();
#endif

  /* Replacement for local_timer */
  MODULE_ITER(m)
    MODULE_FUNC_NOARGS(handle, m->handle, "module_timer");
}