#define GST_NUMBERING (options.guest_roman_numeral)
#define GUEST_NUMBER(x) (const char *) (GST_NUMBERING ? ArabicToRoman(x) : unparse_number((NVAL) x))
#define PLAYER_DEF_POWERGROUP (options.player_powergroup)
+
+typedef struct globals_table GLOBALTAB;
+
+struct globals_table {
+ int database_loaded; /**< True after the database has been read. */
+ char dumpfile[200]; /**< File name to dump database to */
+ time_t start_time; /**< MUSH start time (since process exec'd) */
+ time_t first_start_time; /**< MUSH start time (since last shutdown) */
+ time_t last_dump_time; /**< Time of last successful db save */
+ int reboot_count; /**< Number of reboots so far */
+ int paranoid_dump; /**< if paranoid, scan before dumping */
+ int paranoid_checkpt; /**< write out an okay message every x objs */
+ long indb_flags; /**< flags set in the input database */
+ int on_second; /**< is it time for per-second processes? */
+};
+
+extern GLOBALTAB globals;
+
#endif /* __CONF_H */
#endif
int que_next(void); /* from cque.c */
-extern int on_second; /**< Are we ready to do per-second processing? */
void dispatch(void); /* from timer.c */
dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */
-extern time_t start_time; /**< When was the mush last rebooted? */
-extern time_t first_start_time; /**< When was the mush first started? */
-extern int reboot_count; /**< How many times have we been rebooted? */
-extern int database_loaded; /* From game.c */
static int extrafd;
int shutdown_flag = 0; /**< Is it time to shut down? */
-extern int paranoid_dump; /**< Are we doing a paranoid dump? */
#ifdef CHAT_SYSTEM
void chat_player_announce(dbref player, char *msg, int ungag);
#endif /* CHAT_SYSTEM */
void WIN32_CDECL signal_dump(int sig);
void reaper(int sig);
extern Pid_t forked_dump_pid; /**< Process id of forking dump process */
-extern time_t last_dump_time; /**< Time of last database dump */
static void dump_users(DESC *call_by, char *match, int doing);
static const char *time_format_1(long int dt);
static const char *time_format_2(long int dt);
init_game_postdb(confname);
- database_loaded = 1;
+ globals.database_loaded = 1;
set_signals();
last_slice.tv_usec = current_time.tv_usec;
if (msec_diff(¤t_time, &then) >= 1000) {
- on_second = 1;
+ globals.on_second = 1;
then.tv_sec = current_time.tv_sec;
then.tv_usec = current_time.tv_usec;
}
}
if (signal_dump_flag) {
- paranoid_dump = 0;
+ globals.paranoid_dump = 0;
do_rawlog(LT_CHECK, "DUMP by external signal");
fork_and_dump(1);
signal_dump_flag = 0;
do_rawlog(LT_ERR, T("ERROR! forking dump exited with signal %d"),
WTERMSIG(my_stat));
} else if (WIFEXITED(my_stat) && WEXITSTATUS(my_stat) == 0) {
- time(&last_dump_time);
+ time(&globals.last_dump_time);
if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
}
queue_string_eol(call_by, tprintf("Name: %s", options.mud_name));
queue_string_eol(call_by,
- tprintf("Uptime: %s", show_time(first_start_time, 0)));
+ tprintf("Uptime: %s", show_time(globals.first_start_time, 0)));
queue_string_eol(call_by, tprintf("Connected: %d", count));
queue_string_eol(call_by, tprintf("Size: %d", db_top));
queue_string_eol(call_by, tprintf("Version: CobraMUSH v%s [%s]", VERSION,
putref(f, 0);
putstring(f, poll_msg);
- putref(f, first_start_time);
- putref(f, reboot_count);
+ putref(f, globals.first_start_time);
+ putref(f, globals.reboot_count);
fclose(f);
}
}
}
strcpy(poll_msg, getstring_noalloc(f));
- first_start_time = getref(f);
- reboot_count = getref(f) + 1;
+ globals.first_start_time = getref(f);
+ globals.reboot_count = getref(f) + 1;
DESC_ITER_CONN(d) {
d->mailp = find_exact_starting_point(d->player);
}
#endif
int que_next(void); /* from cque.c */
-extern int on_second; /**< Are we ready to do per-second processing? */
void dispatch(void); /* from timer.c */
dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */
-extern time_t start_time; /**< When was the mush last rebooted? */
-extern time_t first_start_time; /**< When was the mush first started? */
-extern int reboot_count; /**< How many times have we been rebooted? */
-extern int database_loaded; /* From game.c */
static int extrafd;
int shutdown_flag = 0; /**< Is it time to shut down? */
-extern int paranoid_dump; /**< Are we doing a paranoid dump? */
#ifdef CHAT_SYSTEM
void chat_player_announce(dbref player, char *msg, int ungag);
#endif /* CHAT_SYSTEM */
void WIN32_CDECL signal_dump(int sig);
void reaper(int sig);
extern Pid_t forked_dump_pid; /**< Process id of forking dump process */
-extern time_t last_dump_time; /**< Time of last database dump */
static void dump_users(DESC *call_by, char *match, int doing);
static const char *time_format_1(long int dt);
static const char *time_format_2(long int dt);
init_game_postdb(confname);
- database_loaded = 1;
+ globals.database_loaded = 1;
set_signals();
last_slice.tv_usec = current_time.tv_usec;
if (msec_diff(¤t_time, &then) >= 1000) {
- on_second = 1;
+ globals.on_second = 1;
then.tv_sec = current_time.tv_sec;
then.tv_usec = current_time.tv_usec;
}
}
if (signal_dump_flag) {
- paranoid_dump = 0;
+ globals.paranoid_dump = 0;
do_rawlog(LT_CHECK, "DUMP by external signal");
fork_and_dump(1);
signal_dump_flag = 0;
do_rawlog(LT_ERR, T("ERROR! forking dump exited with signal %d"),
WTERMSIG(my_stat));
} else if (WIFEXITED(my_stat) && WEXITSTATUS(my_stat) == 0) {
- time(&last_dump_time);
+ time(&globals.last_dump_time);
if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
}
queue_string_eol(call_by, tprintf("Name: %s", options.mud_name));
queue_string_eol(call_by,
- tprintf("Uptime: %s", show_time(first_start_time, 0)));
+ tprintf("Uptime: %s", show_time(globals.first_start_time, 0)));
queue_string_eol(call_by, tprintf("Connected: %d", count));
queue_string_eol(call_by, tprintf("Size: %d", db_top));
queue_string_eol(call_by, tprintf("Version: CobraMUSH v%s [%s]", VERSION,
putref(f, 0);
putstring(f, poll_msg);
- putref(f, first_start_time);
- putref(f, reboot_count);
+ putref(f, globals.first_start_time);
+ putref(f, globals.reboot_count);
fclose(f);
}
}
}
strcpy(poll_msg, getstring_noalloc(f));
- first_start_time = getref(f);
- reboot_count = getref(f) + 1;
+ globals.first_start_time = getref(f);
+ globals.reboot_count = getref(f) + 1;
DESC_ITER_CONN(d) {
d->mailp = find_exact_starting_point(d->player);
}
#define MAYBE_GET(f,x) \
(indb_flags & (x)) ? getref(f) : 0
-extern int paranoid_checkpt; /* from game.c */
-
long indb_flags; /**< What flags are in the db we read at startup? */
long flagdb_flags; /**< What flags are in the flag db we read at startup? */
OUTPUT(fprintf(f, "!%d\n", i));
db_paranoid_write_object(f, i, flag);
/* print out a message every so many objects */
- if (i % paranoid_checkpt == 0)
+ if (i % globals.paranoid_checkpt == 0)
do_rawlog(LT_CHECK, T("\t...wrote up to object #%d\n"), i);
}
OUTPUT(fputs(EOD, f));
hashinit(&htab_objdata_keys, 8, 32);
}
-extern time_t first_start_time;
-
void init_postconvert() {
dbref master_division, i;
- if((!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) && CreTime(0) != first_start_time ) {
+ if((!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) && CreTime(0) != globals.first_start_time ) {
do_rawlog(LT_ERR, "Beginning Pennmush to CobraMUSH database conversion process.");
/* Final Step of DB Conversion
* We're gonna first Create the Master Division
#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
-extern time_t start_time, first_start_time;
-extern int reboot_count;
extern FUN flist[];
static char *soundex(char *str);
extern char cf_motd_msg[BUFFER_LEN],
/* ARGSUSED */
FUNCTION(fun_starttime)
{
- safe_str(show_time(first_start_time, 0), buff, bp);
+ safe_str(show_time(globals.first_start_time, 0), buff, bp);
}
/* ARGSUSED */
FUNCTION(fun_restarttime)
{
- safe_str(show_time(start_time, 0), buff, bp);
+ safe_str(show_time(globals.start_time, 0), buff, bp);
}
/* ARGSUSED */
FUNCTION(fun_restarts)
{
- safe_integer(reboot_count, buff, bp);
+ safe_integer(globals.reboot_count, buff, bp);
}
/* Data for soundex functions */
#endif
/* declarations */
-int database_loaded = 0; /**< True after the database has been read. */
-char dumpfile[200]; /**< File name to dump database to */
-time_t start_time; /**< MUSH start time (since process exec'd) */
-time_t first_start_time = 0; /**< MUSH start time (since last shutdown) */
-time_t last_dump_time = 0; /**< Time of last successful db save */
-int reboot_count = 0; /**< Number of reboots so far */
+GLOBALTAB globals = { 0, "", 0, 0, 0, 0, 0, 0, 0, 0 };
static int epoch = 0;
static int reserved; /**< Reserved file descriptor */
int depth = 0; /**< excessive recursion prevention */
extern void initialize_mt(void);
extern const unsigned char *tables;
-int paranoid_dump = 0; /**< if paranoid, scan before dumping */
-int paranoid_checkpt = 0; /**< write out an okay message every x objs */
-extern long indb_flags;
extern void conf_default_set(void);
static int dump_database_internal(void);
static FILE *db_open(const char *filename);
if (flag != DUMP_NORMAL) {
#endif
/* want to do a scan before dumping each object */
- paranoid_dump = 1;
+ globals.paranoid_dump = 1;
if (num && *num) {
/* checkpoint interval given */
- paranoid_checkpt = atoi(num);
- if ((paranoid_checkpt < 1) || (paranoid_checkpt >= db_top)) {
+ globals.paranoid_checkpt = atoi(num);
+ if ((globals.paranoid_checkpt < 1)
+ || (globals.paranoid_checkpt >= db_top)) {
notify(player, T("Permission denied. Invalid checkpoint interval."));
- paranoid_dump = 0;
+ globals.paranoid_dump = 0;
return;
}
} else {
/* use a default interval */
- paranoid_checkpt = db_top / 5;
- if (paranoid_checkpt < 1)
- paranoid_checkpt = 1;
+ globals.paranoid_checkpt = db_top / 5;
+ if (globals.paranoid_checkpt < 1)
+ globals.paranoid_checkpt = 1;
}
if (flag == DUMP_PARANOID) {
notify_format(player, T("Paranoid dumping, checkpoint interval %d."),
- paranoid_checkpt);
+ globals.paranoid_checkpt);
do_rawlog(LT_CHECK,
"*** PARANOID DUMP *** done by %s(#%d),\n",
Name(player), player);
} else {
notify_format(player, T("Debug dumping, checkpoint interval %d."),
- paranoid_checkpt);
+ globals.paranoid_checkpt);
do_rawlog(LT_CHECK,
"*** DEBUG DUMP *** done by %s(#%d),\n",
Name(player), player);
}
do_rawlog(LT_CHECK, T("\tcheckpoint interval %d, at %s"),
- paranoid_checkpt, show_time(mudtime, 0));
+ globals.paranoid_checkpt, show_time(mudtime, 0));
} else {
/* normal dump */
- paranoid_dump = 0; /* just to be safe */
+ globals.paranoid_dump = 0; /* just to be safe */
notify(player, "Dumping...");
do_rawlog(LT_CHECK, "** DUMP ** done by %s(#%d) at %s",
Name(player), player, show_time(mudtime, 0));
}
fork_and_dump(1);
- paranoid_dump = 0;
+ globals.paranoid_dump = 0;
}
}
mush_panic("@shutdown/panic");
} else {
if (flag == SHUT_PARANOID) {
- paranoid_checkpt = db_top / 5;
- if (paranoid_checkpt < 1)
- paranoid_checkpt = 1;
- paranoid_dump = 1;
+ globals.paranoid_checkpt = db_top / 5;
+ if (globals.paranoid_checkpt < 1)
+ globals.paranoid_checkpt = 1;
+ globals.paranoid_dump = 1;
}
shutdown_flag = 1;
}
}
}
- sprintf(realdumpfile, "%s%s", dumpfile, options.compresssuff);
- strcpy(tmpfl, make_new_epoch_file(dumpfile, epoch));
+ sprintf(realdumpfile, "%s%s", globals.dumpfile, options.compresssuff);
+ strcpy(tmpfl, make_new_epoch_file(globals.dumpfile, epoch));
sprintf(realtmpfl, "%s%s", tmpfl, options.compresssuff);
if ((f = db_open_write(tmpfl)) != NULL) {
- switch (paranoid_dump) {
+ switch (globals.paranoid_dump) {
case 0:
#ifdef ALWAYS_PARANOID
db_paranoid_write(f, 0);
longjmp(db_err, 1);
}
#endif /* CHAT_SYSTEM */
- time(&last_dump_time);
+ time(&globals.last_dump_time);
}
#endif
emergency_shutdown();
/* dump panic file if we have a database read. */
- if (database_loaded) {
+ if (globals.database_loaded) {
if (setjmp(db_err)) {
/* Dump failed. We're in deep doo-doo */
do_rawlog(LT_ERR, T("CANNOT DUMP PANIC DB. OOPS."));
{
epoch++;
- do_rawlog(LT_ERR, "DUMPING: %s.#%d#", dumpfile, epoch);
+ do_rawlog(LT_ERR, "DUMPING: %s.#%d#", globals.dumpfile, epoch);
dump_database_internal();
- do_rawlog(LT_ERR, "DUMPING: %s.#%d# (done)", dumpfile, epoch);
+ do_rawlog(LT_ERR, "DUMPING: %s.#%d# (done)", globals.dumpfile, epoch);
}
/** Dump a database, possibly by forking the process.
chunk_stats(NOTHING, 0);
chunk_stats(NOTHING, 1);
#endif
- do_rawlog(LT_CHECK, "CHECKPOINTING: %s.#%d#\n", dumpfile, epoch);
+ do_rawlog(LT_CHECK, "CHECKPOINTING: %s.#%d#\n", globals.dumpfile, epoch);
if (NO_FORK)
nofork = 1;
else
- nofork = !forking || (paranoid_dump == 2); /* Don't fork for dump/debug */
+ nofork = !forking || (globals.paranoid_dump == 2); /* Don't fork for dump/debug */
#ifdef WIN32
nofork = 1;
#endif
}
/* set MUSH start time */
- start_time = time((time_t *) 0);
- if (!first_start_time)
- first_start_time = start_time;
+ globals.start_time = time((time_t *) 0);
+ if (!globals.first_start_time)
+ globals.first_start_time = globals.start_time;
/* initialize all the hash and prefix tables */
init_flagspaces();
do_rawlog(LT_ERR, "CobraMUSH v%s [%s]", VERSION, VBRANCH);
do_rawlog(LT_ERR, T("MUSH restarted, PID %d, at %s"),
- (int) getpid(), show_time(start_time, 0));
+ (int) getpid(), show_time(globals.start_time, 0));
}
/** Post-db-load configuration.
outfile = options.output_db;
flag_file = options.flagdb;
mailfile = options.mail_db;
- strcpy(dumpfile, outfile);
+ strcpy(globals.dumpfile, outfile);
/* read small text files into cache */
fcache_init();
* format db, with everything shoved together. In that case,
* don't close the file
*/
- panicdb = ((indb_flags & DBF_PANIC) && !feof(f));
+ panicdb = ((globals.indb_flags & DBF_PANIC) && !feof(f));
if (!panicdb)
db_close(f);
char tbuf1[BUFFER_LEN];
struct tm *when;
- when = localtime(&first_start_time);
+ when = localtime(&globals.first_start_time);
strftime(tbuf1, sizeof tbuf1, T(" Up since %a %b %d %X %Z %Y"), when);
notify(player, tbuf1);
- when = localtime(&start_time);
+ when = localtime(&globals.start_time);
strftime(tbuf1, sizeof tbuf1, T(" Last reboot: %a %b %d %X %Z %Y"), when);
notify(player, tbuf1);
- notify_format(player, T("Total reboots: %d"), reboot_count);
+ notify_format(player, T("Total reboots: %d"), globals.reboot_count);
when = localtime(&mudtime);
strftime(tbuf1, sizeof tbuf1, T(" Time now: %a %b %d %X %Z %Y"), when);
notify(player, tbuf1);
- if (last_dump_time > 0) {
- when = localtime(&last_dump_time);
+ if (globals.last_dump_time > 0) {
+ when = localtime(&globals.last_dump_time);
strftime(tbuf1, sizeof tbuf1,
T(" Time of last database save: %a %b %d %X %Z %Y"), when);
notify(player, tbuf1);
#include "confmagic.h"
-int on_second = 0; /**< Have we been called at the end of a second? */
static sig_atomic_t hup_triggered = 0;
static sig_atomic_t usr1_triggered = 0;
do_reboot(NOTHING, 0); /* We don't return from this */
usr1_triggered = 0; /* But just in case */
}
- if (!on_second)
+ if (!globals.on_second)
return;
- on_second = 0;
+ globals.on_second = 0;
mudtime = time(NULL);
#endif
#include "confmagic.h"
-extern time_t start_time; /* from bsd.c */
void do_version _((dbref player));
void
notify_format(player, T("You are connected to %s"), MUDNAME);
- strcpy(buff, ctime(&start_time));
+ strcpy(buff, ctime(&globals.start_time));
buff[strlen(buff) - 1] = '\0'; /* eat the newline */
notify_format(player, T("Last restarted: %s"), buff);
extern dbref find_entrance(dbref door);
struct db_stat_info *get_stats(dbref owner);
extern dbref find_player_by_desc(int port);
-extern int paranoid_dump;
-extern int paranoid_checkpt;
#ifndef WIN32
Name(Owner(player)));
}
if (flag) {
- paranoid_dump = 1;
- paranoid_checkpt = db_top / 5;
- if (paranoid_checkpt < 1)
- paranoid_checkpt = 1;
+ globals.paranoid_dump = 1;
+ globals.paranoid_checkpt = db_top / 5;
+ if (globals.paranoid_checkpt < 1)
+ globals.paranoid_checkpt = 1;
}
#ifdef HAS_OPENSSL
close_ssl_connections();