#ifdef HAVE_SYS_INOTIFY_H
#include <sys/inotify.h>
-#endif
+#endif
#ifdef HAVE_FAM_H
#include <fam.h>
#include <poll.h>
#endif
-
+
#include "conf.h"
#include "externs.h"
#include "lookup.h"
#endif
#endif
-
+
#include "strtree.h"
#include "log.h"
#include "mypcre.h"
int shutdown_flag = 0; /**< Is it time to shut down? */
#ifdef CHAT_SYSTEM
void chat_player_announce(dbref player, char *msg, int ungag);
-#endif /* CHAT_SYSTEM */
+#endif /* CHAT_SYSTEM */
static int login_number = 0;
static int under_limit = 1;
/* Default Connection flags for certain clients
*/
-static CLIENT_DEFAULTS client_maps[] = {
+static CLIENT_DEFAULTS client_maps[] = {
{"TINYFUGUE", CONN_PROMPT},
{NULL, -1}
};
#define TN_LINEMODE 34 /**< Line mode */
#define TN_NAWS 31 /**< Negotiate About Window Size */
#define TN_TTYPE 24 /**< Ask for termial type information */
-static void test_telnet(DESC *d);
-static void setup_telnet(DESC *d);
-static int handle_telnet(DESC *d, unsigned char **q, unsigned char *qend);
+static void test_telnet(DESC * d);
+static void setup_telnet(DESC * d);
+static int handle_telnet(DESC * d, unsigned char **q, unsigned char *qend);
static const char *empabb(dbref);
-static int do_su_exit(DESC *d);
+static int do_su_exit(DESC * d);
static const char *create_fail =
- "Either there is already a player with that name, or that name is illegal.";
+ "Either there is already a player with that name, or that name is illegal.";
static const char *password_fail = "The password is invalid (or missing).";
static const char *register_fail =
- "Unable to register that player with that email address.";
+ "Unable to register that player with that email address.";
static const char *register_success =
- "Registration successful! You will receive your password by email.";
+ "Registration successful! You will receive your password by email.";
static const char *shutdown_message = "Going down - Bye";
#ifdef HAVE_SSL
-static const char *ssl_shutdown_message =
- "GAME: SSL connections must be dropped, sorry.";
+static const char *ssl_shutdown_message =
+ "GAME: SSL connections must be dropped, sorry.";
#endif
/** Where we save the descriptor info across reboots. */
#define REBOOTFILE "reboot.db"
dummy_msgs()
{
char *temp;
- temp = T("Either that player does not exist, or has a different password.");
temp =
- T
- ("Either there is already a player with that name, or that name is illegal.");
+ T("Either that player does not exist, or has a different password.");
+ temp =
+ T
+ ("Either there is already a player with that name, or that name is illegal.");
temp = T("The password is invalid (or missing).");
temp = T("Unable to register that player with that email address.");
- temp = T("Registration successful! You will receive your password by email.");
+ temp =
+ T
+ ("Registration successful! You will receive your password by email.");
temp = T("Going down - Bye");
temp = T("GAME: SSL connections must be dropped, sorry.");
}
#endif
#endif
void set_signals(void);
-static struct timeval *timeval_sub(struct timeval *now, struct timeval *then);
+static struct timeval *timeval_sub(struct timeval *now,
+ struct timeval *then);
#ifdef WIN32
/** Windows doesn't have gettimeofday(), so we implement it here */
#define our_gettimeofday(now) win_gettimeofday((now))
static int test_connection(int newsock);
static DESC *new_connection(int oldsock, int *result, bool use_ssl);
-static void clearstrings(DESC *d);
+static void clearstrings(DESC * d);
/** A block of cached text. */
typedef struct fblock {
unsigned char *buff; /**< Pointer to the block as a string */
size_t len; /**< Length of buff */
+ dbref thing; /**< If NOTHING, display buff as raw text. Otherwise, buff is an attrname on thing to eval and display */
} FBLOCK;
/** The complete collection of cached text files. */
FBLOCK guest_fcache[2]; /**< guest.txt and guest.html */
};
-void feed_snoop(DESC *, const char *, char );
+void feed_snoop(DESC *, const char *, char);
char is_snooped(DESC *);
char set_snoop(dbref, DESC *);
void clr_snoop(dbref, DESC *);
void announce_connect(dbref player, int isnew, int num);
void announce_disconnect(dbref player);
-void add_to_exit_path(DESC *d, dbref player);
+void add_to_exit_path(DESC * d, dbref player);
static struct fcache_entries fcache;
-static void fcache_dump(DESC *d, FBLOCK fp[2], const unsigned char *prefix);
-static int fcache_read(FBLOCK *cp, const char *filename);
-static void logout_sock(DESC *d);
-static void shutdownsock(DESC *d);
+static void fcache_dump(DESC * d, FBLOCK fp[2],
+ const unsigned char *prefix);
+static int fcache_dump_attr(DESC * d, dbref thing, const char *attr,
+ int html, const unsigned char *prefix);
+static int fcache_read(FBLOCK * cp, const char *filename);
+static void logout_sock(DESC * d);
+static void shutdownsock(DESC * d);
DESC *initializesock(int s, int os, char *addr, char *ip, int use_ssl);
-int process_output(DESC *d);
+int process_output(DESC * d);
/* Notify.c */
extern void free_text_block(struct text_block *t);
-extern void add_to_queue(struct text_queue *q, const unsigned char *b, int n);
-extern int queue_write(DESC *d, const unsigned char *b, int n);
-extern int queue_eol(DESC *d);
-extern int queue_newwrite(DESC *d, const unsigned char *b, int n);
-extern int queue_string(DESC *d, const char *s);
-extern int queue_string_eol(DESC *d, const char *s);
-extern void freeqs(DESC *d);
-static void welcome_user(DESC *d);
-static void dump_info(DESC *call_by);
-static void save_command(DESC *d, const unsigned char *command);
-static int process_input(DESC *d, int output_ready);
-static void process_input_helper(DESC *d, char *tbuf1, int got);
-static void set_userstring(unsigned char **userstring, const char *command);
+extern void add_to_queue(struct text_queue *q, const unsigned char *b,
+ int n);
+extern int queue_write(DESC * d, const unsigned char *b, int n);
+extern int queue_eol(DESC * d);
+extern int queue_newwrite(DESC * d, const unsigned char *b, int n);
+extern int queue_string(DESC * d, const char *s);
+extern int queue_string_eol(DESC * d, const char *s);
+extern void freeqs(DESC * d);
+static void welcome_user(DESC * d);
+static void dump_info(DESC * call_by);
+static void save_command(DESC * d, const unsigned char *command);
+static int process_input(DESC * d, int output_ready);
+static void process_input_helper(DESC * d, char *tbuf1, int got);
+static void set_userstring(unsigned char **userstring,
+ const char *command);
static void process_commands(void);
-static void parse_puebloclient(DESC *d, char *command);
-static int dump_messages(DESC *d, dbref player, int new);
-static int check_connect(DESC *d, const char *msg);
+static void parse_puebloclient(DESC * d, char *command);
+static int dump_messages(DESC * d, dbref player, int new);
+static int check_connect(DESC * d, const char *msg);
static void parse_connect(const char *msg, char *command, char *user,
char *pass);
static void close_sockets(void);
#endif
#endif
extern pid_t forked_dump_pid; /**< Process id of forking dump process */
-static void dump_users(DESC *call_by, char *match, int doing);
+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);
void load_reboot_db(void);
static bool in_suid_root_mode = 0;
static char *pidfile = NULL;
-static char *console_user = NULL; /* For defining a user to autmatically log into with console */
+static char *console_user = NULL; /* For defining a user to autmatically log into with console */
static char **saved_argv = NULL;
int file_watch_init(void);
void file_watch_event(int);
-
+
#ifdef HAS_GETRLIMIT
static void
init_rlimit(void)
char *eq;
bool detach_session = 1;
struct module_entry_t *m;
- void (*handle)();
+ void (*handle) ();
/* disallow running as root on unix.
* This is done as early as possible, before translation is initialized.
#ifdef HAVE_GETUID
if (getuid() == 0) {
fputs("Please run the server as another user.\n", stderr);
- fputs("PennMUSH will not run as root as a security measure.\n", stderr);
+ fputs("PennMUSH will not run as root as a security measure.\n",
+ stderr);
return EXIT_FAILURE;
}
/* Add suid-root checks here. */
#endif
#ifdef HAVE_GETEUID
if (geteuid() == 0) {
- fprintf(stderr, "The %s binary is set suid and owned by root.\n", argv[0]);
+ fprintf(stderr, "The %s binary is set suid and owned by root.\n",
+ argv[0]);
#ifdef HAVE_SETEUID
fprintf(stderr, "Changing effective user to %d.\n", getuid());
seteuid(getuid());
}
#endif /* HAVE_GETEUID */
#endif /* !WIN32 */
-
+
/* read the configuration file */
- if (argc < 2) {
- fprintf(stderr,
- "WARNING: Called without a config file argument. Assuming mush.cnf\n");
+ if (argc < 2) {
+ fprintf(stderr,
+ "WARNING: Called without a config file argument. Assuming mush.cnf\n");
strcpy(confname, "mush.cnf");
} else {
int n;
else if (strcmp(argv[n], "--console") == 0) {
console_mode = 1;
detach_session = 0;
- } else if(strncmp(argv[n], "--user",6) == 0) {
- fprintf(stderr, "USING USER OPTION\n");
- if ((eq = strchr(argv[n], '='))) {
- console_user = eq + 1;
- console_mode = 1;
- detach_session = 0;
- } else {
- if (n + 1 >= argc) {
- fprintf(stderr, "%s: --user needs a user to log into.\n", argv[0]);
+ } else if (strncmp(argv[n], "--user", 6) == 0) {
+ fprintf(stderr, "USING USER OPTION\n");
+ if ((eq = strchr(argv[n], '='))) {
+ console_user = eq + 1;
+ console_mode = 1;
+ detach_session = 0;
+ } else {
+ if (n + 1 >= argc) {
+ fprintf(stderr, "%s: --user needs a user to log into.\n",
+ argv[0]);
return EXIT_FAILURE;
}
- console_user = argv[n + 1];
- n++;
- /* Assume console mode & non-session */
- console_mode = 1;
- detach_session = 0;
- }
- } else if (strncmp(argv[n], "--pid-file", 10) == 0) {
+ console_user = argv[n + 1];
+ n++;
+ /* Assume console mode & non-session */
+ console_mode = 1;
+ detach_session = 0;
+ }
+ } else if (strncmp(argv[n], "--pid-file", 10) == 0) {
if ((eq = strchr(argv[n], '=')))
pidfile = eq + 1;
else {
if (n + 1 >= argc) {
- fprintf(stderr, "%s: --pid-file needs a filename.\n", argv[0]);
+ fprintf(stderr, "%s: --pid-file needs a filename.\n",
+ argv[0]);
return EXIT_FAILURE;
}
pidfile = argv[n + 1];
break;
}
}
- }
+ }
#ifdef HAVE_FORK
/* Fork off and detach from controlling terminal. */
#endif
saved_argv = argv;
-
+
#ifdef WIN32
{
close_sockets();
sql_shutdown();
- mush_lua_stop(); /* shutdown the lua environment */
+ mush_lua_stop(); /* shutdown the lua environment */
#ifdef INFO_SLAVE
kill_info_slave();
#endif
dump_database();
-
+
/* Replacement for local_shutdown */
MODULE_ITER(m) {
MODULE_FUNC_NOARGS(handle, m->handle, "module_shutdown");
else if (secs == 1)
return (now->tv_usec + (1000000 - then->tv_usec)) / 100;
else if (secs > 1)
- return (secs * 1000) + ((now->tv_usec + (1000000 - then->tv_usec)) / 1000);
+ return (secs * 1000) +
+ ((now->tv_usec + (1000000 - then->tv_usec)) / 1000);
else
return 0;
}
}
}
-static const char *empabb(dbref player) {
- static char str[4];
- ATTR *a;
- /*
- dbref start, end, last;
- */
- dbref start;
-
- memset(str, '\0', 4);
-
- if(!IsDivision(SDIV(player).object))
- goto bad_empabb_value;
- start = SDIV(player).object;
-
- /*
- for(last = end = start; GoodObject(end) && IsDivision(end) &&
- !has_flag_by_name(end, "EMPIRE", TYPE_DIVISION) ; last = end, end = SDIV(end).object)
- ;
- if(!has_flag_by_name(end, "EMPIRE", TYPE_DIVISION)) {
- if(end == NOTHING && IsDivision(last))
- end = last;
- else end = start;
- }
- */
- /* K, end is the empire we're grabbing this off of */
- a = atr_get(start, "ALIAS");
- if(!a)
- goto bad_empabb_value;
- strncpy(str, atr_value(a), 3);
- if(!str[0])
- goto bad_empabb_value;
- return str;
+static const char *
+empabb(dbref player)
+{
+ static char str[4];
+ ATTR *a;
+ /*
+ dbref start, end, last;
+ */
+ dbref start;
+
+ memset(str, '\0', 4);
+
+ if (!IsDivision(SDIV(player).object))
+ goto bad_empabb_value;
+ start = SDIV(player).object;
+
+ /*
+ for(last = end = start; GoodObject(end) && IsDivision(end) &&
+ !has_flag_by_name(end, "EMPIRE", TYPE_DIVISION) ; last = end, end = SDIV(end).object)
+ ;
+ if(!has_flag_by_name(end, "EMPIRE", TYPE_DIVISION)) {
+ if(end == NOTHING && IsDivision(last))
+ end = last;
+ else end = start;
+ }
+ */
+ /* K, end is the empire we're grabbing this off of */
+ a = atr_get(start, "ALIAS");
+ if (!a)
+ goto bad_empabb_value;
+ strncpy(str, atr_value(a), 3);
+ if (!str[0])
+ goto bad_empabb_value;
+ return str;
bad_empabb_value:
- strncpy(str, "---", 3);
- return str;
+ strncpy(str, "---", 3);
+ return str;
}
static void
shovechars(Port_t port __attribute__ ((__unused__)),
- Port_t sslport __attribute__ ((__unused__)))
+ Port_t sslport __attribute__ ((__unused__)))
{
/* this is the main game loop */
if (console_output >= maxd)
maxd = console_output + 1;
- initializesock(console_input, console_output, "localhost", "127.0.0.1", 0);
+ initializesock(console_input, console_output, "localhost",
+ "127.0.0.1", 0);
sock = 0;
#ifdef HAVE_SSL
maxd = sock + 1;
#ifdef HAVE_SSL
if (sslport) {
- sslsock = make_socket(sslport, SOCK_STREAM, NULL, NULL, SSL_IP_ADDR);
+ sslsock =
+ make_socket(sslport, SOCK_STREAM, NULL, NULL, SSL_IP_ADDR);
ssl_master_socket = ssl_setup_socket(sslsock);
if (sslsock >= maxd)
maxd = sslsock + 1;
if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
} else {
- do_rawlog(LT_ERR, T("ERROR! forking dump exited with exit code %d"),
+ do_rawlog(LT_ERR,
+ T("ERROR! forking dump exited with exit code %d"),
WEXITSTATUS(dump_status));
flag_broadcast("ROYALTY WIZARD", 0,
T("GAME: ERROR! Forking database save failed!"));
socket_ident = ident_id(newsock, &timeout);
if (socket_ident) {
/* Truncate at first non-printable character */
- for (chp = socket_ident; *chp && isprint((unsigned char) *chp); chp++) ;
+ for (chp = socket_ident; *chp && isprint((unsigned char) *chp);
+ chp++);
*chp = '\0';
safe_str(socket_ident, tbuf1, &bp);
safe_chr('@', tbuf1, &bp);
#endif
return 0;
}
- do_rawlog(LT_CONN, T("[%d/%s/%s] Connection opened."), newsock, tbuf1, tbuf2);
+ do_rawlog(LT_CONN, T("[%d/%s/%s] Connection opened."), newsock, tbuf1,
+ tbuf2);
set_keepalive(newsock);
return initializesock(newsock, newsock, tbuf1, tbuf2, use_ssl);
}
static void
-clearstrings(DESC *d)
+clearstrings(DESC * d)
{
if (d->output_prefix) {
mush_free((Malloc_t) d->output_prefix, "userstring");
}
}
+static int
+fcache_dump_attr(DESC * d, dbref thing, const char *attr, int html,
+ const unsigned char *prefix)
+{
+ ATTR *a;
+ char *wsave[10], *rsave[NUMQ];
+ char arg[BUFFER_LEN], *save, *buff, *bp;
+ char const *sp;
+ int j;
+
+ if (!GoodObject(thing) || IsGarbage(thing))
+ return 0;
+
+ a = atr_get(thing, attr);
+ if (!a)
+ return -1;
+
+ bp = arg;
+ safe_integer(d->descriptor, arg, &bp);
+ *bp = '\0';
+ buff = (char *) mush_malloc(BUFFER_LEN, "string");
+ if (!buff) {
+ mush_panic("Unable to allocate memory in fcache_dump_attr");
+ return -2;
+ }
+ save_global_regs("send_txt", rsave);
+ for (j = 0; j < 10; j++) {
+ wsave[j] = global_eval_context.wenv[j];
+ global_eval_context.wenv[j] = NULL;
+ }
+ for (j = 0; j < NUMQ; j++)
+ global_eval_context.renv[j][0] = '\0';
+ global_eval_context.wenv[0] = arg;
+ sp = save = safe_atr_value(a);
+ bp = buff;
+ process_expression(buff, &bp, &sp, thing, NOTHING, NOTHING, PE_DEFAULT,
+ PT_DEFAULT, NULL);
+ safe_chr('\n', buff, &bp);
+ *bp = '\0';
+ free((void *) save);
+ if (prefix) {
+ queue_newwrite(d, prefix, u_strlen(prefix));
+ queue_eol(d);
+ }
+ if (html)
+ queue_newwrite(d, (unsigned char *) buff, strlen(buff));
+ else
+ queue_write(d, (unsigned char *) buff, strlen(buff));
+ for (j = 0; j < 10; j++) {
+ global_eval_context.wenv[j] = wsave[j];
+ }
+ restore_global_regs("send_txt", rsave);
+ mush_free((void *) buff, "string");
+
+ return 1;
+}
+
/* Display a cached text file. If a prefix line was given,
* display that line before the text file, but only if we've
* got a text file to display
*/
static void
-fcache_dump(DESC *d, FBLOCK fb[2], const unsigned char *prefix)
+fcache_dump(DESC * d, FBLOCK fb[2], const unsigned char *prefix)
{
+ int i;
+
/* If we've got nothing nice to say, don't say anything */
if (!fb[0].buff && !((d->conn_flags & CONN_HTML) && fb[1].buff))
return;
- /* We've got something to say */
- if (prefix) {
- queue_newwrite(d, prefix, u_strlen(prefix));
- queue_eol(d);
+
+ for (i = ((d->conn_flags & CONN_HTML) && fb[1].buff); i >= 0; i--) {
+ if (fb[i].thing != NOTHING) {
+ if (fcache_dump_attr(d, fb[i].thing, (char *) fb[i].buff, i, prefix)
+ == 1) {
+ /* Attr successfully evaluated and displayed */
+ return;
+ }
+ } else {
+ /* Output static text from the cached file */
+ if (prefix) {
+ queue_newwrite(d, prefix, u_strlen(prefix));
+ queue_eol(d);
+ }
+ if (i)
+ queue_newwrite(d, fb[1].buff, fb[1].len);
+ else
+ queue_write(d, fb[0].buff, fb[0].len);
+ return;
+ }
}
- if (d->conn_flags & CONN_HTML) {
- if (fb[1].buff)
- queue_newwrite(d, fb[1].buff, fb[1].len);
- else
- queue_write(d, fb[0].buff, fb[0].len);
- } else
- queue_write(d, fb[0].buff, fb[0].len);
}
static int
-fcache_read(FBLOCK *fb, const char *filename)
+fcache_read(FBLOCK * fb, const char *filename)
{
+ char objname[BUFFER_LEN];
+ char *attr;
+ dbref thing;
+ size_t len;
+
if (!fb || !filename)
return -1;
fb->buff = NULL;
fb->len = 0;
+ fb->thing = NOTHING;
+
+ /* Check for #dbref/attr */
+ if (*filename == NUMBER_TOKEN) {
+ strcpy(objname, filename);
+ if ((attr = strchr(objname, '/')) != NULL) {
+ *attr++ = '\0';
+ if ((thing = qparse_dbref(objname)) != NOTHING) {
+ /* we have #dbref/attr */
+ if (!(fb->buff = mush_malloc(BUFFER_LEN, "fcache_data"))) {
+ return -1;
+ }
+ len = strlen(attr);
+ fb->thing = thing;
+ fb->len = len;
+ memcpy(fb->buff, (unsigned char *) upcasestr(attr), len);
+ *((char *) fb->buff + len) = '\0';
+ return fb->len;
+ }
+ }
+ }
#ifdef WIN32
/* Win32 read code here */
release_fd();
if ((fd = open(filename, O_RDONLY, 0)) < 0) {
- do_rawlog(LT_ERR, T("Couldn't open cached text file '%s'"), filename);
+ do_rawlog(LT_ERR, T("Couldn't open cached text file '%s'"),
+ filename);
reserve_fd();
return -1;
}
if (fstat(fd, &sb) < 0) {
- do_rawlog(LT_ERR, T("Couldn't get the size of text file '%s'"), filename);
+ do_rawlog(LT_ERR, T("Couldn't get the size of text file '%s'"),
+ filename);
close(fd);
reserve_fd();
return -1;
if (!(fb->buff = mush_malloc(sb.st_size, "fcache_data"))) {
- do_rawlog(LT_ERR, T("Couldn't allocate %d bytes of memory for '%s'!"),
+ do_rawlog(LT_ERR,
+ T("Couldn't allocate %d bytes of memory for '%s'!"),
(int) sb.st_size, filename);
close(fd);
reserve_fd();
close(fd);
reserve_fd();
fb->len = sb.st_size;
+
}
#endif /* Posix read code */
conn = fcache_read(&fcache.connect_fcache[i], options.connect_file[i]);
motd = fcache_read(&fcache.motd_fcache[i], options.motd_file[i]);
new = fcache_read(&fcache.newuser_fcache[i], options.newuser_file[i]);
- reg = fcache_read(&fcache.register_fcache[i], options.register_file[i]);
+ reg =
+ fcache_read(&fcache.register_fcache[i], options.register_file[i]);
quit = fcache_read(&fcache.quit_fcache[i], options.quit_file[i]);
down = fcache_read(&fcache.down_fcache[i], options.down_file[i]);
full = fcache_read(&fcache.full_fcache[i], options.full_file[i]);
}
static void
-logout_sock(DESC *d)
+logout_sock(DESC * d)
{
SU_PATH *path_entry;
if (d->connected) {
fcache_dump(d, fcache.quit_fcache, NULL);
- do_rawlog(LT_CONN, T("[%d/%s/%s] Logout by %s(#%d) <Connection not dropped>"),
- d->descriptor, d->addr, d->ip, Name(d->player), d->player);
- if(d->last_time > 0) {
+ do_rawlog(LT_CONN,
+ T("[%d/%s/%s] Logout by %s(#%d) <Connection not dropped>"),
+ d->descriptor, d->addr, d->ip, Name(d->player), d->player);
+ if (d->last_time > 0) {
d->idle_total += difftime(mudtime, d->last_time);
d->unidle_times++;
}
- snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at),
- d->idle_total, d->unidle_times, d->cmds);
- tbuf1[strlen(tbuf1)+1] = '\0';
+ snprintf(tbuf1, BUFFER_LEN - 1, "%ld %ld %d %d",
+ (mudtime - d->connected_at), d->idle_total, d->unidle_times,
+ d->cmds);
+ tbuf1[strlen(tbuf1) + 1] = '\0';
(void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, 0);
announce_disconnect(d->player);
#ifdef USE_MAILER
login_number--;
if (!under_limit && (login_number < MAX_LOGINS)) {
under_limit = 1;
- do_rawlog(LT_CONN, T("Below maximum player limit of %d. Logins enabled."),
- MAX_LOGINS);
+ do_rawlog(LT_CONN,
+ T("Below maximum player limit of %d. Logins enabled."),
+ MAX_LOGINS);
}
}
} else {
- do_rawlog(LT_CONN, T("[%d/%s/%s] Logout, never connected. <Connection not dropped>"),
- d->descriptor, d->addr, d->ip);
+ do_rawlog(LT_CONN,
+ T
+ ("[%d/%s/%s] Logout, never connected. <Connection not dropped>"),
+ d->descriptor, d->addr, d->ip);
}
process_output(d); /* flush our old output */
/* pretend we have a new connection */
d->pinfo.lock = 0;
d->pinfo.function = NULL;
- while(d->su_exit_path) {
+ while (d->su_exit_path) {
path_entry = d->su_exit_path;
d->su_exit_path = path_entry->next;
mush_free(path_entry, "SU_EXIT_PATH");
}
welcome_user(d);
- for(n = 0; n < MAX_SNOOPS; n++)
+ for (n = 0; n < MAX_SNOOPS; n++)
d->snooper[n] = -1;
}
* \param d pointer to descriptor to disconnect.
*/
static void
-shutdownsock(DESC *d)
+shutdownsock(DESC * d)
{
char tbuf1[BUFFER_LEN];
if (d->connected != 2) {
fcache_dump(d, fcache.quit_fcache, NULL);
/* Player was not allowed to log in from the connect screen */
- if(d->last_time > 0) {
+ if (d->last_time > 0) {
d->idle_total += difftime(mudtime, d->last_time);
d->unidle_times++;
}
- snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at),
- d->idle_total , d->unidle_times, d->cmds);
- tbuf1[strlen(tbuf1)+1] = '\0';
+ snprintf(tbuf1, BUFFER_LEN - 1, "%ld %ld %d %d",
+ (mudtime - d->connected_at), d->idle_total, d->unidle_times,
+ d->cmds);
+ tbuf1[strlen(tbuf1) + 1] = '\0';
(void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, 0);
announce_disconnect(d->player);
#ifdef USE_MAILER
/* ARGSUSED */
DESC *
initializesock(int s, int os, char *addr, char *ip, int use_ssl
- __attribute__ ((__unused__)))
+ __attribute__ ((__unused__)))
{
DESC *d;
dbref console_player;
}
#endif
test_telnet(d);
- if(console_user) {
+ if (console_user) {
console_player = lookup_player(console_user);
- if(console_player != NOTHING) {
+ if (console_player != NOTHING) {
d->player = console_player;
d->connected = 2;
d->doing[0] = '\0';
ModTime(console_player) = (time_t) 0;
set_flag_internal(console_player, "CONNECTED");
orator = console_player;
- check_last(console_player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */
+ check_last(console_player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */
strcpy(global_eval_context.ccom, "");
} else
fprintf(stderr, "No such player");
}
- if(d->player == 0)
+ if (d->player == 0)
welcome_user(d);
- for(n = 0; n < MAX_SNOOPS; n++)
+ for (n = 0; n < MAX_SNOOPS; n++)
d->snooper[n] = -1;
return d;
}
* \retval 0 something failed, and the descriptor should probably be closed.
*/
int
-process_output(DESC *d)
+process_output(DESC * d)
{
struct text_block **qp, *cur;
int cnt;
#ifdef HAVE_SSL
&& !d->ssl
#endif
- ) {
+ ) {
/* If there's more than one pending block, try to send up to 10
at once with writev(). Doesn't work for SSL connections, and
if there's only one block waiting to go out, just use
*qp = block->nxt;
cnt -= block->nchars;
#ifdef DEBUG
- do_rawlog(LT_TRACE, "free_text_block(%p) at writev", (void *) block);
+ do_rawlog(LT_TRACE, "free_text_block(%p) at writev",
+ (void *) block);
#endif
free_text_block(block);
} else {
if (d->ssl) {
cnt = 0;
d->ssl_state =
- ssl_write(d->ssl, d->ssl_state, input_ready, 1, cur->start,
- cur->nchars, &cnt);
+ ssl_write(d->ssl, d->ssl_state, input_ready, 1, cur->start,
+ cur->nchars, &cnt);
if (ssl_want_write(d->ssl_state))
return 1; /* Need to retry */
} else
if (cnt == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
#else
#ifdef EAGAIN
- if ((errno == EWOULDBLOCK) || (errno == EAGAIN) || errno == EINTR)
+ if ((errno == EWOULDBLOCK) || (errno == EAGAIN)
+ || errno == EINTR)
#else
if (errno == EWOULDBLOCK || errno == EINTR)
#endif
static void
-welcome_user(DESC *d)
+welcome_user(DESC * d)
{
/* TODO: Add MUDURL */
if (SUPPORT_PUEBLO && !(d->conn_flags & CONN_HTML))
- queue_newwrite(d, (unsigned const char *) PUEBLO_HELLO, strlen(PUEBLO_HELLO));
+ queue_newwrite(d, (unsigned const char *) PUEBLO_HELLO,
+ strlen(PUEBLO_HELLO));
fcache_dump(d, fcache.connect_fcache, NULL);
/* TODO: Add MUDURL */
}
static void
-save_command(DESC *d, const unsigned char *command)
+save_command(DESC * d, const unsigned char *command)
{
add_to_queue(&d->input, command, u_strlen(command) + 1);
}
static void
-test_telnet(DESC *d)
+test_telnet(DESC * d)
{
/* Use rfc 1184 to test telnet support, as it tries to set linemode
with client-side editing. Good for Broken Telnet Programs. */
}
static void
-setup_telnet(DESC *d)
+setup_telnet(DESC * d)
{
/* Win2k telnet doesn't do local echo by default,
apparently. Unfortunately, there doesn't seem to be a telnet
}
static int
-handle_telnet(DESC *d, unsigned char **q, unsigned char *qend)
+handle_telnet(DESC * d, unsigned char **q, unsigned char *qend)
{
int i;
/* *(*q - q) == IAC at this point. */
switch (**q) {
- case SB: /* Sub-option */
+ case SB: /* Sub-option */
if (*q >= qend)
return -1;
(*q)++;
mush_free(d->ttype, "terminal description");
d->ttype = mush_strdup(tbuf, "terminal description");
/* We have the terminal type, now set any defaults if we find 'em */
- for(i = 0 ; client_maps[i].terminal != NULL; i++)
- if(!strcmp(client_maps[i].terminal, d->ttype)) {
+ for (i = 0; client_maps[i].terminal != NULL; i++)
+ if (!strcmp(client_maps[i].terminal, d->ttype)) {
d->conn_flags |= client_maps[i].flags;
break;
}
(*q)++;
}
break;
- case NOP: /* No-op */
+ case NOP: /* No-op */
if (*q >= qend)
return -1;
#ifdef DEBUG_TELNET
#endif
*q += 1;
break;
- case AYT: /* Are you there? */
+ case AYT: /* Are you there? */
if (*q >= qend)
return -1;
else {
static unsigned char ayt_reply[] =
- "\r\n*** AYT received, I'm here ***\r\n";
+ "\r\n*** AYT received, I'm here ***\r\n";
queue_newwrite(d, ayt_reply, u_strlen(ayt_reply));
process_output(d);
}
break;
- case WILL: /* Client is willing to do something, or confirming */
+ case WILL: /* Client is willing to do something, or confirming */
setup_telnet(d);
if (*q >= qend)
return -1;
process_output(d);
}
break;
- case DO: /* Client is asking us to do something */
+ case DO: /* Client is asking us to do something */
setup_telnet(d);
if (*q >= qend)
return -1;
process_output(d);
}
break;
- case WONT: /* Client won't do something we want. */
- case DONT: /* Client doesn't want us to do something */
+ case WONT: /* Client won't do something we want. */
+ case DONT: /* Client doesn't want us to do something */
setup_telnet(d);
#ifdef DEBUG_TELNET
fprintf(stderr, "Got IAC %s 0x%x\n", **q == WONT ? "WONT" : "DONT",
return -1;
(*q)++;
break;
- default: /* Also catches IAC IAC for a literal 255 */
+ default: /* Also catches IAC IAC for a literal 255 */
return 0;
}
return 1;
}
static void
-process_input_helper(DESC *d, char *tbuf1, int got)
+process_input_helper(DESC * d, char *tbuf1, int got)
{
unsigned char *p, *pend, *q, *qend;
/* ARGSUSED */
static int
-process_input(DESC *d, int output_ready __attribute__ ((__unused__)))
+process_input(DESC * d, int output_ready __attribute__ ((__unused__)))
{
int got = 0;
char tbuf1[BUFFER_LEN];
}
/* It's an SSL connection, proceed accordingly */
d->ssl_state =
- ssl_read(d->ssl, d->ssl_state, 1, output_ready, tbuf1, sizeof tbuf1,
- &got);
+ ssl_read(d->ssl, d->ssl_state, 1, output_ready, tbuf1,
+ sizeof tbuf1, &got);
if (d->ssl_state < 0) {
/* Fatal error */
ssl_close_connection(d->ssl);
cdesc->quota--;
nprocessed++;
start_cpu_timer();
- feed_snoop(cdesc,(const char *) t->start, 0);
+ feed_snoop(cdesc, (const char *) t->start, 0);
/* check AUNIDLE */
- if(options.idle_time && ((mudtime - cdesc->last_time) > options.idle_time)) {
- if(atr_get(cdesc->player, "AUNIDLE"))
- queue_attribute_noparent(cdesc->player, "AUNIDLE", cdesc->player);
- if(GoodObject(Division(cdesc->player)) && atr_get(Division(cdesc->player), "AUNIDLE"))
- queue_attribute(Division(cdesc->player), "AUNIDLE", cdesc->player);
+ if (options.idle_time
+ && ((mudtime - cdesc->last_time) > options.idle_time)) {
+ if (atr_get(cdesc->player, "AUNIDLE"))
+ queue_attribute_noparent(cdesc->player, "AUNIDLE",
+ cdesc->player);
+ if (GoodObject(Division(cdesc->player))
+ && atr_get(Division(cdesc->player), "AUNIDLE"))
+ queue_attribute(Division(cdesc->player), "AUNIDLE",
+ cdesc->player);
}
retval = cdesc->input_handler(cdesc, (char *) t->start);
reset_cpu_timer();
- if(retval == -1 && do_su_exit(cdesc))
+ if (retval == -1 && do_su_exit(cdesc))
retval = 1;
if (retval == 0) {
}
int
-do_command(DESC *d, char *command)
+do_command(DESC * d, char *command)
{
int j;
(d->cmds)++;
- if(difftime(mudtime, d->last_time) >= 300) {
+ if (difftime(mudtime, d->last_time) >= 300) {
d->idle_total += difftime(mudtime, d->last_time);
d->unidle_times++;
}
} else if (!strncmp(command, "SCREENHEIGHT", 12)) {
d->height = parse_integer(command + 12);
} else if (SUPPORT_PUEBLO
- && !strncmp(command, PUEBLO_COMMAND, strlen(PUEBLO_COMMAND))) {
+ && !strncmp(command, PUEBLO_COMMAND,
+ strlen(PUEBLO_COMMAND))) {
parse_puebloclient(d, command);
if (!(d->conn_flags & CONN_HTML)) {
queue_newwrite(d, (unsigned const char *) PUEBLO_SEND,
}
static void
-parse_puebloclient(DESC *d, char *command)
+parse_puebloclient(DESC * d, char *command)
{
const char *p, *end;
if ((p = string_match(command, "md5="))) {
}
static int
-dump_messages(DESC *d, dbref player, int isnew)
+dump_messages(DESC * d, dbref player, int isnew)
{
struct module_entry_t *m;
- void (*handle)(dbref, int, int);
+ void (*handle) (dbref, int, int);
int is_hidden;
int num = 0;
if (ModTime(player))
notify_format(player, T("%ld failed connections since last login."),
- (long) ModTime(player));
+ (long) ModTime(player));
ModTime(player) = (time_t) 0;
announce_connect(player, isnew, num); /* broadcast connect message */
check_last(player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */
}
static int
-check_connect(DESC *d, const char *msg)
+check_connect(DESC * d, const char *msg)
{
char command[MAX_COMMAND_LEN];
char user[MAX_COMMAND_LEN];
if (string_prefix("connect", command)) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip,
+ errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_rawlog(LT_CONN, T("[%d/%s/%s] Failed connect to '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
do_rawlog(LT_CONN, T("[%d/%s/%s] Connected to %s(#%d) in %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(player), player,
- Name(Location(player)), Location(player));
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ Name(Location(player)), Location(player));
/* Check if we're fake siting this guy.. */
- if(has_flag_by_name(player, "WEIRDSITE", TYPE_PLAYER)) {
- ATTR *a;
- a = atr_get(player, "LASTSITE");
- strncpy(d->addr, !a ? "localhost" : atr_value(a), 100);
+ if (has_flag_by_name(player, "WEIRDSITE", TYPE_PLAYER)) {
+ ATTR *a;
+ a = atr_get(player, "LASTSITE");
+ strncpy(d->addr, !a ? "localhost" : atr_value(a), 100);
}
if ((dump_messages(d, player, 0)) == 0) {
} else if (!strcasecmp(command, "cd")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip,
+ errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_rawlog(LT_CONN, T("[%d/%s/%s] Failed connect to '%s'."),
d->descriptor, d->addr, d->ip, user);
} else if (!strcasecmp(command, "cv")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip,
+ errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_rawlog(LT_CONN, T("[%d/%s/%s] Failed connect to '%s'."),
d->descriptor, d->addr, d->ip, user);
} else if (!strcasecmp(command, "ch")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip,
+ errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_rawlog(LT_CONN, T("[%d/%s/%s] Failed connect to '%s'."),
d->descriptor, d->addr, d->ip, user);
if (!Deny_Silent_Site(d->addr, AMBIGUOUS)
&& !Deny_Silent_Site(d->ip, AMBIGUOUS)) {
do_rawlog(LT_CONN,
- T("[%d/%s/%s] Refused registration (bad site) for '%s'."),
+ T
+ ("[%d/%s/%s] Refused registration (bad site) for '%s'."),
d->descriptor, d->addr, d->ip, user);
}
return 0;
} else {
queue_string_eol(d, T(register_success));
do_rawlog(LT_CONN, T("[%d/%s/%s] Registered %s(#%d) to %s"),
- d->descriptor, d->addr, d->ip, Name(player), player, password);
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ password);
}
/* Whether it succeeds or fails, leave them connected */
welcome_user(d);
}
/* If they were in a program, get them back in it */
- if(InProg(d->player)) {
+ if (InProg(d->player)) {
queue_string(d, "Loading @Program onto Descriptor....\r\n");
prog_load_desc(d);
}
p = (unsigned char *) user;
if (*msg == '\"') {
- for (; *msg && ((*msg == '\"') || isspace(*msg)); msg++) ;
+ for (; *msg && ((*msg == '\"') || isspace(*msg)); msg++);
while (*msg && (*msg != '\"')) {
while (*msg && !isspace(*msg) && (*msg != '\"'))
*p++ = *msg++;
ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) shutmsg,
shutlen, &offset);
offset = 0;
- ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) "\r\n", 2, &offset);
+ ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) "\r\n", 2,
+ &offset);
const char *shutmsg = T(shutdown_message);
offset = 0;
ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) shutmsg,
strlen(shutmsg), &offset);
offset = 0;
- ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) "\r\n", 2, &offset);
+ ssl_write(d->ssl, d->ssl_state, 0, 1, (uint8_t *) "\r\n", 2,
+ &offset);
ssl_close_connection(d->ssl);
d->ssl = NULL;
d->ssl_state = 0;
* \param d pointer to descriptor to disconnect.
*/
void
-boot_desc(DESC *d)
+boot_desc(DESC * d)
{
shutdownsock(d);
}
* \param message message to send.
*/
void
-do_page_port(dbref player, dbref cause, const char *pc, const char *message, bool eval_msg)
+do_page_port(dbref player, dbref cause, const char *pc,
+ const char *message, bool eval_msg)
{
int p, key;
DESC *d;
return;
}
- process_expression(tbuf, &tbp, &pc, player, cause, cause, PE_DEFAULT, PT_DEFAULT, NULL);
+ process_expression(tbuf, &tbp, &pc, player, cause, cause, PE_DEFAULT,
+ PT_DEFAULT, NULL);
*tbp = '\0';
p = atoi(tbuf);
tbp = tbuf;
}
if (eval_msg) {
- process_expression(mbuf, &mbp, &message, player, cause, cause, PE_DEFAULT, PT_DEFAULT, NULL);
+ process_expression(mbuf, &mbp, &message, player, cause, cause,
+ PE_DEFAULT, PT_DEFAULT, NULL);
*mbp = '\0';
message = mbuf;
}
if (!*message) {
- notify(player, T("What do you want to page with?"));
+ notify(player, T("What do you want to page with?"));
return;
}
message + 1);
notify_format(player, T("Long distance to %s: %s%s%s"),
target != NOTHING ? Name(target) :
- T("a connecting player"), Name(player), gap, message + 1);
+ T("a connecting player"), Name(player), gap,
+ message + 1);
break;
case 3:
safe_format(tbuf, &tbp, T("%s pages: %s"), Name(player), message);
WAIT_TYPE my_stat;
pid_t pid;
- while ((pid = mush_wait(-1, &my_stat, WNOHANG)) > 0) {
+ while ((pid = mush_wait(-1, &my_stat, WNOHANG)) > 0) {
#ifdef INFO_SLAVE
if (info_slave_pid > -1 && pid == info_slave_pid) {
do_rawlog(LT_ERR, T("info_slave on pid %d exited!"), pid);
}
reload_sig_handler(SIGCHLD, reaper);
}
-#endif /* !WIN32 */
+#endif /* !WIN32 */
static void
-dump_info(DESC *call_by)
+dump_info(DESC * call_by)
{
int count = 0;
DESC *d;
if (d->connected) {
if (!GoodObject(d->player))
continue;
- if (COUNT_ALL || !Hidden(d) || call_by->player == d->player )
+ if (COUNT_ALL || !Hidden(d) || call_by->player == d->player)
count++;
}
}
queue_string_eol(call_by, tprintf("Name: %s", options.mud_name));
queue_string_eol(call_by,
- tprintf("Uptime: %s", show_time(globals.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,
- VBRANCH));
+ VBRANCH));
queue_string_eol(call_by, "### End INFO");
}
static void
-dump_users(DESC *call_by, char *match, int doing)
+dump_users(DESC * call_by, char *match, int doing)
/* doing: 0 if normal WHO, 1 if DOING, 2 if SESSION */
{
DESC *d;
#ifdef COLOREDWHO
- int tcount = 0;
+ int tcount = 0;
#endif
int count = 0;
time_t now;
int csite;
if (!GoodObject(call_by->player)) {
- do_rawlog(LT_ERR, T("Bogus caller #%d of dump_users"), call_by->player);
+ do_rawlog(LT_ERR, T("Bogus caller #%d of dump_users"),
+ call_by->player);
return;
}
while (*match && *match == ' ')
*/
if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
- queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=html>", 19);
+ queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=html>",
+ 19);
queue_newwrite(call_by, (const unsigned char *) "<PRE>", 5);
}
if (poll_msg[0] == '\0')
strcpy(poll_msg, "Doing");
if (ShowAnsi(call_by->player))
- snprintf(tbuf2, BUFFER_LEN, "%s%-16s %4s %10s %6s %s%s\n", ANSI_HILITE,
- T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg, ANSI_END);
+ snprintf(tbuf2, BUFFER_LEN, "%s%-16s %4s %10s %6s %s%s\n",
+ ANSI_HILITE, T("Player Name"), T("Aff"), T("On For"),
+ T("Idle"), poll_msg, ANSI_END);
else
snprintf(tbuf2, BUFFER_LEN, "%-16s %4s %10s %6s %s\n",
- T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg);
+ T("Player Name"), T("Aff"), T("On For"), T("Idle"),
+ poll_msg);
queue_string(call_by, tbuf2);
} else if (doing == 2) {
- snprintf(tbuf2, BUFFER_LEN, "%s%-16s %6s %9s %5s %5s Des Sent Recv Pend%s\n", ShowAnsi(call_by->player) ? ANSI_HILITE :
- "", T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"),
- ShowAnsi(call_by->player) ? ANSI_END : "");
+ snprintf(tbuf2, BUFFER_LEN,
+ "%s%-16s %6s %9s %5s %5s Des Sent Recv Pend%s\n",
+ ShowAnsi(call_by->player) ? ANSI_HILITE : "",
+ T("Player Name"), T("Loc #"), T("On For"), T("Idle"),
+ T("Cmds"), ShowAnsi(call_by->player) ? ANSI_END : "");
queue_string(call_by, tbuf2);
} else {
- snprintf(tbuf2, BUFFER_LEN, "%s%-16s %6s %9s %5s %5s Des Host%s\n", ShowAnsi(call_by->player) ? ANSI_HILITE : "",
- T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"), ShowAnsi(call_by->player) ? ANSI_END : "");
+ snprintf(tbuf2, BUFFER_LEN, "%s%-16s %6s %9s %5s %5s Des Host%s\n",
+ ShowAnsi(call_by->player) ? ANSI_HILITE : "",
+ T("Player Name"), T("Loc #"), T("On For"), T("Idle"),
+ T("Cmds"), ShowAnsi(call_by->player) ? ANSI_END : "");
queue_string(call_by, tbuf2);
}
if (d->connected) {
if (!GoodObject(d->player))
continue;
- if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player
- || (call_by->player && Priv_Who(call_by->player)))) {
- count++;
+ if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player
+ || (call_by->player
+ && Priv_Who(call_by->player)))) {
+ count++;
#ifdef COLOREDWHO
- tcount++;
+ tcount++;
#endif
}
if (match && !(string_prefix(Name(d->player), match)))
if (Hidden(d) && !csite)
continue;
- sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
- time_format_1(now - d->connected_at),
+ sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s",
+ tprintf("%s%s", Name(d->player),
+ InProg(d->player) ? "(P)" : ""),
+ Can_Locate(call_by->player,
+ d->player) ? unparse_dbref(Location(d->
+ player)) :
+ "#-1", time_format_1(now - d->connected_at),
time_format_2(now - d->last_time), csite ? d->cmds : 0,
csite ? d->descriptor : 0,
#ifdef HAVE_SSL
} else if (call_by->connected && doing == 2 && call_by->player
&& Priv_Who(call_by->player)) {
sprintf(tbuf1, "%-16s %6s %9s %5s %5d %3d%c %5lu %7lu %5d",
- tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
- time_format_1(now - d->connected_at),
+ tprintf("%s%s", Name(d->player),
+ InProg(d->player) ? "(P)" : ""),
+ Can_Locate(call_by->player,
+ d->player) ? unparse_dbref(Location(d->
+ player)) :
+ "#-1", time_format_1(now - d->connected_at),
time_format_2(now - d->last_time), csite ? d->cmds : 0,
csite ? d->descriptor : 0,
#ifdef HAVE_SSL
#else
' ',
#endif
-
csite ? d->input_chars : 0, csite ? d->output_chars : 0,
csite ? d->output_size : 0);
} else {
if (!Hidden(d)
|| call_by->player == d->player ||
(call_by->player && Priv_Who(call_by->player) && (doing))) {
- snprintf(tbuf1, BUFFER_LEN, "%-16s %4s %10s %4s%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""), empabb(d->player),
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time),
- (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' '))
- , d->doing);
+ snprintf(tbuf1, BUFFER_LEN, "%-16s %4s %10s %4s%c %s",
+ tprintf("%s%s", Name(d->player),
+ InProg(d->player) ? "(P)" : ""),
+ empabb(d->player), time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time),
+ (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' '))
+ , d->doing);
}
}
if (!Hidden(d) || (call_by->player && Priv_Who(call_by->player))) {
#ifdef COLOREDWHO
- if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_END, (tcount % 2 ? "" : ANSI_HILITE),
- (tcount % 2 ? ANSI_CYAN : ANSI_WHITE),
- tbuf1, ANSI_NORMAL));
+ if (ShowAnsiColor(call_by->player))
+ queue_string(call_by,
+ tprintf("%s%s%s%s%s", ANSI_END,
+ (tcount % 2 ? "" : ANSI_HILITE),
+ (tcount % 2 ? ANSI_CYAN : ANSI_WHITE),
+ tbuf1, ANSI_NORMAL));
- else
+ else
#endif
- queue_string(call_by, tbuf1);
+ queue_string(call_by, tbuf1);
queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
}
} else if (call_by->player && Priv_Who(call_by->player) && doing != 1
#endif
if (doing == 0) {
/* Privileged WHO for non-logged in connections */
- snprintf(tbuf1, BUFFER_LEN, "%-16s %6s %9s %5s %4d %3d%c %s", T("Connecting..."),
- "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), d->cmds, d->descriptor,
- #ifdef HAVE_SSL
- d->ssl ? 'S' : ' ',
- #else
- ' ',
- #endif
-
- d->addr);
+ snprintf(tbuf1, BUFFER_LEN, "%-16s %6s %9s %5s %4d %3d%c %s",
+ T("Connecting..."), "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), d->cmds, d->descriptor,
+#ifdef HAVE_SSL
+ d->ssl ? 'S' : ' ',
+#else
+ ' ',
+#endif
+ d->addr);
tbuf1[78] = '\0';
} else {
/* SESSION for non-logged in connections */
- snprintf(tbuf1, BUFFER_LEN, "%-16s %5s %9s %5s %5d %3d%c %5lu %7lu %5d",
- T("Connecting..."), "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), d->cmds, d->descriptor,
- #ifdef HAVE_SSL
- d->ssl ? 'S' : ' ',
- #else
- ' ',
- #endif
- d->input_chars, d->output_chars, d->output_size);
+ snprintf(tbuf1, BUFFER_LEN,
+ "%-16s %5s %9s %5s %5d %3d%c %5lu %7lu %5d",
+ T("Connecting..."), "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), d->cmds, d->descriptor,
+#ifdef HAVE_SSL
+ d->ssl ? 'S' : ' ',
+#else
+ ' ',
+#endif
+ d->input_chars, d->output_chars, d->output_size);
}
#ifdef COLOREDWHO
- if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL,tcount % 2 ? "" : ANSI_HILITE,
- tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
- else
+ if (ShowAnsiColor(call_by->player))
+ queue_string(call_by,
+ tprintf("%s%s%s%s%s", ANSI_NORMAL,
+ tcount % 2 ? "" : ANSI_HILITE,
+ tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1,
+ ANSI_NORMAL));
+ else
#endif
- queue_string(call_by, tbuf1);
+ queue_string(call_by, tbuf1);
queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
}
}
mush_strncpy(tbuf1, T("There is 1 player connected."), BUFFER_LEN);
break;
default:
- snprintf(tbuf1, BUFFER_LEN, T("There are %d players connected."), count);
+ snprintf(tbuf1, BUFFER_LEN, T("There are %d players connected."),
+ count);
break;
}
#ifdef COLOREDWHO
- if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount+1) % 2 ? "" : ANSI_HILITE ,
- (tcount+1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
- else
+ if (ShowAnsiColor(call_by->player))
+ queue_string(call_by,
+ tprintf("%s%s%s%s%s", ANSI_NORMAL,
+ (tcount + 1) % 2 ? "" : ANSI_HILITE,
+ (tcount + 1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1,
+ ANSI_NORMAL));
+ else
#endif
- queue_string(call_by, tbuf1);
+ queue_string(call_by, tbuf1);
if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
queue_newwrite(call_by, (const unsigned char *) "\n</PRE>\n", 8);
- queue_newwrite(call_by, (const unsigned char *) "<img xch_mode=purehtml>", 23);
+ queue_newwrite(call_by,
+ (const unsigned char *) "<img xch_mode=purehtml>", 23);
} else
queue_newwrite(call_by, (const unsigned char *) "\r\n", 2);
}
/* Redundant, but better for translators */
if (Dark(player)) {
- message = (num > 1) ? T("has DARK-reconnected.") : T("has DARK-connected.");
+ message =
+ (num > 1) ? T("has DARK-reconnected.") : T("has DARK-connected.");
} else if (hidden(player)) {
message = (num > 1) ? T("has HIDDEN-reconnected.") :
- T("has HIDDEN-connected.");
+ T("has HIDDEN-connected.");
} else {
message = (num > 1) ? T("has reconnected.") : T("has connected.");
}
#ifdef CHAT_SYSTEM
if (ANNOUNCE_CONNECTS)
chat_player_announce(player, message, (num == 1));
-#endif /* CHAT_SYSTEM */
+#endif /* CHAT_SYSTEM */
loc = Location(player);
if (!GoodObject(loc)) {
}
raw_notify(player, " ");
- if(ANNOUNCE_CONNECTS)
+ if (ANNOUNCE_CONNECTS)
notify_except(Contents(player), player, tbuf1, 0);
/* added to allow player's inventory to hear a player connect */
- if(ANNOUNCE_CONNECTS)
- if(!Dark(player))
- notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
+ if (ANNOUNCE_CONNECTS)
+ if (!Dark(player))
+ notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
/* clear the environment for possible actions */
for (j = 0; j < 10; j++)
int num;
DESC *d;
char tbuf1[BUFFER_LEN];
- /* TODO: See above, char *message; */
+ /* TODO: See above, char *message; */
dbref zone, obj;
int j;
struct module_entry_t *m;
- void (*handle)(dbref, int);
+ void (*handle) (dbref, int);
}
break;
default:
- do_rawlog(LT_ERR, T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
- Name(player), player, Typeof(zone));
+ do_rawlog(LT_ERR,
+ T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
+ Name(player), player, Typeof(zone));
}
}
/* now try the master room */
#ifdef CHAT_SYSTEM
if (ANNOUNCE_CONNECTS)
chat_player_announce(player, tbuf1, 0);
-#endif /* CHAT_SYSTEM */
+#endif /* CHAT_SYSTEM */
/* Monitor broadcasts */
/* Redundant, but better for translators */
}
if (!Dark(player))
flag_broadcast(0, "MONITOR", "%s %s", T("GAME:"), tbuf1);
- if(Guest(player) && !Connected(player)) { /* queue for destruction */
- set_flag_internal(player, "GOING");
- set_flag_internal(player, "GOING_TWICE");
- }
+ if (Guest(player) && !Connected(player)) { /* queue for destruction */
+ set_flag_internal(player, "GOING");
+ set_flag_internal(player, "GOING_TWICE");
+ }
/* Replacement for local_disconnect */
MODULE_ITER(m) {
MODULE_FUNC(handle, m->handle, "module_disconnect", player, num);
{
const char *what;
- if(key != MOTD_LIST && !Can_Announce(player)) {
+ if (key != MOTD_LIST && !Can_Announce(player)) {
notify(player,
T
("You may get 15 minutes of fame and glory in life, but not right now."));
/* LWHO() function - really belongs elsewhere but needs stuff declared here */
/* ARGSUSED */
-FUNCTION(fun_nwho) {
+FUNCTION(fun_nwho)
+{
DESC *d;
dbref victim;
int count = 0;
if (!Hidden(d) || powered) {
count++;
}
- }
+ }
safe_integer(count, buff, bp);
}
int objid = (strchr(called_as, 'D') != NULL);
first = 1;
- if(!xwho && nargs && args[0] && *args[0]) {
- if(!powered) {
+ if (!xwho && nargs && args[0] && *args[0]) {
+ if (!powered) {
safe_str(T(e_perm), buff, bp);
return;
}
- if( (victim = noisy_match_result(executor, args[0], NOTYPE, MAT_EVERYTHING)) == 0) {
+ if ((victim =
+ noisy_match_result(executor, args[0], NOTYPE,
+ MAT_EVERYTHING)) == 0) {
safe_str(T(e_notvis), buff, bp);
return;
}
- if(!controls(executor, victim)) {
+ if (!controls(executor, victim)) {
safe_str(T(e_perm), buff, bp);
return;
}
- if(!Priv_Who(victim))
+ if (!Priv_Who(victim))
powered = 0;
- } else victim = executor;
-
- if(xwho) {
- if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) {
- safe_str(T(e_int), buff, bp);
- return;
- }
+ } else
+ victim = executor;
+
+ if (xwho) {
+ if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) {
+ safe_str(T(e_int), buff, bp);
+ return;
+ }
start = parse_integer(args[0]) - 1;
count = parse_integer(args[1]);
/* Reset values to be in range if they're not */
- if(start < 0)
+ if (start < 0)
start = 0;
- if(count < 1)
+ if (count < 1)
count = 1;
}
DESC_ITER_CONN(d) {
- if (!Hidden(d) || (powered && CanSee(victim,d->player))) {
- if(xwho && start) {
+ if (!Hidden(d) || (powered && CanSee(victim, d->player))) {
+ if (xwho && start) {
start--;
continue;
- } else if(xwho && !count)
+ } else if (xwho && !count)
break;
- else if(xwho && count)
+ else if (xwho && count)
count--;
if (first)
else
safe_chr(' ', buff, bp);
safe_dbref(d->player, buff, bp);
- if(objid) {
+ if (objid) {
safe_chr(':', buff, bp);
safe_integer(CreTime(d->player), buff, bp);
}
{
dbref it = match_thing(executor, args[0]);
if (CanSee(executor, it) && ((Admin(executor) ||
- Location(executor) == Location(it) || Location(it) == executor))) {
- if ((it == NOTHING) || (!IsPlayer(it))) {
- notify(executor, T("Couldn't find that player."));
+ Location(executor) == Location(it)
+ || Location(it) == executor))) {
+ if ((it == NOTHING) || (!IsPlayer(it))) {
+ notify(executor, T("Couldn't find that player."));
+ safe_str("#-1", buff, bp);
+ return;
+ }
+ safe_boolean(hidden(it), buff, bp);
+ return;
+ } else {
+ notify(executor, T("Permission denied."));
safe_str("#-1", buff, bp);
return;
}
- safe_boolean(hidden(it), buff, bp);
- return;
- } else {
- notify(executor, T("Permission denied."));
- safe_str("#-1", buff, bp);
- return;
- }
}
#ifdef WIN32
d = im_find(descs_by_fd, fd);
if (d && (Priv_Who(executor) || d->player == executor
- || (Inherit_Powers(executor) && Priv_Who(Owner(executor)))))
+ || (Inherit_Powers(executor) && Priv_Who(Owner(executor)))))
return d;
else
return NULL;
-
- } else { /* Look up player name */
+
+ } else { /* Look up player name */
DESC *match = NULL;
dbref target = lookup_player(name);
if (target == NOTHING) {
DESC_ITER_CONN(d) {
if ((d->player == target) &&
(!Hidden(d) || Priv_Who(executor) ||
- (Inherit_Powers(executor) && Priv_Who(Owner(executor)))) &&
+ (Inherit_Powers(executor) && Priv_Who(Owner(executor)))) &&
(!match || (d->last_time > match->last_time)))
match = d;
}
{
DESC *d, *match = NULL;
DESC_ITER_CONN(d) {
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
+ if ((d->player == player)
+ && (!match || (d->last_time > match->last_time)))
match = d;
}
if (match) {
{
DESC *d, *match = NULL;
DESC_ITER_CONN(d) {
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
+ if ((d->player == player)
+ && (!match || (d->last_time > match->last_time)))
match = d;
}
return match ? (match->ip) : NULL;
char *p;
DESC_ITER_CONN(d) {
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
+ if ((d->player == player)
+ && (!match || (d->last_time > match->last_time)))
match = d;
}
if (!match)
return;
}
- if (!GoodObject(zone) || (!Priv_Who(executor) && !(eval_lock(victim, zone, Zone_Lock) || CanSee(victim,zone)))) {
+ if (!GoodObject(zone)
+ || (!Priv_Who(executor)
+ && !(eval_lock(victim, zone, Zone_Lock)
+ || CanSee(victim, zone)))) {
safe_str(T(e_perm), buff, bp);
return;
}
if ((getlock(zone, Zone_Lock) == TRUE_BOOLEXP) ||
- (IsPlayer(zone) && !(has_flag_by_name(zone, "SHARED", TYPE_PLAYER)))) {
+ (IsPlayer(zone)
+ && !(has_flag_by_name(zone, "SHARED", TYPE_PLAYER)))) {
safe_str(T("#-1 INVALID ZONE."), buff, bp);
return;
}
DESC_ITER_CONN(d) {
if (Zone(Location(d->player)) == zone &&
- (!Hidden(d) || (powered && CanSee(victim, d->player))) ) {
- if (first) {
- first = 0;
- } else {
- safe_chr(' ', buff, bp);
- }
- safe_dbref(d->player, buff, bp);
- if (objid) {
- safe_chr(':', buff, bp);
- safe_integer(CreTime(d->player), buff, bp);
- }
+ (!Hidden(d) || (powered && CanSee(victim, d->player)))) {
+ if (first) {
+ first = 0;
+ } else {
+ safe_chr(' ', buff, bp);
}
+ safe_dbref(d->player, buff, bp);
+ if (objid) {
+ safe_chr(':', buff, bp);
+ safe_integer(CreTime(d->player), buff, bp);
+ }
+ }
}
}
}
/* ARGSUSED */
-FUNCTION(fun_idle_average) {
+FUNCTION(fun_idle_average)
+{
DESC *match = lookup_desc(executor, args[0]);
double idle_time;
- if(match) {
+ if (match) {
idle_time = difftime(mudtime, match->last_time);
- if(idle_time >= 300)
- safe_number(((match->idle_total + idle_time) / (match->unidle_times+1)), buff, bp);
- else if(match->unidle_times == 0)
+ if (idle_time >= 300)
+ safe_number(((match->idle_total + idle_time) / (match->unidle_times +
+ 1)), buff, bp);
+ else if (match->unidle_times == 0)
safe_number(0, buff, bp);
else
safe_number((match->idle_total / match->unidle_times), buff, bp);
-
+
} else
safe_str("-1", buff, bp);
}
/* ARGSUSED */
-FUNCTION(fun_idle_total) {
+FUNCTION(fun_idle_total)
+{
DESC *match = lookup_desc(executor, args[0]);
double idle_time;
- if(match) {
+ if (match) {
idle_time = difftime(mudtime, match->last_time);
- safe_number(idle_time >= 300 ? (match->idle_total+idle_time) : match->idle_total, buff, bp);
+ safe_number(idle_time >=
+ 300 ? (match->idle_total + idle_time) : match->idle_total,
+ buff, bp);
} else
safe_str("-1", buff, bp);
}
/* ARGSUSED */
-FUNCTION(fun_idle_times) {
+FUNCTION(fun_idle_times)
+{
DESC *match = lookup_desc(executor, args[0]);
- if(match) {
- safe_number((difftime(mudtime, match->last_time) >= 300) ?
- (match->unidle_times+1) : match->unidle_times, buff, bp);
+ if (match) {
+ safe_number((difftime(mudtime, match->last_time) >= 300) ?
+ (match->unidle_times + 1) : match->unidle_times, buff, bp);
} else
safe_str("-1", buff, bp);
}
int first = 1;
if (!Priv_Who(executor)
- && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
+ && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
safe_str(T(e_perm), buff, bp);
return;
}
MAT_ABSOLUTE | MAT_PLAYER | MAT_ME);
}
if (target != executor && !Priv_Who(executor)
- && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
+ && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
/* This should probably be a safe_str */
notify(executor, T("Permission denied."));
return;
idle_for = (int) difftime(now, d->last_time);
/* If they've been connected for 60 seconds without getting a telnet-option
back, the client probably doesn't understand them */
- if ((d->conn_flags & CONN_TELNET_QUERY) && difftime(now, d->connected_at) > 60)
+ if ((d->conn_flags & CONN_TELNET_QUERY)
+ && difftime(now, d->connected_at) > 60)
d->conn_flags &= ~CONN_TELNET_QUERY;
/* If they've been idle for 60 seconds and are set KEEPALIVE and using
a telnet-aware client, send a NOP */
process_output(d);
}
- if(d->connected && GoodObject(d->player) && ((a = atr_get(d->player, "IDLE_TIMEOUT"))!=NULL)) {
- memset(tbuf, '\0', BUFFER_LEN);
- strncpy(tbuf, atr_value(a), BUFFER_LEN-1);
- idle = atoi(tbuf);
- if(idle > 0)
- goto after_idle_atr_check;
- }
+ if (d->connected && GoodObject(d->player)
+ && ((a = atr_get(d->player, "IDLE_TIMEOUT")) != NULL)) {
+ memset(tbuf, '\0', BUFFER_LEN);
+ strncpy(tbuf, atr_value(a), BUFFER_LEN - 1);
+ idle = atoi(tbuf);
+ if (idle > 0)
+ goto after_idle_atr_check;
+ }
idle = INACTIVITY_LIMIT ? INACTIVITY_LIMIT : INT_MAX;
-after_idle_atr_check:
- if ((d->connected) ? (idle_for > idle ) : (idle_for > unconnected_idle)) {
+ after_idle_atr_check:
+ if ((d->connected) ? (idle_for > idle) : (idle_for > unconnected_idle)) {
if (!d->connected)
shutdownsock(d);
queue_string(d, T("\n*** Inactivity timeout ***\n"));
do_rawlog(LT_CONN,
T("[%d/%s/%s] Logout by %s(#%d) <Inactivity Timeout>"),
- d->descriptor, d->addr, d->ip, Name(d->player), d->player);
+ d->descriptor, d->addr, d->ip, Name(d->player),
+ d->player);
boot_desc(d);
} else if (Unfind(d->player)) {
FILE *
fopen(file, mode)
- const char *file;
- const char *mode;
+const char *file;
+const char *mode;
{
/* FILE *f; */
int fd, rw, oflags = 0;
#undef fclose(x)
int
f_close(stream)
- FILE *stream;
+FILE *stream;
{
int fd = fileno(stream);
/* if extrafd is bad, and the fd we're closing is good, recycle the
DESC *d;
SU_PATH *exit_path;
long flags = RDBF_SCREENSIZE | RDBF_TTYPE | RDBF_PUEBLO_CHECKSUM
- | RDBF_SU_EXIT_PATH | RDBF_CONSOLE;
+ | RDBF_SU_EXIT_PATH | RDBF_CONSOLE;
if (setjmp(db_err)) {
flag_broadcast(0, 0, T("GAME: Error writing reboot database!"));
exit(0);
/* First, iterate through all descriptors to get to the end
* we do this so the descriptor_list isn't reversed on reboot
*/
- for (d = descriptor_list; d && d->next; d = d->next) ;
+ for (d = descriptor_list; d && d->next; d = d->next);
/* Second, we iterate backwards from the end of descriptor_list
* which is now in the d variable.
*/
putref(f, d->height);
putstring(f, d->ttype);
putstring(f, d->checksum);
- for(exit_path = d->su_exit_path; exit_path; exit_path = exit_path->next)
+ for (exit_path = d->su_exit_path; exit_path;
+ exit_path = exit_path->next)
putref(f, exit_path->player);
putref(f, NOTHING);
} /* for loop */
d->pinfo.function = NULL;
d->connected = GoodObject(d->player) ? 1 : 0;
/* setup snooper array */
- for(n = 0; n < MAX_SNOOPS; n++)
+ for (n = 0; n < MAX_SNOOPS; n++)
d->snooper[n] = -1;
temp = getstring_noalloc(f);
d->su_exit_path = NULL;
if (flags & RDBF_SU_EXIT_PATH) {
exit_path = getref(f);
- while(GoodObject(exit_path)) {
+ while (GoodObject(exit_path)) {
add_to_exit_path(d, exit_path);
exit_path = getref(f);
}
epprev = NULL;
- while(d->su_exit_path) {
+ while (d->su_exit_path) {
epnext = d->su_exit_path->next;
d->su_exit_path->next = epprev;
epprev = d->su_exit_path;
d->connected = 0;
d->player = 0;
}
- /* If they were in a program, get them back into it */
- if(d->connected && InProg(d->player))
+ /* If they were in a program, get them back into it */
+ if (d->connected && InProg(d->player))
prog_load_desc(d);
}
} /* while loop */
/* Now announce disconnects of everyone who's not really here */
while (closed) {
nextclosed = closed->next;
- if(closed->last_time > 0) {
+ if (closed->last_time > 0) {
closed->idle_total += difftime(mudtime, closed->last_time);
closed->unidle_times++;
}
- snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - closed->connected_at),
- closed->idle_total , closed->unidle_times, closed->cmds);
- tbuf1[strlen(tbuf1)+1] = '\0';
+ snprintf(tbuf1, BUFFER_LEN - 1, "%ld %ld %d %d",
+ (mudtime - closed->connected_at), closed->idle_total,
+ closed->unidle_times, closed->cmds);
+ tbuf1[strlen(tbuf1) + 1] = '\0';
(void) atr_add(closed->player, "LASTACTIVITY", tbuf1, GOD, 0);
announce_disconnect(closed->player);
mush_free(closed->ttype, "terminal description");
/* Syntax: @snoop[/list] [!]<descriptor>
- */
-COMMAND(cmd_snoop) {
+ */
+COMMAND(cmd_snoop)
+{
DESC *d;
int descn, on, n, sn;
char snooplist[MAX_SNOOPS][BUFFER_LEN];
char buf[BUFFER_LEN], *bp;
- if(SW_ISSET(sw, SWITCH_LIST)) {
- descn = atoi(arg_left);
+ if (SW_ISSET(sw, SWITCH_LIST)) {
+ descn = atoi(arg_left);
- bp = buf;
+ bp = buf;
- d = port_desc(descn);
+ d = port_desc(descn);
- if (LEVEL(player) <= 28) {
- notify(player, MSG_HUH);
- return;
- }
- /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
- if(!d || (d && !IsPlayer(d->player))) {
- notify(player, "There is no one connected on that descriptor.");
- return;
- }
+ if (LEVEL(player) <= 28) {
+ notify(player, MSG_HUH);
+ return;
+ }
+ /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
+ if (!d || (d && !IsPlayer(d->player))) {
+ notify(player, "There is no one connected on that descriptor.");
+ return;
+ }
- for(sn = 0, n = 0; n < MAX_SNOOPS; n++)
- if(d->snooper[n] != -1) {
- memset(snooplist[sn], '\0', BUFFER_LEN);
- snprintf(snooplist[sn++], BUFFER_LEN-1, "%s", Name(d->snooper[n]));
- }
- *snooplist[sn] = '\0';
-
- for(n = 0; n < sn; n++) {
- if(n != 0)
- safe_str(", ", buf, &bp);
- if(n == (sn-1) && sn > 1)
- safe_str("& ", buf, &bp);
- safe_str(snooplist[n], buf, &bp);
- }
- *bp = '\0';
- notify_format(player, "%s is being snooped on by: %s", Name(d->player), buf);
+ for (sn = 0, n = 0; n < MAX_SNOOPS; n++)
+ if (d->snooper[n] != -1) {
+ memset(snooplist[sn], '\0', BUFFER_LEN);
+ snprintf(snooplist[sn++], BUFFER_LEN - 1, "%s",
+ Name(d->snooper[n]));
+ }
+ *snooplist[sn] = '\0';
+
+ for (n = 0; n < sn; n++) {
+ if (n != 0)
+ safe_str(", ", buf, &bp);
+ if (n == (sn - 1) && sn > 1)
+ safe_str("& ", buf, &bp);
+ safe_str(snooplist[n], buf, &bp);
+ }
+ *bp = '\0';
+ notify_format(player, "%s is being snooped on by: %s", Name(d->player),
+ buf);
} else {
- if(*arg_left== '!') {
- on = 0;
- descn = atoi(arg_left+1);
- } else {
- descn = atoi(arg_left);
- on = 1;
- }
-
- d = port_desc(descn);
- if (LEVEL(player) <= 28) {
- notify(player, MSG_HUH);
- return;
- }
- /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
- if(!d || (d && !IsPlayer(d->player))) {
- notify(player, "There is no one connected on that descriptor.");
- return;
- }
-
- if(on) {
- if((d->player == player)) {
- notify(player, "You can't snoop yourself.");
- return;
- }
+ if (*arg_left == '!') {
+ on = 0;
+ descn = atoi(arg_left + 1);
+ } else {
+ descn = atoi(arg_left);
+ on = 1;
+ }
- switch(set_snoop(player,d)) {
- case -1: /* Too Many */
- notify(player, "Sorry, can't snoop at this time.");
+ d = port_desc(descn);
+ if (LEVEL(player) <= 28) {
+ notify(player, MSG_HUH);
return;
- case -2: /* Already Snoopin on 'em */
- notify(player, "You can only snoop one person at a time.");
+ }
+ /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
+ if (!d || (d && !IsPlayer(d->player))) {
+ notify(player, "There is no one connected on that descriptor.");
return;
- default:
- notify_format(player, T("Snoop now set on %s(%d)"), Name(d->player), descn);
- }
- } else {
- for(on = n = 0; n < MAX_SNOOPS; n++)
- if(d->snooper[n] == player) {
- d->snooper[n] = -1;
- on = 1;
+ }
+
+ if (on) {
+ if ((d->player == player)) {
+ notify(player, "You can't snoop yourself.");
+ return;
}
+
+ switch (set_snoop(player, d)) {
+ case -1: /* Too Many */
+ notify(player, "Sorry, can't snoop at this time.");
+ return;
+ case -2: /* Already Snoopin on 'em */
+ notify(player, "You can only snoop one person at a time.");
+ return;
+ default:
+ notify_format(player, T("Snoop now set on %s(%d)"),
+ Name(d->player), descn);
+ }
+ } else {
+ for (on = n = 0; n < MAX_SNOOPS; n++)
+ if (d->snooper[n] == player) {
+ d->snooper[n] = -1;
+ on = 1;
+ }
notify(player, on ? "Snoop deactivated." : "Snooping Error.");
- }
+ }
}
}
-void feed_snoop(DESC *d, const char *s, char dir) {
+void
+feed_snoop(DESC * d, const char *s, char dir)
+{
int n;
char snstr[BUFFER_LEN];
- if(!d || !d->connected)
+ if (!d || !d->connected)
return;
memset(snstr, '\0', BUFFER_LEN);
- strncpy(snstr, remove_markup(s, NULL), BUFFER_LEN-1);
- if(*s && !*snstr)
+ strncpy(snstr, remove_markup(s, NULL), BUFFER_LEN - 1);
+ if (*s && !*snstr)
return;
- for(n = 0; n < MAX_SNOOPS ; n++) {
- if(!GoodObject(d->snooper[n]) || !IsPlayer(d->snooper[n]))
+ for (n = 0; n < MAX_SNOOPS; n++) {
+ if (!GoodObject(d->snooper[n]) || !IsPlayer(d->snooper[n]))
continue;
- if(dir == 1) /* player sees */
+ if (dir == 1) /* player sees */
notify_format((dbref) d->snooper[n], T("%s%s<-%s %s"),
- object_header(d->snooper[n],d->player),
- ANSI_BLUE, ANSI_NORMAL, snstr);
- else /* player types */
+ object_header(d->snooper[n], d->player),
+ ANSI_BLUE, ANSI_NORMAL, snstr);
+ else /* player types */
notify_format((dbref) d->snooper[n], T("%s%s->%s %s%s"),
- object_header(d->snooper[n],d->player),
- ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL);
+ object_header(d->snooper[n], d->player),
+ ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL);
}
}
-char is_snooped(DESC *d) {
+char
+is_snooped(DESC * d)
+{
int n;
- for(n = 0; n < MAX_SNOOPS; n++)
- if(IsPlayer(d->snooper[n]))
+ for (n = 0; n < MAX_SNOOPS; n++)
+ if (IsPlayer(d->snooper[n]))
return 1;
return 0;
}
-char set_snoop(dbref plyr, DESC *d) {
+char
+set_snoop(dbref plyr, DESC * d)
+{
int n;
/* take first available spot */
- for( n = 0; n < MAX_SNOOPS ; n++)
- if(d->snooper[n] == -1)
+ for (n = 0; n < MAX_SNOOPS; n++)
+ if (d->snooper[n] == -1)
break;
- else if(d->snooper[n] == plyr)
- return -2; /* they're already snooping */
- if(n == MAX_SNOOPS-1) /* too many snoopers on player */
+ else if (d->snooper[n] == plyr)
+ return -2; /* they're already snooping */
+ if (n == MAX_SNOOPS - 1) /* too many snoopers on player */
return -1;
d->snooper[n] = plyr;
return 1;
}
-void clr_snoop(dbref plyr, DESC *d) {
+void
+clr_snoop(dbref plyr, DESC * d)
+{
int n;
- for(n = 0; n < MAX_SNOOPS; n++)
- if(d->snooper[n] == plyr)
+ for (n = 0; n < MAX_SNOOPS; n++)
+ if (d->snooper[n] == plyr)
d->snooper[n] = -1;
}
/* switch users */
-COMMAND(cmd_su) {
+COMMAND(cmd_su)
+{
DESC *d, *match = NULL;
dbref target;
int num = 0, is_hidden;
/* Stage 1. Make sure arg_left exists */
- if(arg_left && *arg_left) {
- if(!strcasecmp(cmd->name, "@SD")) {
- target = match_result(player, arg_left, TYPE_DIVISION, MAT_EVERYTHING);
- if(!GoodObject(target) || Typeof(target) != TYPE_DIVISION) {
+ if (arg_left && *arg_left) {
+ if (!strcasecmp(cmd->name, "@SD")) {
+ target =
+ match_result(player, arg_left, TYPE_DIVISION, MAT_EVERYTHING);
+ if (!GoodObject(target) || Typeof(target) != TYPE_DIVISION) {
notify(player, "No such division.");
return;
}
/* Check to see if special conditions exist, where they can enter without a password */
- if(controls(player, target)) { /* condition 1: they control it */
+ if (controls(player, target)) { /* condition 1: they control it */
/* trigger did_it on exiting division.. Possibly save their exiting values, for if they come back in? */
- did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
+ did_it(player, Division(player), "SDOUT", NULL, NULL, NULL,
+ "ASDOUT", Location(player));
add_to_div_exit_path(player, Division(player));
Division(player) = target;
/* triger did_it on incoming division.. to i guess set 'em for something.. *shrugs* */
- did_it(player, Division(player), "SDIN", tprintf("You have switched into Division: %s", object_header(player, Division(player)))
- , NULL, NULL, "ASDIN", Location(player));
+ did_it(player, Division(player), "SDIN",
+ tprintf("You have switched into Division: %s",
+ object_header(player, Division(player)))
+ , NULL, NULL, "ASDIN", Location(player));
return;
}
/* get least idle desc */
- DESC_ITER_CONN(d)
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
- match = d;
+ DESC_ITER_CONN(d)
+ if ((d->player == player)
+ && (!match || (d->last_time > match->last_time)))
+ match = d;
/* We're only entering using a password at this moment */
- queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
- IAC, GOAHEAD), 13);
- if(!PromptConnection(match))
- queue_newwrite(match, (unsigned char *) "\r\n", 3);
-
- match->input_handler = password_handler;
- match->pinfo.object = target;
- match->pinfo.function = &pw_div_connect;
- match->pinfo.lock = 0x40;
+ queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
+ IAC, GOAHEAD), 13);
+ if (!PromptConnection(match))
+ queue_newwrite(match, (unsigned char *) "\r\n", 3);
+
+ match->input_handler = password_handler;
+ match->pinfo.object = target;
+ match->pinfo.function = &pw_div_connect;
+ match->pinfo.lock = 0x40;
} else {
target = lookup_player(arg_left);
- if(target == NOTHING) {
+ if (target == NOTHING) {
notify(player, "No such player.");
return;
}
do_log(LT_WIZ, player, target, "** @SU ATTEMPT **");
/* get least idle desc */
- DESC_ITER_CONN(d)
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
- match = d;
- /* Step 2. Find if we can get in without a pass, if
- * we need a pass. Throw them into password_handler() internal
- * prompt
- */
- if(div_powover(player, target, "@SU")) {
+ DESC_ITER_CONN(d)
+ if ((d->player == player)
+ && (!match || (d->last_time > match->last_time)))
+ match = d;
+ /* Step 2. Find if we can get in without a pass, if
+ * we need a pass. Throw them into password_handler() internal
+ * prompt
+ */
+ if (div_powover(player, target, "@SU")) {
do_log(LT_WIZ, player, target, "** @SU SUCCESS **");
/* Phase 3a. Put Guy in user */
add_to_exit_path(match, player);
match->player = target;
is_hidden = Can_Hide(target) && Dark(target);
DESC_ITER_CONN(d)
- if(d->player == player) {
- num++;
- if(is_hidden)
- d->hide = 1;
- }
+ if (d->player == player) {
+ num++;
+ if (is_hidden)
+ d->hide = 1;
+ }
- if(ModTime(target))
- notify_format(target, T("%ld failed connections since last login."), ModTime(target));
+ if (ModTime(target))
+ notify_format(target,
+ T("%ld failed connections since last login."),
+ ModTime(target));
announce_connect(target, 0, num);
- check_last(target, match->addr, match->ip); /* set last, lastsite, give paycheck */
+ check_last(target, match->addr, match->ip); /* set last, lastsite, give paycheck */
queue_eol(match);
#ifdef USE_MAILER
- if(command_check_byname(target, "@MAIL"))
+ if (command_check_byname(target, "@MAIL"))
check_mail(target, 0, 0);
set_player_folder(target, 0);
#endif
do_look_around(target);
- if(Haven(target))
- notify(player, T("Your HAVEN flag is set. You cannot receive pages."));
+ if (Haven(target))
+ notify(player,
+ T("Your HAVEN flag is set. You cannot receive pages."));
} else {
/* Part 3b. Put guy in password program */
- queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
- IAC, GOAHEAD), 13);
- if(!PromptConnection(match))
+ queue_newwrite(match,
+ (unsigned char *) tprintf(T("Password: %c%c"), IAC,
+ GOAHEAD), 13);
+ if (!PromptConnection(match))
queue_newwrite(match, (unsigned char *) "\r\n", 3);
match->input_handler = password_handler;
}
}
} else {
- if(SW_ISSET(sw, SWITCH_LOGOUT)) {
+ if (SW_ISSET(sw, SWITCH_LOGOUT)) {
/* @sd/logout - check to see if there is any division @sd'ing history.. And backtrack us */
ATTR *divrcd;
char tbuf[BUFFER_LEN], *p_buf[BUFFER_LEN / 2], *tbp, sep[2];
dbref div_obj;
divrcd = atr_get(player, "XYXX_DIVRCD");
- if(divrcd == NULL) {
+ if (divrcd == NULL) {
notify(player, "You have not switched into any divisions.");
return;
}
cnt = list2arr(p_buf, BUFFER_LEN / 2, safe_atr_value(divrcd), ' ');
- if(cnt < 1) {
+ if (cnt < 1) {
notify(player, "You have not switched into any divisions.");
return;
}
/* Set them into cnt-1 if its good */
- div_obj = parse_number(p_buf[cnt-1]);
- if(GoodObject(div_obj) && IsDivision(div_obj)) {
+ div_obj = parse_number(p_buf[cnt - 1]);
+ if (GoodObject(div_obj) && IsDivision(div_obj)) {
/* Trigger ASDOUT */
- did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
+ did_it(player, Division(player), "SDOUT", NULL, NULL, NULL,
+ "ASDOUT", Location(player));
Division(player) = div_obj;
/* Trigger SDIN */
- did_it(player, Division(player), "SDIN", tprintf("You have went back to your other division: %s", object_header(player, div_obj))
- , NULL, NULL, "ASDIN", Location(player));
+ did_it(player, Division(player), "SDIN",
+ tprintf("You have went back to your other division: %s",
+ object_header(player, div_obj))
+ , NULL, NULL, "ASDIN", Location(player));
}
/* now chop off last one, and arr2list() */
- if(cnt == 1) { /* clear the attribute */
+ if (cnt == 1) { /* clear the attribute */
atr_clr(player, "XYXX_DIVRCD", GOD);
} else {
memset(tbuf, '\0', BUFFER_LEN);
tbp = tbuf;
sep[0] = ' ';
sep[1] = '\0';
- arr2list(p_buf, cnt-1, tbuf, &tbp, sep);
+ arr2list(p_buf, cnt - 1, tbuf, &tbp, sep);
/* Add the attribute back */
- (void) atr_add(player, "XYXX_DIVRCD", tbuf, GOD, 0);
+ (void) atr_add(player, "XYXX_DIVRCD", tbuf, GOD, 0);
}
} else {
notify(player, "Must specify what player you wish to @su into.");
}
}
-void add_to_exit_path(DESC *d, dbref player) {
+void
+add_to_exit_path(DESC * d, dbref player)
+{
SU_PATH *path_entry;
- if(!d)
+ if (!d)
return;
path_entry = (SU_PATH *) mush_malloc(sizeof(SU_PATH), "SU_PATH_ENTRY");
path_entry->player = player;
- if(d->su_exit_path)
+ if (d->su_exit_path)
path_entry->next = d->su_exit_path;
else
path_entry->next = NULL;
}
/* If they're logged in.. Log 'em out through their su path */
-static int do_su_exit(DESC *d) {
+static int
+do_su_exit(DESC * d)
+{
DESC *c;
SU_PATH *path_entry, *mark_path;
int is_hidden, num = 0;
- if(d->su_exit_path) {
+ if (d->su_exit_path) {
path_entry = d->su_exit_path;
- while(path_entry)
- if(GoodObject(path_entry->player) && IsPlayer(path_entry->player))
+ while (path_entry)
+ if (GoodObject(path_entry->player) && IsPlayer(path_entry->player))
break;
- else { /* Guess the guy got nuked along the way.. free the spot */
+ else { /* Guess the guy got nuked along the way.. free the spot */
mark_path = path_entry;
path_entry = path_entry->next;
mush_free(mark_path, "SU_PATH_ENTRY");
}
d->su_exit_path = path_entry;
- if(!path_entry)
+ if (!path_entry)
return 0;
/* Disconnect appearance */
announce_disconnect(d->player);
mush_free(path_entry, "SU_PATH_ENTRY");
is_hidden = Can_Hide(d->player) && Dark(d->player);
DESC_ITER_CONN(c)
- if(c->player == d->player) {
- num++;
- if(is_hidden)
- c->hide = 1;
- }
- if(ModTime(d->player))
- notify_format(d->player, T("%ld failed connections since last login."), ModTime(d->player));
+ if (c->player == d->player) {
+ num++;
+ if (is_hidden)
+ c->hide = 1;
+ }
+ if (ModTime(d->player))
+ notify_format(d->player,
+ T("%ld failed connections since last login."),
+ ModTime(d->player));
announce_connect(d->player, 0, num);
- check_last(d->player, d->addr, d->ip); /* set last, lastsite, give paycheck */
+ check_last(d->player, d->addr, d->ip); /* set last, lastsite, give paycheck */
queue_eol(d);
#ifdef USE_MAILER
- if(command_check_byname(d->player, "@MAIL"))
+ if (command_check_byname(d->player, "@MAIL"))
check_mail(d->player, 0, 0);
set_player_folder(d->player, 0);
#endif
do_look_around(d->player);
- if(Haven(d->player))
- notify(d->player, T("Your HAVEN flag is set. You cannot receive pages."));
+ if (Haven(d->player))
+ notify(d->player,
+ T("Your HAVEN flag is set. You cannot receive pages."));
return 1;
- } else return 0;
+ } else
+ return 0;
}
/* this should be in wiz.c but console.c likes it here better */
do_reboot(dbref player, int flag)
{
struct module_entry_t *m;
- void (*handle)();
+ void (*handle) ();
#ifndef WIN32
/* Quick and dirty check to make sure the executable is still
WATCH(options.guest_file[n]);
}
- for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files))
+ for (h = hash_firstentry(&help_files); h;
+ h = hash_nextentry(&help_files))
WATCH(h->file);
#undef WATCH
}
if (FAMOpen(&famc) < 0) {
- do_rawlog(LT_TRACE, "file_watch_init: FAMOpen: %s", FamErrlist[FAMErrno]);
+ do_rawlog(LT_TRACE, "file_watch_init: FAMOpen: %s",
+ FamErrlist[FAMErrno]);
return -1;
}
#define WATCH(name) do { \
WATCH(options.guest_file[n]);
}
- for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files))
+ for (h = hash_firstentry(&help_files); h;
+ h = hash_nextentry(&help_files))
WATCH(h->file);
#undef WATCH