From 7cc261bccdd743308e62ea9862512ca22ff65e11 Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Thu, 5 May 2011 19:28:09 -0400 Subject: [PATCH] To start off.. besides changes this is also an indent run on bsd.c (my bad.. didn't separate it before the add --patch) PennMUSH 1.8.3p11 Author: talvo@talvo.com Date: Sat Nov 14 17:50:02 2009 +0000 Fix bug in the softcode fcache code, and make it a little smarter when looking for a dbref. Author: talvo@talvo.com Date: Fri Nov 13 17:59:46 2009 +0000 Fix typo. Must pay more attention when copy-and-pasting. Author: talvo@talvo.com Date: Fri Nov 13 17:37:07 2009 +0000 Fix bug found by Merc in softcoded fcache. Author: talvo@talvo.com Date: Thu Nov 12 05:02:51 2009 +0000 Issue 31, the *_file options (connect_file, motd_file, etc) can now be an obj/attr, to show the evaluated result, instead of a text file. Fixes #165 --- src/bsd.c | 1391 ++++++++++++++++++++++++++++++---------------------- src/conf.c | 2 +- 2 files changed, 815 insertions(+), 578 deletions(-) diff --git a/src/bsd.c b/src/bsd.c index 09bb78a..edfb67f 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -89,7 +89,7 @@ #ifdef HAVE_SYS_INOTIFY_H #include -#endif +#endif #ifdef HAVE_FAM_H #include @@ -98,7 +98,7 @@ #include #endif - + #include "conf.h" #include "externs.h" @@ -125,7 +125,7 @@ #include "lookup.h" #endif #endif - + #include "strtree.h" #include "log.h" #include "mypcre.h" @@ -171,7 +171,7 @@ static int extrafd; 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; @@ -185,7 +185,7 @@ char errlog[BUFFER_LEN] = { '\0' }; /**< Name of the error log file */ /* Default Connection flags for certain clients */ -static CLIENT_DEFAULTS client_maps[] = { +static CLIENT_DEFAULTS client_maps[] = { {"TINYFUGUE", CONN_PROMPT}, {NULL, -1} }; @@ -230,23 +230,23 @@ static CLIENT_DEFAULTS client_maps[] = { #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" @@ -258,13 +258,16 @@ static void 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."); } @@ -305,7 +308,8 @@ int main(int argc, char **argv); #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)) @@ -323,12 +327,13 @@ static void shovechars(Port_t port, Port_t sslport); 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. */ @@ -343,40 +348,45 @@ struct fcache_entries { 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); @@ -394,7 +404,7 @@ sig_atomic_t slave_error = 0; #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); @@ -403,12 +413,12 @@ void reopen_logs(void); 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) @@ -465,7 +475,7 @@ main(int argc, char **argv) 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. @@ -475,14 +485,16 @@ main(int argc, char **argv) #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()); @@ -491,13 +503,13 @@ main(int argc, char **argv) } #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; @@ -508,29 +520,31 @@ main(int argc, char **argv) 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]; @@ -543,7 +557,7 @@ main(int argc, char **argv) break; } } - } + } #ifdef HAVE_FORK /* Fork off and detach from controlling terminal. */ @@ -579,7 +593,7 @@ main(int argc, char **argv) #endif saved_argv = argv; - + #ifdef WIN32 { @@ -729,7 +743,7 @@ main(int argc, char **argv) close_sockets(); sql_shutdown(); - mush_lua_stop(); /* shutdown the lua environment */ + mush_lua_stop(); /* shutdown the lua environment */ #ifdef INFO_SLAVE kill_info_slave(); @@ -741,7 +755,7 @@ main(int argc, char **argv) #endif dump_database(); - + /* Replacement for local_shutdown */ MODULE_ITER(m) { MODULE_FUNC_NOARGS(handle, m->handle, "module_shutdown"); @@ -903,7 +917,8 @@ msec_diff(struct timeval *now, struct timeval *then) 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; } @@ -952,43 +967,45 @@ update_quotas(struct timeval *last, struct timeval *current) } } -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; } @@ -1012,7 +1029,7 @@ setup_desc(int sock, bool use_ssl) static void shovechars(Port_t port __attribute__ ((__unused__)), - Port_t sslport __attribute__ ((__unused__))) + Port_t sslport __attribute__ ((__unused__))) { /* this is the main game loop */ @@ -1040,7 +1057,8 @@ shovechars(Port_t port __attribute__ ((__unused__)), 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 @@ -1052,7 +1070,8 @@ shovechars(Port_t port __attribute__ ((__unused__)), 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; @@ -1106,7 +1125,8 @@ shovechars(Port_t port __attribute__ ((__unused__)), 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!")); @@ -1335,7 +1355,8 @@ new_connection(int oldsock, int *result, bool use_ssl) 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); @@ -1359,13 +1380,14 @@ new_connection(int oldsock, int *result, bool use_ssl) #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"); @@ -1377,34 +1399,107 @@ clearstrings(DESC *d) } } +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; @@ -1415,6 +1510,27 @@ fcache_read(FBLOCK *fb, const char *filename) 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 */ @@ -1460,13 +1576,15 @@ fcache_read(FBLOCK *fb, const char *filename) 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; @@ -1474,7 +1592,8 @@ fcache_read(FBLOCK *fb, const char *filename) 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(); @@ -1493,6 +1612,7 @@ fcache_read(FBLOCK *fb, const char *filename) close(fd); reserve_fd(); fb->len = sb.st_size; + } #endif /* Posix read code */ @@ -1513,7 +1633,8 @@ fcache_load(dbref player) 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]); @@ -1539,7 +1660,7 @@ fcache_init(void) } static void -logout_sock(DESC *d) +logout_sock(DESC * d) { SU_PATH *path_entry; @@ -1548,15 +1669,17 @@ logout_sock(DESC *d) if (d->connected) { fcache_dump(d, fcache.quit_fcache, NULL); - do_rawlog(LT_CONN, T("[%d/%s/%s] Logout by %s(#%d) "), - 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) "), + 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 @@ -1566,13 +1689,16 @@ logout_sock(DESC *d) 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. "), - d->descriptor, d->addr, d->ip); + do_rawlog(LT_CONN, + T + ("[%d/%s/%s] Logout, never connected. "), + d->descriptor, d->addr, d->ip); } process_output(d); /* flush our old output */ /* pretend we have a new connection */ @@ -1600,13 +1726,13 @@ logout_sock(DESC *d) 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; } @@ -1616,7 +1742,7 @@ logout_sock(DESC *d) * \param d pointer to descriptor to disconnect. */ static void -shutdownsock(DESC *d) +shutdownsock(DESC * d) { char tbuf1[BUFFER_LEN]; @@ -1626,13 +1752,14 @@ shutdownsock(DESC *d) 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 @@ -1686,7 +1813,7 @@ shutdownsock(DESC *d) /* ARGSUSED */ DESC * initializesock(int s, int os, char *addr, char *ip, int use_ssl - __attribute__ ((__unused__))) + __attribute__ ((__unused__))) { DESC *d; dbref console_player; @@ -1758,9 +1885,9 @@ initializesock(int s, int os, char *addr, char *ip, int use_ssl } #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'; @@ -1768,15 +1895,15 @@ initializesock(int s, int os, char *addr, char *ip, int use_ssl 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; } @@ -1789,7 +1916,7 @@ initializesock(int s, int os, char *addr, char *ip, int use_ssl * \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; @@ -1863,7 +1990,7 @@ process_output(DESC *d) #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 @@ -1911,7 +2038,8 @@ process_output(DESC *d) *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 { @@ -1931,8 +2059,8 @@ process_output(DESC *d) 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 @@ -1947,7 +2075,8 @@ process_output(DESC *d) 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 @@ -1981,23 +2110,24 @@ process_output(DESC *d) 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. */ @@ -2011,7 +2141,7 @@ test_telnet(DESC *d) } 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 @@ -2029,13 +2159,13 @@ setup_telnet(DESC *d) } 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)++; @@ -2140,8 +2270,8 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) 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; } @@ -2150,7 +2280,7 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) (*q)++; } break; - case NOP: /* No-op */ + case NOP: /* No-op */ if (*q >= qend) return -1; #ifdef DEBUG_TELNET @@ -2158,17 +2288,17 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) #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; @@ -2197,7 +2327,7 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) 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; @@ -2221,8 +2351,8 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) 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", @@ -2232,14 +2362,14 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) 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; @@ -2295,7 +2425,7 @@ process_input_helper(DESC *d, char *tbuf1, int got) /* 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]; @@ -2334,8 +2464,8 @@ process_input(DESC *d, int output_ready __attribute__ ((__unused__))) } /* 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); @@ -2403,17 +2533,21 @@ process_commands(void) 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) { @@ -2451,7 +2585,7 @@ process_commands(void) } int -do_command(DESC *d, char *command) +do_command(DESC * d, char *command) { int j; @@ -2462,7 +2596,7 @@ do_command(DESC *d, char *command) (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++; } @@ -2496,7 +2630,8 @@ do_command(DESC *d, char *command) } 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, @@ -2537,7 +2672,7 @@ do_command(DESC *d, char *command) } static void -parse_puebloclient(DESC *d, char *command) +parse_puebloclient(DESC * d, char *command) { const char *p, *end; if ((p = string_match(command, "md5="))) { @@ -2553,10 +2688,10 @@ parse_puebloclient(DESC *d, char *command) } 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; @@ -2617,7 +2752,7 @@ dump_messages(DESC *d, dbref player, int isnew) 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 */ @@ -2640,7 +2775,7 @@ dump_messages(DESC *d, dbref player, int isnew) } 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]; @@ -2652,19 +2787,20 @@ check_connect(DESC *d, const char *msg) 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) { @@ -2675,7 +2811,8 @@ check_connect(DESC *d, const char *msg) } 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); @@ -2696,7 +2833,8 @@ check_connect(DESC *d, const char *msg) } 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); @@ -2716,7 +2854,8 @@ check_connect(DESC *d, const char *msg) } 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); @@ -2788,7 +2927,8 @@ check_connect(DESC *d, const char *msg) 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; @@ -2808,7 +2948,8 @@ check_connect(DESC *d, const char *msg) } 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 */ @@ -2817,7 +2958,7 @@ check_connect(DESC *d, const char *msg) 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); } @@ -2842,7 +2983,7 @@ parse_connect(const char *msg1, char *command, char *user, char *pass) 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++; @@ -2910,13 +3051,15 @@ close_sockets(void) 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; @@ -2943,7 +3086,7 @@ emergency_shutdown(void) * \param d pointer to descriptor to disconnect. */ void -boot_desc(DESC *d) +boot_desc(DESC * d) { shutdownsock(d); } @@ -2970,7 +3113,8 @@ player_desc(dbref player) * \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; @@ -2984,7 +3128,8 @@ do_page_port(dbref player, dbref cause, const char *pc, const char *message, boo 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; @@ -3000,13 +3145,14 @@ do_page_port(dbref player, dbref cause, const char *pc, const char *message, boo } 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; } @@ -3035,7 +3181,8 @@ do_page_port(dbref player, dbref cause, const char *pc, const char *message, boo 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); @@ -3156,7 +3303,7 @@ reaper(int sig __attribute__ ((__unused__))) 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); @@ -3173,11 +3320,11 @@ reaper(int sig __attribute__ ((__unused__))) } 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; @@ -3188,28 +3335,29 @@ dump_info(DESC *call_by) 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; @@ -3218,7 +3366,8 @@ dump_users(DESC *call_by, char *match, int doing) 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 == ' ') @@ -3230,7 +3379,8 @@ dump_users(DESC *call_by, char *match, int doing) */ if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) { - queue_newwrite(call_by, (const unsigned char *) "", 19); + queue_newwrite(call_by, (const unsigned char *) "", + 19); queue_newwrite(call_by, (const unsigned char *) "
", 5);
   }
 
@@ -3238,20 +3388,26 @@ dump_users(DESC *call_by, char *match, int doing)
     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);
   }
 
@@ -3259,11 +3415,12 @@ dump_users(DESC *call_by, char *match, int doing)
     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)))
@@ -3275,9 +3432,13 @@ dump_users(DESC *call_by, char *match, int doing)
         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
@@ -3297,9 +3458,12 @@ dump_users(DESC *call_by, char *match, int doing)
       } 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
@@ -3307,31 +3471,34 @@ dump_users(DESC *call_by, char *match, int doing)
 #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
@@ -3341,38 +3508,41 @@ dump_users(DESC *call_by, char *match, int doing)
 #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);
     }
   }
@@ -3384,20 +3554,25 @@ dump_users(DESC *call_by, char *match, int doing)
     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
\n", 8); - queue_newwrite(call_by, (const unsigned char *) "", 23); + queue_newwrite(call_by, + (const unsigned char *) "", 23); } else queue_newwrite(call_by, (const unsigned char *) "\r\n", 2); } @@ -3467,10 +3642,11 @@ announce_connect(dbref player, int isnew, int num) /* 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."); } @@ -3483,7 +3659,7 @@ announce_connect(dbref player, int isnew, int num) #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)) { @@ -3497,12 +3673,12 @@ announce_connect(dbref player, int isnew, int num) } 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++) @@ -3570,11 +3746,11 @@ announce_disconnect(dbref player) 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); @@ -3627,8 +3803,9 @@ announce_disconnect(dbref player) } 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 */ @@ -3652,7 +3829,7 @@ announce_disconnect(dbref player) #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 */ @@ -3668,10 +3845,10 @@ announce_disconnect(dbref player) } 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); @@ -3693,7 +3870,7 @@ do_motd(dbref player, enum motd_type key, const char *message) { 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.")); @@ -3873,7 +4050,8 @@ visible_short_page(dbref player, const char *match) /* LWHO() function - really belongs elsewhere but needs stuff declared here */ /* ARGSUSED */ -FUNCTION(fun_nwho) { +FUNCTION(fun_nwho) +{ DESC *d; dbref victim; int count = 0; @@ -3899,7 +4077,7 @@ FUNCTION(fun_nwho) { if (!Hidden(d) || powered) { count++; } - } + } safe_integer(count, buff, bp); } @@ -3916,47 +4094,50 @@ FUNCTION(fun_lwho) 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) @@ -3964,7 +4145,7 @@ FUNCTION(fun_lwho) 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); } @@ -3980,19 +4161,20 @@ FUNCTION(fun_hidden) { 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 @@ -4015,12 +4197,12 @@ lookup_desc(dbref executor, const char *name) 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) { @@ -4034,7 +4216,7 @@ lookup_desc(dbref executor, const char *name) 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; } @@ -4117,7 +4299,8 @@ least_idle_time_priv(dbref player) { 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) { @@ -4138,7 +4321,8 @@ least_idle_ip(dbref player) { 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; @@ -4158,7 +4342,8 @@ least_idle_hostname(dbref player) 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) @@ -4196,12 +4381,16 @@ FUNCTION(fun_zwho) 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; } @@ -4212,18 +4401,18 @@ FUNCTION(fun_zwho) 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); + } + } } } @@ -4412,42 +4601,48 @@ FUNCTION(fun_idlesecs) } /* 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); } @@ -4474,7 +4669,7 @@ FUNCTION(fun_lports) 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; } @@ -4505,7 +4700,7 @@ FUNCTION(fun_ports) 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; @@ -4578,7 +4773,8 @@ inactivity_check(void) 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 */ @@ -4589,17 +4785,18 @@ inactivity_check(void) 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); @@ -4608,7 +4805,8 @@ after_idle_atr_check: queue_string(d, T("\n*** Inactivity timeout ***\n")); do_rawlog(LT_CONN, T("[%d/%s/%s] Logout by %s(#%d) "), - 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)) { @@ -4661,8 +4859,8 @@ hidden(dbref player) FILE * fopen(file, mode) - const char *file; - const char *mode; +const char *file; +const char *mode; { /* FILE *f; */ int fd, rw, oflags = 0; @@ -4707,7 +4905,7 @@ fopen(file, mode) #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 @@ -4832,7 +5030,7 @@ dump_reboot_db(void) 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); @@ -4853,7 +5051,7 @@ dump_reboot_db(void) /* 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. */ @@ -4886,7 +5084,8 @@ dump_reboot_db(void) 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 */ @@ -4963,7 +5162,7 @@ load_reboot_db(void) 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); @@ -4996,12 +5195,12 @@ load_reboot_db(void) 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; @@ -5048,8 +5247,8 @@ load_reboot_db(void) 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 */ @@ -5057,14 +5256,15 @@ load_reboot_db(void) /* 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"); @@ -5091,206 +5291,225 @@ load_reboot_db(void) /* Syntax: @snoop[/list] [!] - */ -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); @@ -5298,30 +5517,34 @@ COMMAND(cmd_su) { 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; @@ -5331,7 +5554,7 @@ COMMAND(cmd_su) { } } } 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]; @@ -5339,39 +5562,42 @@ COMMAND(cmd_su) { 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."); @@ -5379,16 +5605,18 @@ COMMAND(cmd_su) { } } -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; @@ -5396,23 +5624,25 @@ void add_to_exit_path(DESC *d, dbref player) { } /* 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); @@ -5422,26 +5652,30 @@ static int do_su_exit(DESC *d) { 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 */ @@ -5459,7 +5693,7 @@ void 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 @@ -5591,7 +5825,8 @@ watch_files_in(int fd) 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 @@ -5653,7 +5888,8 @@ file_watch_init_fam(void) } 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 { \ @@ -5677,7 +5913,8 @@ file_watch_init_fam(void) 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 diff --git a/src/conf.c b/src/conf.c index 8d1051c..41ddbce 100644 --- a/src/conf.c +++ b/src/conf.c @@ -121,7 +121,7 @@ COBRA_CONF conftable[] = { "messages"} , {"motd_html_file", cf_str, options.motd_file[1], - sizeof options.connect_file[1], 0, + sizeof options.motd_file[1], 0, "messages"} , {"newuser_html_file", cf_str, options.newuser_file[1], -- 2.30.2