mux/src/interface.h File Reference

#include "copyright.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>

Include dependency graph for interface.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cmd_block_hdr
struct  cmd_block
struct  text_block_hdr
struct  text_block
struct  prog_data
struct  descriptor_data

Defines

#define R_QUIT   1
#define R_TIMEOUT   2
#define R_BOOT   3
#define R_SOCKDIED   4
#define R_GOING_DOWN   5
#define R_BADLOGIN   6
#define R_GAMEDOWN   7
#define R_LOGOUT   8
#define R_GAMEFULL   9
#define CMD_QUIT   1
#define CMD_WHO   2
#define CMD_DOING   3
#define CMD_PREFIX   5
#define CMD_SUFFIX   6
#define CMD_LOGOUT   7
#define CMD_SESSION   8
#define CMD_PUEBLOCLIENT   9
#define CMD_INFO   10
#define CMD_MASK   0xff
#define CMD_NOxFIX   0x100
#define NVT_IS_NORMAL   0
#define NVT_IS_HAVE_IAC   1
#define NVT_IS_HAVE_IAC_WILL   2
#define NVT_IS_HAVE_IAC_WONT   3
#define NVT_IS_HAVE_IAC_DO   4
#define NVT_IS_HAVE_IAC_DONT   5
#define NVT_IS_HAVE_IAC_SB   6
#define NVT_IS_HAVE_IAC_SB_IAC   7
#define NVT_BS   '\x08'
#define NVT_DEL   '\x7F'
#define NVT_EOR   '\xEF'
#define NVT_NOP   '\xF1'
#define NVT_GA   '\xF9'
#define NVT_WILL   '\xFB'
#define NVT_WONT   '\xFC'
#define NVT_DO   '\xFD'
#define NVT_DONT   '\xFE'
#define NVT_IAC   '\xFF'
#define TELNET_SGA   '\x03'
#define TELNET_EOR   '\x19'
#define TELNET_NAWS   '\x1F'
#define OPTION_NO   0
#define OPTION_YES   1
#define OPTION_WANTNO_EMPTY   2
#define OPTION_WANTNO_OPPOSITE   3
#define OPTION_WANTYES_EMPTY   4
#define OPTION_WANTYES_OPPOSITE   5
#define DS_CONNECTED   0x0001
#define DS_AUTODARK   0x0002
#define DS_PUEBLOCLIENT   0x0004
#define alloc_desc(s)   (DESC *)pool_alloc(POOL_DESC,s, __FILE__, __LINE__)
#define free_desc(b)   pool_free(POOL_DESC,(char *)(b), __FILE__, __LINE__)
#define DESC_ITER_PLAYER(p, d)   for (d=(DESC *)hashfindLEN(&(p), sizeof(p), &mudstate.desc_htab); d; d = d->hashnext)
#define DESC_ITER_CONN(d)
#define DESC_ITER_ALL(d)   for (d=descriptor_list;(d);d=(d)->next)
#define DESC_SAFEITER_PLAYER(p, d, n)
#define DESC_SAFEITER_ALL(d, n)

Typedefs

typedef cmd_block CBLK
typedef cmd_block_hdr CBLKHDR
typedef cmd_block CBLK
typedef text_block TBLOCK
typedef text_block_hdr TBLOCKHDR
typedef text_block TBLOCK
typedef prog_data PROG
typedef descriptor_data DESC

Functions

int HimState (DESC *d, unsigned char chOption)
 Return the other side's negotiation state.
int UsState (DESC *d, unsigned char chOption)
 Return our side's negotiation state.
void EnableHim (DESC *d, unsigned char chOption)
 Start the process of negotiating the enablement of an option on his side.
void DisableHim (DESC *d, unsigned char chOption)
 Start the process of negotiating the disablement of an option on his side.
void EnableUs (DESC *d, unsigned char chOption)
 Start the process of negotiating the enablement of an option on our side.
void DisableUs (DESC *d, unsigned char chOption)
 Start the process of negotiating the disablement of an option on our side.
void emergency_shutdown (void)
void shutdownsock (DESC *, int)
void SetupPorts (int *pnPorts, PortInfo aPorts[], IntArray *pia)
void shovechars (int nPorts, PortInfo aPorts[])
void process_output (void *, int)
void dump_restart_db (void)
void BuildSignalNamesTable (void)
void set_signals (void)
void make_ulist (dbref, char *, char **, bool)
void make_port_ulist (dbref, char *, char **)
int fetch_session (dbref target)
int fetch_idle (dbref target)
int fetch_connect (dbref target)
int fetch_height (dbref target)
int fetch_width (dbref target)
const char * time_format_1 (int Seconds, size_t maxWidth)
const char * time_format_2 (int Seconds)
void update_quotas (CLinearTimeAbsolute &tLast, const CLinearTimeAbsolute &tCurrent)
void raw_notify (dbref, const char *)
void raw_notify_newline (dbref)
void clearstrings (DESC *)
void queue_write_LEN (DESC *, const char *, int)
void queue_write (DESC *, const char *)
void queue_string (DESC *, const char *)
void freeqs (DESC *)
void welcome_user (DESC *)
void save_command (DESC *, CBLK *)
void announce_disconnect (dbref, DESC *, const char *)
int boot_by_port (SOCKET port, bool bGod, const char *message)
void find_oldest (dbref target, DESC *dOldest[2])
void check_idle (void)
void Task_ProcessCommand (void *arg_voidptr, int arg_iInteger)
int site_check (struct in_addr, SITE *)
dbref find_connected_name (dbref, char *)
void do_command (DESC *, char *)
void desc_addhash (DESC *)
void handle_prog (DESC *d, char *message)
void record_login (dbref, bool, char *, char *, char *, char *)
dbref connect_player (char *, char *, char *, char *, char *)

Variables

NAMETAB logout_cmdtable []
DESCdescriptor_list


Define Documentation

#define alloc_desc (  )     (DESC *)pool_alloc(POOL_DESC,s, __FILE__, __LINE__)

Definition at line 258 of file interface.h.

Referenced by initializesock(), and load_restart_db().

#define CMD_DOING   3

Definition at line 40 of file interface.h.

Referenced by do_logged_out_internal().

#define CMD_INFO   10

Definition at line 46 of file interface.h.

Referenced by do_logged_out_internal().

#define CMD_LOGOUT   7

Definition at line 43 of file interface.h.

#define CMD_MASK   0xff

Definition at line 48 of file interface.h.

Referenced by do_command().

#define CMD_NOxFIX   0x100

Definition at line 49 of file interface.h.

Referenced by do_command().

#define CMD_PREFIX   5

Definition at line 41 of file interface.h.

Referenced by do_logged_out_internal().

#define CMD_PUEBLOCLIENT   9

Definition at line 45 of file interface.h.

#define CMD_QUIT   1

Definition at line 38 of file interface.h.

Referenced by do_command(), and do_logged_out_internal().

#define CMD_SESSION   8

Definition at line 44 of file interface.h.

Referenced by dump_users().

#define CMD_SUFFIX   6

Definition at line 42 of file interface.h.

Referenced by do_logged_out_internal().

#define CMD_WHO   2

Definition at line 39 of file interface.h.

Referenced by do_logged_out_internal(), and dump_users().

#define DESC_ITER_ALL (  )     for (d=descriptor_list;(d);d=(d)->next)

Definition at line 272 of file interface.h.

Referenced by dump_restart_db(), dump_users(), shovechars(), and update_quotas().

#define DESC_ITER_CONN (  ) 

Value:

for (d=descriptor_list;(d);d=(d)->next) \
        if ((d)->flags & DS_CONNECTED)

Definition at line 269 of file interface.h.

Referenced by announce_connect(), check_connect(), dump_info(), find_connected_name(), FUNCTION(), load_restart_db(), make_port_ulist(), make_portlist(), make_ulist(), raw_broadcast(), SiteMonSend(), and wall_broadcast().

#define DESC_ITER_PLAYER ( p,
 )     for (d=(DESC *)hashfindLEN(&(p), sizeof(p), &mudstate.desc_htab); d; d = d->hashnext)

Definition at line 267 of file interface.h.

Referenced by announce_connect(), announce_disconnect(), check_connect(), check_idle(), desc_reload(), do_doing(), do_prog(), do_quitprog(), fcache_send(), fetch_cmds(), fetch_session(), find_least_idle(), find_oldest(), handle_prog(), logged_out1(), raw_notify(), raw_notify_html(), raw_notify_newline(), shovechars(), and shutdownsock().

#define DESC_SAFEITER_ALL ( d,
 ) 

Value:

for (d=descriptor_list,n=((d!=NULL) ? d->next : NULL); \
         d; \
         d=n,n=((n!=NULL) ? n->next : NULL))

Definition at line 280 of file interface.h.

Referenced by boot_by_port(), check_idle(), close_sockets(), and shovechars().

#define DESC_SAFEITER_PLAYER ( p,
d,
 ) 

Value:

for (d=(DESC *)hashfindLEN(&(p), sizeof(p), &mudstate.desc_htab), \
            n=((d!=NULL) ? d->hashnext : NULL); \
         d; \
         d=n,n=((n!=NULL) ? n->hashnext : NULL))

Definition at line 275 of file interface.h.

Referenced by boot_off().

#define DS_AUTODARK   0x0002

Definition at line 200 of file interface.h.

Referenced by announce_disconnect(), check_idle(), dump_users(), and shovechars().

#define DS_CONNECTED   0x0001

Definition at line 199 of file interface.h.

Referenced by boot_by_port(), check_connect(), check_idle(), do_command(), dump_info(), dump_users(), queue_string(), queue_write_LEN(), and shutdownsock().

#define DS_PUEBLOCLIENT   0x0004

Definition at line 201 of file interface.h.

Referenced by announce_connect(), do_logged_out_internal(), and dump_users().

#define free_desc (  )     pool_free(POOL_DESC,(char *)(b), __FILE__, __LINE__)

Definition at line 259 of file interface.h.

#define NVT_BS   '\x08'

Definition at line 99 of file interface.h.

#define NVT_DEL   '\x7F'

Definition at line 100 of file interface.h.

Referenced by process_input_helper().

#define NVT_DO   '\xFD'

Definition at line 106 of file interface.h.

Referenced by SendDo().

#define NVT_DONT   '\xFE'

Definition at line 107 of file interface.h.

Referenced by SendDont().

#define NVT_EOR   '\xEF'

Definition at line 101 of file interface.h.

Referenced by do_prog(), and handle_prog().

#define NVT_GA   '\xF9'

Definition at line 103 of file interface.h.

Referenced by do_prog(), and handle_prog().

#define NVT_IAC   '\xFF'

Definition at line 108 of file interface.h.

Referenced by check_idle(), do_prog(), encode_iac(), handle_prog(), SendDo(), SendDont(), SendWill(), and SendWont().

#define NVT_IS_HAVE_IAC   1

Definition at line 89 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_DO   4

Definition at line 92 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_DONT   5

Definition at line 93 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_SB   6

Definition at line 94 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_SB_IAC   7

Definition at line 95 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_WILL   2

Definition at line 90 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_HAVE_IAC_WONT   3

Definition at line 91 of file interface.h.

Referenced by process_input_helper().

#define NVT_IS_NORMAL   0

Definition at line 88 of file interface.h.

Referenced by freeqs(), initializesock(), load_restart_db(), and process_input_helper().

#define NVT_NOP   '\xF1'

Definition at line 102 of file interface.h.

Referenced by check_idle().

#define NVT_WILL   '\xFB'

Definition at line 104 of file interface.h.

Referenced by SendWill().

#define NVT_WONT   '\xFC'

Definition at line 105 of file interface.h.

Referenced by SendWont().

#define OPTION_NO   0

Definition at line 118 of file interface.h.

Referenced by EnableHim(), EnableUs(), freeqs(), HimState(), initializesock(), load_restart_db(), process_input_helper(), SetUsState(), and UsState().

#define OPTION_WANTNO_EMPTY   2

Definition at line 120 of file interface.h.

Referenced by DisableHim(), DisableUs(), EnableHim(), EnableUs(), and process_input_helper().

#define OPTION_WANTNO_OPPOSITE   3

Definition at line 121 of file interface.h.

Referenced by DisableHim(), DisableUs(), EnableHim(), EnableUs(), and process_input_helper().

#define OPTION_WANTYES_EMPTY   4

Definition at line 122 of file interface.h.

Referenced by DisableHim(), DisableUs(), EnableHim(), EnableUs(), and process_input_helper().

#define OPTION_WANTYES_OPPOSITE   5

Definition at line 123 of file interface.h.

Referenced by DisableHim(), DisableUs(), EnableHim(), EnableUs(), and process_input_helper().

#define OPTION_YES   1

Definition at line 119 of file interface.h.

Referenced by DesiredUsOption(), DisableHim(), DisableUs(), do_prog(), handle_prog(), process_input_helper(), and SetUsState().

#define R_BADLOGIN   6

Definition at line 31 of file interface.h.

Referenced by check_connect().

#define R_BOOT   3

Definition at line 28 of file interface.h.

Referenced by boot_by_port(), and boot_off().

#define R_GAMEDOWN   7

Definition at line 32 of file interface.h.

Referenced by check_connect().

#define R_GAMEFULL   9

Definition at line 34 of file interface.h.

Referenced by check_connect().

#define R_GOING_DOWN   5

Definition at line 30 of file interface.h.

Referenced by close_sockets().

#define R_LOGOUT   8

Definition at line 33 of file interface.h.

Referenced by do_logged_out_internal(), and shutdownsock().

#define R_QUIT   1

Definition at line 26 of file interface.h.

Referenced by do_logged_out_internal(), load_restart_db(), and shutdownsock().

#define R_SOCKDIED   4

Definition at line 29 of file interface.h.

Referenced by process_output(), and shovechars().

#define R_TIMEOUT   2

Definition at line 27 of file interface.h.

Referenced by check_idle().

#define TELNET_EOR   '\x19'

Definition at line 113 of file interface.h.

Referenced by DesiredHimOption(), DesiredUsOption(), do_prog(), handle_prog(), HimState(), SetHimState(), SetUsState(), TelnetSetup(), and UsState().

#define TELNET_NAWS   '\x1F'

Definition at line 114 of file interface.h.

Referenced by DesiredHimOption(), HimState(), process_input_helper(), SetHimState(), SetUsState(), TelnetSetup(), and UsState().

#define TELNET_SGA   '\x03'

Definition at line 112 of file interface.h.

Referenced by DesiredHimOption(), DesiredUsOption(), do_prog(), handle_prog(), HimState(), SetHimState(), SetUsState(), TelnetSetup(), and UsState().


Typedef Documentation

typedef struct cmd_block CBLK

typedef struct cmd_block CBLK

Definition at line 53 of file interface.h.

typedef struct cmd_block_hdr CBLKHDR

typedef struct descriptor_data DESC

Definition at line 125 of file interface.h.

typedef struct prog_data PROG

Definition at line 80 of file interface.h.

typedef struct text_block TBLOCK

typedef struct text_block TBLOCK

Definition at line 65 of file interface.h.

typedef struct text_block_hdr TBLOCKHDR


Function Documentation

void announce_disconnect ( dbref  ,
DESC ,
const char *   
)

Definition at line 913 of file netcommon.cpp.

References A_ADISCONNECT, alloc_lbuf, alloc_mbuf, argv, atr_pget_str_LEN(), c_Connected, Can_Hide, Contents, statedata::curr_enactor, DARK, db, desc_delhash(), DESC_ITER_PLAYER, do_comdisconnect(), do_mail_purge(), DOLIST, DS_AUTODARK, FLAG_WORD1, descriptor_data::flags, free_lbuf, free_mbuf, object::fs, Good_obj, Guest, H_SUSPECT, halt_que(), confdata::have_comsys, confdata::have_mailer, confdata::have_zones, Hidden, descriptor_data::host_info, local_disconnect(), Location, log_text(), confdata::master_room, Moniker(), MONITOR, MSG_FWDLIST, MSG_INV, MSG_LOC, MSG_NBR, MSG_NBR_EXITS, mudconf, mudstate, Name, NOTHING, notify_check(), notify_except_rlevel(), raw_broadcast(), Suspect, tprintf(), TYPE_ROOM, TYPE_THING, Typeof, wait_que(), WIZARD, flagset::word, and Zone.

Referenced by shutdownsock().

00914 {
00915     int num = 0, key;
00916     DESC *dtemp;
00917     DESC_ITER_PLAYER(player, dtemp)
00918     {
00919         num++;
00920     }
00921 
00922     dbref temp = mudstate.curr_enactor;
00923     mudstate.curr_enactor = player;
00924     dbref loc = Location(player);
00925 
00926     if (num < 2)
00927     {
00928         if (  Suspect(player)
00929            || (d->host_info & H_SUSPECT))
00930         {
00931             raw_broadcast(WIZARD, "[Suspect] %s has disconnected.", Moniker(player));
00932         }
00933         char *buf = alloc_lbuf("announce_disconnect.only");
00934 
00935         sprintf(buf, "%s has disconnected.", Moniker(player));
00936         key = MSG_INV;
00937         if (  loc != NOTHING
00938            && !(  Hidden(player)
00939                && Can_Hide(player)))
00940         {
00941             key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST);
00942         }
00943 #ifdef REALITY_LVLS
00944         if(loc == NOTHING)
00945             notify_check(player, player, buf, key);
00946         else
00947             notify_except_rlevel(loc, player, player, buf, 0);
00948 #else
00949         notify_check(player, player, buf, key);
00950 #endif /* REALITY_LVLS */
00951 
00952         if (mudconf.have_mailer)
00953         {
00954             do_mail_purge(player);
00955         }
00956 
00957         raw_broadcast(MONITOR, "GAME: %s has disconnected. <%s>", Moniker(player), reason);
00958 
00959         c_Connected(player);
00960 
00961         if (mudconf.have_comsys)
00962         {
00963             do_comdisconnect(player);
00964         }
00965 
00966         dbref aowner, zone, obj;
00967         int aflags;
00968         size_t nLen;
00969         char *argv[1];
00970         argv[0] = (char *)reason;
00971         CLinearTimeAbsolute lta;
00972         atr_pget_str_LEN(buf, player, A_ADISCONNECT, &aowner, &aflags, &nLen);
00973         if (nLen)
00974         {
00975             wait_que(player, player, player, false, lta, NOTHING, 0, buf,
00976                 argv, 1, NULL);
00977         }
00978         if (mudconf.master_room != NOTHING)
00979         {
00980             atr_pget_str_LEN(buf, mudconf.master_room, A_ADISCONNECT, &aowner,
00981                 &aflags, &nLen);
00982             if (nLen)
00983             {
00984                 wait_que(mudconf.master_room, player, player, false, lta,
00985                     NOTHING, 0, buf, (char **)NULL, 0, NULL);
00986             }
00987             DOLIST(obj, Contents(mudconf.master_room))
00988             {
00989                 atr_pget_str_LEN(buf, obj, A_ADISCONNECT, &aowner, &aflags,
00990                     &nLen);
00991                 if (nLen)
00992                 {
00993                     wait_que(obj, player, player, false, lta, NOTHING, 0,
00994                         buf, (char **)NULL, 0, NULL);
00995                 }
00996             }
00997         }
00998 
00999         // Do the zone of the player's location's possible adisconnect.
01000         //
01001         if (mudconf.have_zones && Good_obj(zone = Zone(loc)))
01002         {
01003             switch (Typeof(zone))
01004             {
01005             case TYPE_THING:
01006 
01007                 atr_pget_str_LEN(buf, zone, A_ADISCONNECT, &aowner, &aflags,
01008                     &nLen);
01009                 if (nLen)
01010                 {
01011                     wait_que(zone, player, player, false, lta, NOTHING, 0,
01012                         buf, (char **)NULL, 0, NULL);
01013                 }
01014                 break;
01015 
01016             case TYPE_ROOM:
01017 
01018                 // check every object in the room for a connect action.
01019                 //
01020                 DOLIST(obj, Contents(zone))
01021                 {
01022                     atr_pget_str_LEN(buf, obj, A_ADISCONNECT, &aowner, &aflags,
01023                         &nLen);
01024                     if (nLen)
01025                     {
01026                         wait_que(obj, player, player, false, lta, NOTHING,
01027                             0, buf, (char **)NULL, 0, NULL);
01028                     }
01029                 }
01030                 break;
01031 
01032             default:
01033                 log_text(tprintf("Invalid zone #%d for %s(#%d) has bad type %d",
01034                     zone, Name(player), player, Typeof(zone)));
01035             }
01036         }
01037         free_lbuf(buf);
01038         if (d->flags & DS_AUTODARK)
01039         {
01040             d->flags &= ~DS_AUTODARK;
01041             db[player].fs.word[FLAG_WORD1] &= ~DARK;
01042         }
01043 
01044         if (Guest(player))
01045         {
01046             db[player].fs.word[FLAG_WORD1] |= DARK;
01047             halt_que(NOTHING, player);
01048         }
01049     }
01050     else
01051     {
01052         if (  Suspect(player)
01053            || (d->host_info & H_SUSPECT))
01054         {
01055             raw_broadcast(WIZARD, "[Suspect] %s has partially disconnected.", Moniker(player));
01056         }
01057         char *mbuf = alloc_mbuf("announce_disconnect.partial");
01058         sprintf(mbuf, "%s has partially disconnected.", Moniker(player));
01059         key = MSG_INV;
01060         if (  loc != NOTHING
01061            && !(  Hidden(player)
01062                && Can_Hide(player)))
01063         {
01064             key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST);
01065         }
01066 #ifdef REALITY_LVLS
01067         if(loc == NOTHING)
01068             notify_check(player, player, mbuf, key);
01069         else
01070             notify_except_rlevel(loc, player, player, mbuf, 0);
01071 #else
01072         notify_check(player, player, mbuf, key);
01073 #endif /* REALITY_LVLS */
01074         raw_broadcast(MONITOR, "GAME: %s has partially disconnected.",
01075             Moniker(player));
01076         free_mbuf(mbuf);
01077     }
01078 
01079     mudstate.curr_enactor = temp;
01080     desc_delhash(d);
01081 
01082     local_disconnect(player, num);
01083 }

int boot_by_port ( SOCKET  port,
bool  bGod,
const char *  message 
)

Definition at line 1102 of file netcommon.cpp.

References DESC_SAFEITER_ALL, descriptor_data::descriptor, DS_CONNECTED, descriptor_data::flags, God, descriptor_data::player, queue_string(), queue_write_LEN(), R_BOOT, and shutdownsock().

Referenced by do_boot().

01103 {
01104     DESC *d, *dnext;
01105     int count = 0;
01106     DESC_SAFEITER_ALL(d, dnext)
01107     {
01108         if (  d->descriptor == port
01109            && (  bGod
01110               || !(d->flags & DS_CONNECTED)
01111               || !God(d->player)))
01112         {
01113             if (  message
01114                && *message)
01115             {
01116                 queue_string(d, message);
01117                 queue_write_LEN(d, "\r\n", 2);
01118             }
01119             shutdownsock(d, R_BOOT);
01120             count++;
01121         }
01122     }
01123     return count;
01124 }

void BuildSignalNamesTable ( void   ) 

Definition at line 3632 of file bsd.cpp.

References aSigTypes, SIGNALTYPE::iSignal, MUX_SIGNAMES::pLongName, MUX_SIGNAMES::pShortName, signames, and SIGNALTYPE::szSignal.

Referenced by main().

03633 {
03634     int i;
03635     for (i = 0; i < NSIG; i++)
03636     {
03637         signames[i].pShortName = NULL;
03638         signames[i].pLongName  = NULL;
03639     }
03640 
03641     const SIGNALTYPE *pst = aSigTypes;
03642     while (pst->szSignal)
03643     {
03644         int sig = pst->iSignal;
03645         if (  0 <= sig
03646            && sig < NSIG)
03647         {
03648             MUX_SIGNAMES *tsn = &signames[sig];
03649             if (tsn->pShortName == NULL)
03650             {
03651                 tsn->pShortName = pst->szSignal;
03652 #ifndef WIN32
03653                 if (sig == SIGUSR1)
03654                 {
03655                     tsn->pLongName = "Restart server";
03656                 }
03657                 else if (sig == SIGUSR2)
03658                 {
03659                     tsn->pLongName = "Drop flatfile";
03660                 }
03661 #endif // WIN32
03662 #ifdef SysSigNames
03663                 if (  tsn->pLongName == NULL
03664                    && SysSigNames[sig]
03665                    && strcmp(tsn->pShortName, SysSigNames[sig]) != 0)
03666                 {
03667                     tsn->pLongName = SysSigNames[sig];
03668                 }
03669 #endif // SysSigNames
03670             }
03671         }
03672         pst++;
03673     }
03674     for (i = 0; i < NSIG; i++)
03675     {
03676         MUX_SIGNAMES *tsn = &signames[i];
03677         if (tsn->pShortName == NULL)
03678         {
03679 #ifdef SysSigNames
03680             if (SysSigNames[i])
03681             {
03682                 tsn->pLongName = SysSigNames[i];
03683             }
03684 #endif // SysSigNames
03685 
03686             // This is the only non-const memory case.
03687             //
03688             tsn->pShortName = StringClone(tprintf("SIG%03d", i));
03689         }
03690     }
03691 }

void check_idle ( void   ) 

Definition at line 1279 of file netcommon.cpp.

References Can_Idle, confdata::conn_timeout, descriptor_data::connected_at, d1, DARK, db, DESC_ITER_PLAYER, DESC_SAFEITER_ALL, DS_AUTODARK, DS_CONNECTED, FLAG_WORD1, descriptor_data::flags, Flags, object::fs, CLinearTimeAbsolute::GetUTC(), confdata::idle_timeout, confdata::idle_wiz_dark, KeepAlive, descriptor_data::last_time, mudconf, NVT_IAC, NVT_NOP, descriptor_data::player, queue_write(), queue_write_LEN(), R_TIMEOUT, CLinearTimeDelta::ReturnSeconds(), shutdownsock(), descriptor_data::timeout, WIZARD, and flagset::word.

Referenced by dispatch_IdleCheck().

01280 {
01281     DESC *d, *dnext;
01282 
01283     CLinearTimeAbsolute ltaNow;
01284     ltaNow.GetUTC();
01285 
01286     DESC_SAFEITER_ALL(d, dnext)
01287     {
01288         if (  (d->flags & DS_CONNECTED)
01289            && KeepAlive(d->player))
01290         {
01291             // Send a Telnet NOP code - creates traffic to keep NAT routers
01292             // happy.  Hopefully this only runs once a minute.
01293             //
01294             const char aNOP[2] = { NVT_IAC, NVT_NOP };
01295             queue_write_LEN(d, aNOP, sizeof(aNOP));
01296         }
01297         if (d->flags & DS_AUTODARK)
01298         {
01299             continue;
01300         }
01301         if (d->flags & DS_CONNECTED)
01302         {
01303             if (mudconf.idle_timeout <= 0)
01304             {
01305                 // Idle timeout checking on connected players is effectively disabled.
01306                 // PennMUSH uses idle_timeout == 0. Rhost uses idel_timeout == -1.
01307                 // We will be disabled for either setting.
01308                 //
01309                 continue;
01310             }
01311 
01312             CLinearTimeDelta ltdIdle = ltaNow - d->last_time;
01313             if (Can_Idle(d->player))
01314             {
01315                 if (  mudconf.idle_wiz_dark
01316                    && (Flags(d->player) & (WIZARD|DARK)) == WIZARD
01317                    && ltdIdle.ReturnSeconds() > mudconf.idle_timeout)
01318                 {
01319                     // Make sure this Wizard player does not have some other
01320                     // active session.
01321                     //
01322                     DESC *d1;
01323                     bool bFound = false;
01324                     DESC_ITER_PLAYER(d->player, d1)
01325                     {
01326                         if (d1 != d)
01327                         {
01328                             CLinearTimeDelta ltd = ltaNow - d1->last_time;
01329                             if (ltd.ReturnSeconds() <= mudconf.idle_timeout)
01330                             {
01331                                  bFound = true;
01332                                  break;
01333                             }
01334                         }
01335                     }
01336                     if (!bFound)
01337                     {
01338                         db[d->player].fs.word[FLAG_WORD1] |= DARK;
01339                         DESC_ITER_PLAYER(d->player, d1)
01340                         {
01341                             d1->flags |= DS_AUTODARK;
01342                         }
01343                     }
01344                 }
01345             }
01346             else if (ltdIdle.ReturnSeconds() > d->timeout)
01347             {
01348                 queue_write(d, "*** Inactivity Timeout ***\r\n");
01349                 shutdownsock(d, R_TIMEOUT);
01350             }
01351         }
01352         else if (0 < mudconf.conn_timeout)
01353         {
01354             CLinearTimeDelta ltdIdle = ltaNow - d->connected_at;
01355             if (ltdIdle.ReturnSeconds() > mudconf.conn_timeout)
01356             {
01357                 queue_write(d, "*** Login Timeout ***\r\n");
01358                 shutdownsock(d, R_TIMEOUT);
01359             }
01360         }
01361     }
01362 }

void clearstrings ( DESC  ) 

Definition at line 239 of file netcommon.cpp.

References free_lbuf, descriptor_data::output_prefix, and descriptor_data::output_suffix.

Referenced by shutdownsock().

00240 {
00241     if (d->output_prefix)
00242     {
00243         free_lbuf(d->output_prefix);
00244         d->output_prefix = NULL;
00245     }
00246     if (d->output_suffix)
00247     {
00248         free_lbuf(d->output_suffix);
00249         d->output_suffix = NULL;
00250     }
00251 }

dbref connect_player ( char *  ,
char *  ,
char *  ,
char *  ,
char *   
)

Definition at line 490 of file player.cpp.

References A_ALLOWANCE, A_LAST, atr_add_raw(), atr_get, atr_pget, check_pass(), free_lbuf, CLinearTimeAbsolute::GetLocal(), giveto(), lookup_player(), mudconf, mux_atol(), NOTHING, confdata::paycheck, record_login(), and CLinearTimeAbsolute::ReturnDateString().

Referenced by check_connect().

00491 {
00492     CLinearTimeAbsolute ltaNow;
00493     ltaNow.GetLocal();
00494     char *time_str = ltaNow.ReturnDateString(7);
00495 
00496     dbref player = lookup_player(NOTHING, name, false);
00497     if (player == NOTHING)
00498     {
00499         return NOTHING;
00500     }
00501     if (!check_pass(player, password))
00502     {
00503         record_login(player, false, time_str, host, username, ipaddr);
00504         return NOTHING;
00505     }
00506 
00507     // Compare to last connect see if player gets salary.
00508     //
00509     int aflags;
00510     dbref aowner;
00511     char *player_last = atr_get(player, A_LAST, &aowner, &aflags);
00512     if (strncmp(player_last, time_str, 10) != 0)
00513     {
00514         char *allowance = atr_pget(player, A_ALLOWANCE, &aowner, &aflags);
00515         if (*allowance == '\0')
00516         {
00517             giveto(player, mudconf.paycheck);
00518         }
00519         else
00520         {
00521             giveto(player, mux_atol(allowance));
00522         }
00523         free_lbuf(allowance);
00524     }
00525     free_lbuf(player_last);
00526     atr_add_raw(player, A_LAST, time_str);
00527     return player;
00528 }

void desc_addhash ( DESC  ) 

Definition at line 513 of file netcommon.cpp.

References statedata::desc_htab, hashaddLEN(), hashfindLEN(), descriptor_data::hashnext, hashreplLEN(), mudstate, and descriptor_data::player.

Referenced by announce_connect(), and load_restart_db().

00514 {
00515     dbref player = d->player;
00516     DESC *hdesc = (DESC *)hashfindLEN(&player, sizeof(player), &mudstate.desc_htab);
00517     if (hdesc == NULL)
00518     {
00519         d->hashnext = NULL;
00520         hashaddLEN(&player, sizeof(player), d, &mudstate.desc_htab);
00521     }
00522     else
00523     {
00524         d->hashnext = hdesc;
00525         hashreplLEN(&player, sizeof(player), d, &mudstate.desc_htab);
00526     }
00527 }

void DisableHim ( DESC d,
unsigned char  chOption 
)

Start the process of negotiating the disablement of an option on his side.

Whether we actually send anything across the wire to disable this depends on the negotiation state. The option could potentially already be disabled.

Parameters:
d Player connection context.
chOption Telnet Option.
Returns:
None.

Definition at line 2874 of file bsd.cpp.

References HimState(), OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, OPTION_WANTYES_OPPOSITE, OPTION_YES, SendDont(), and SetHimState().

02875 {
02876     switch (HimState(d, chOption))
02877     {
02878     case OPTION_YES:
02879         SetHimState(d, chOption, OPTION_WANTNO_EMPTY);
02880         SendDont(d, chOption);
02881         break;
02882 
02883     case OPTION_WANTNO_OPPOSITE:
02884         SetHimState(d, chOption, OPTION_WANTNO_EMPTY);
02885         break;
02886 
02887     case OPTION_WANTYES_EMPTY:
02888         SetHimState(d, chOption, OPTION_WANTYES_OPPOSITE);
02889         break;
02890     }
02891 }

void DisableUs ( DESC d,
unsigned char  chOption 
)

Start the process of negotiating the disablement of an option on our side.

Whether we actually send anything across the wire to disable this depends on the negotiation state. The option could potentially already be disabled.

Parameters:
d Player connection context.
chOption Telnet Option.
Returns:
None.

Definition at line 2934 of file bsd.cpp.

References HimState(), OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, OPTION_WANTYES_OPPOSITE, OPTION_YES, SendWont(), and SetUsState().

Referenced by SetUsState().

02935 {
02936     switch (HimState(d, chOption))
02937     {
02938     case OPTION_YES:
02939         SetUsState(d, chOption, OPTION_WANTNO_EMPTY);
02940         SendWont(d, chOption);
02941         break;
02942 
02943     case OPTION_WANTNO_OPPOSITE:
02944         SetUsState(d, chOption, OPTION_WANTNO_EMPTY);
02945         break;
02946 
02947     case OPTION_WANTYES_EMPTY:
02948         SetUsState(d, chOption, OPTION_WANTYES_OPPOSITE);
02949         break;
02950     }
02951 }

void do_command ( DESC ,
char *   
)

Definition at line 2335 of file netcommon.cpp.

References alloc_lbuf, CMuxAlarm::bAlarmed, CA_PUBLIC, check_connect(), CMuxAlarm::Clear(), CMD_MASK, CMD_NOxFIX, CMD_QUIT, descriptor_data::command_count, statedata::curr_cmd, statedata::curr_enactor, statedata::curr_executor, statedata::debug_cmd, do_logged_out_internal(), DS_CONNECTED, ENDLOG, name_table::flag, FLAG_WORD1, descriptor_data::flags, Flags, free_lbuf, CLinearTimeAbsolute::GetUTC(), statedata::glob_reg_len, statedata::global_regs, HALT, halt_que(), hashfindLEN(), log_name_and_loc(), LOG_PROBLEMS, log_text(), statedata::logout_cmd_htab, confdata::max_cmdsecs, MAX_GLOBAL_REGS, mudconf, mudstate, mux_isspace, MuxAlarm, name_table::name, NOTHING, notify, descriptor_data::output_prefix, descriptor_data::output_suffix, name_table::perm, descriptor_data::player, process_command(), queue_string(), queue_write(), queue_write_LEN(), CLinearTimeDelta::ReturnSecondsString(), confdata::rpt_cmdsecs, s_Flags, CMuxAlarm::Set(), and STARTLOG.

Referenced by handle_prog(), and Task_ProcessCommand().

02336 {
02337     char *cmdsave = mudstate.debug_cmd;
02338     mudstate.debug_cmd = (char *)"< do_command >";
02339 
02340     if (d->flags & DS_CONNECTED)
02341     {
02342         // Normal logged-in command processing.
02343         //
02344         d->command_count++;
02345         if (d->output_prefix)
02346         {
02347             queue_string(d, d->output_prefix);
02348             queue_write_LEN(d, "\r\n", 2);
02349         }
02350         mudstate.curr_executor = d->player;
02351         mudstate.curr_enactor = d->player;
02352         for (int i = 0; i < MAX_GLOBAL_REGS; i++)
02353         {
02354             mudstate.global_regs[i][0] = '\0';
02355             mudstate.glob_reg_len[i] = 0;
02356         }
02357 
02358         CLinearTimeAbsolute ltaBegin;
02359         ltaBegin.GetUTC();
02360         MuxAlarm.Set(mudconf.max_cmdsecs);
02361 
02362         char *log_cmdbuf = process_command(d->player, d->player, d->player,
02363             true, command, (char **)NULL, 0);
02364 
02365         CLinearTimeAbsolute ltaEnd;
02366         ltaEnd.GetUTC();
02367         if (MuxAlarm.bAlarmed)
02368         {
02369             notify(d->player, "GAME: Expensive activity abbreviated.");
02370             halt_que(d->player, NOTHING);
02371             s_Flags(d->player, FLAG_WORD1, Flags(d->player) | HALT);
02372         }
02373         MuxAlarm.Clear();
02374 
02375         CLinearTimeDelta ltd = ltaEnd - ltaBegin;
02376         if (ltd > mudconf.rpt_cmdsecs)
02377         {
02378             STARTLOG(LOG_PROBLEMS, "CMD", "CPU");
02379             log_name_and_loc(d->player);
02380             char *logbuf = alloc_lbuf("do_command.LOG.cpu");
02381             sprintf(logbuf, " queued command taking %s secs: ",
02382                 ltd.ReturnSecondsString(4));
02383             log_text(logbuf);
02384             free_lbuf(logbuf);
02385             log_text(log_cmdbuf);
02386             ENDLOG;
02387         }
02388 
02389         mudstate.curr_cmd = (char *) "";
02390         if (d->output_suffix)
02391         {
02392             queue_string(d, d->output_suffix);
02393             queue_write_LEN(d, "\r\n", 2);
02394         }
02395         mudstate.debug_cmd = cmdsave;
02396         return;
02397     }
02398 
02399     // Login screen (logged-out) command processing.
02400     //
02401 
02402     // Split off the command from the arguments.
02403     //
02404     char *arg = command;
02405     while (*arg && !mux_isspace(*arg))
02406     {
02407         arg++;
02408     }
02409 
02410     if (*arg)
02411     {
02412         *arg++ = '\0';
02413     }
02414 
02415     // Look up the command in the logged-out command table.
02416     //
02417     NAMETAB *cp = (NAMETAB *)hashfindLEN(command, strlen(command), &mudstate.logout_cmd_htab);
02418     if (cp == NULL)
02419     {
02420         // Not in the logged-out command table, so maybe a connect attempt.
02421         //
02422         if (*arg)
02423         {
02424             // Restore nullified space
02425             //
02426             *--arg = ' ';
02427         }
02428         mudstate.curr_executor = NOTHING;
02429         mudstate.curr_enactor = NOTHING;
02430         mudstate.debug_cmd = cmdsave;
02431         check_connect(d, command);
02432         return;
02433     }
02434 
02435     // The command was in the logged-out command table. Perform
02436     // prefix and suffix processing, and invoke the command
02437     // handler.
02438     //
02439     d->command_count++;
02440     if (!(cp->flag & CMD_NOxFIX))
02441     {
02442         if (d->output_prefix)
02443         {
02444             queue_string(d, d->output_prefix);
02445             queue_write_LEN(d, "\r\n", 2);
02446         }
02447     }
02448     if (cp->perm != CA_PUBLIC)
02449     {
02450         queue_write(d, "Permission denied.\r\n");
02451     }
02452     else
02453     {
02454         mudstate.debug_cmd = cp->name;
02455         do_logged_out_internal(d, cp->flag & CMD_MASK, arg);
02456     }
02457     // QUIT or LOGOUT will close the connection and cause the
02458     // descriptor to be freed!
02459     //
02460     if (  ((cp->flag & CMD_MASK) != CMD_QUIT)
02461        && ((cp->flag & CMD_MASK) != CMD_LOGOUT)
02462        && !(cp->flag & CMD_NOxFIX))
02463     {
02464         if (d->output_suffix)
02465         {
02466             queue_string(d, d->output_suffix);
02467             queue_write_LEN(d, "\r\n", 2);
02468         }
02469     }
02470     mudstate.debug_cmd = cmdsave;
02471 }

void dump_restart_db ( void   ) 

Definition at line 3166 of file db.cpp.

References descriptor_data::addr, aMainGamePorts, descriptor_data::command_count, descriptor_data::connected_at, DESC_ITER_ALL, descriptor_data::descriptor, descriptor_data::doing, statedata::doing_hdr, descriptor_data::flags, descriptor_data::height, descriptor_data::host_info, descriptor_data::last_time, mudstate, nMainGamePorts, descriptor_data::nvt_eor_him_state, descriptor_data::nvt_eor_us_state, descriptor_data::nvt_naws_him_state, descriptor_data::nvt_naws_us_state, descriptor_data::nvt_sga_him_state, descriptor_data::nvt_sga_us_state, descriptor_data::output_prefix, descriptor_data::output_suffix, descriptor_data::player, putref(), putstring(), descriptor_data::raw_input_state, statedata::record_players, CLinearTimeAbsolute::ReturnSeconds(), statedata::start_time, descriptor_data::timeout, descriptor_data::username, and descriptor_data::width.

Referenced by do_restart(), and sighandler().

03167 {
03168     FILE *f;
03169     DESC *d;
03170     int version = 2;
03171 
03172     f = fopen("restart.db", "wb");
03173     fprintf(f, "+V%d\n", version);
03174     putref(f, nMainGamePorts);
03175     for (int i = 0; i < nMainGamePorts; i++)
03176     {
03177         putref(f, aMainGamePorts[i].port);
03178         putref(f, aMainGamePorts[i].socket);
03179     }
03180     putref(f, mudstate.start_time.ReturnSeconds());
03181     putstring(f, mudstate.doing_hdr);
03182     putref(f, mudstate.record_players);
03183     DESC_ITER_ALL(d)
03184     {
03185         putref(f, d->descriptor);
03186         putref(f, d->flags);
03187         putref(f, d->connected_at.ReturnSeconds());
03188         putref(f, d->command_count);
03189         putref(f, d->timeout);
03190         putref(f, d->host_info);
03191         putref(f, d->player);
03192         putref(f, d->last_time.ReturnSeconds());
03193         putref(f, d->raw_input_state);
03194         putref(f, d->nvt_sga_him_state);
03195         putref(f, d->nvt_sga_us_state);
03196         putref(f, d->nvt_eor_him_state);
03197         putref(f, d->nvt_eor_us_state);
03198         putref(f, d->nvt_naws_him_state);
03199         putref(f, d->nvt_naws_us_state);
03200         putref(f, d->height);
03201         putref(f, d->width);
03202         putstring(f, d->output_prefix);
03203         putstring(f, d->output_suffix);
03204         putstring(f, d->addr);
03205         putstring(f, d->doing);
03206         putstring(f, d->username);
03207     }
03208     putref(f, 0);
03209 
03210     fclose(f);
03211 }

void emergency_shutdown ( void   ) 

Definition at line 3371 of file bsd.cpp.

References close_sockets().

Referenced by do_shutdown().

03372 {
03373     close_sockets(true, "Going down - Bye");
03374 }

void EnableHim ( DESC d,
unsigned char  chOption 
)

Start the process of negotiating the enablement of an option on his side.

Whether we actually send anything across the wire to enable this depends on the negotiation state. The option could potentially already be enabled.

Parameters:
d Player connection context.
chOption Telnet Option.
Returns:
None.

Definition at line 2844 of file bsd.cpp.

References HimState(), OPTION_NO, OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, OPTION_WANTYES_OPPOSITE, SendDo(), and SetHimState().

Referenced by TelnetSetup().

02845 {
02846     switch (HimState(d, chOption))
02847     {
02848     case OPTION_NO:
02849         SetHimState(d, chOption, OPTION_WANTYES_EMPTY);
02850         SendDo(d, chOption);
02851         break;
02852 
02853     case OPTION_WANTNO_EMPTY:
02854         SetHimState(d, chOption, OPTION_WANTNO_OPPOSITE);
02855         break;
02856 
02857     case OPTION_WANTYES_OPPOSITE:
02858         SetHimState(d, chOption, OPTION_WANTYES_EMPTY);
02859         break;
02860     }
02861 }

void EnableUs ( DESC d,
unsigned char  chOption 
)

Start the process of negotiating the enablement of an option on our side.

Whether we actually send anything across the wire to enable this depends on the negotiation state. The option could potentially already be enabled.

Parameters:
d Player connection context.
chOption Telnet Option.
Returns:
None.

Definition at line 2904 of file bsd.cpp.

References HimState(), OPTION_NO, OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, OPTION_WANTYES_OPPOSITE, SendWill(), and SetUsState().

Referenced by SetUsState(), and TelnetSetup().

02905 {
02906     switch (HimState(d, chOption))
02907     {
02908     case OPTION_NO:
02909         SetUsState(d, chOption, OPTION_WANTYES_EMPTY);
02910         SendWill(d, chOption);
02911         break;
02912 
02913     case OPTION_WANTNO_EMPTY:
02914         SetUsState(d, chOption, OPTION_WANTNO_OPPOSITE);
02915         break;
02916 
02917     case OPTION_WANTYES_OPPOSITE:
02918         SetUsState(d, chOption, OPTION_WANTYES_EMPTY);
02919         break;
02920     }
02921 }

int fetch_connect ( dbref  target  ) 

Definition at line 1252 of file netcommon.cpp.

References descriptor_data::connected_at, find_oldest(), CLinearTimeAbsolute::GetUTC(), and CLinearTimeDelta::ReturnSeconds().

Referenced by FUNCTION().

01253 {
01254     DESC *dOldest[2];
01255     find_oldest(target, dOldest);
01256     if (dOldest[0])
01257     {
01258         CLinearTimeAbsolute ltaNow;
01259         CLinearTimeDelta ltdOldest;
01260 
01261         ltaNow.GetUTC();
01262         ltdOldest = ltaNow - dOldest[0]->connected_at;
01263         return ltdOldest.ReturnSeconds();
01264     }
01265     else
01266     {
01267         return -1;
01268     }
01269 }

int fetch_height ( dbref  target  ) 

Definition at line 1184 of file netcommon.cpp.

References find_least_idle(), and descriptor_data::height.

Referenced by FUNCTION().

01185 {
01186     DESC *d = find_least_idle(target);
01187     if (NULL != d)
01188     {
01189         return d->height;
01190     }
01191     return 24;
01192 }

int fetch_idle ( dbref  target  ) 

Definition at line 1207 of file netcommon.cpp.

References find_least_idle(), CLinearTimeAbsolute::GetUTC(), descriptor_data::last_time, and CLinearTimeDelta::ReturnSeconds().

Referenced by do_page(), and FUNCTION().

01208 {
01209     CLinearTimeAbsolute ltaNow;
01210     ltaNow.GetUTC();
01211 
01212     DESC *d = find_least_idle(target);
01213     if (NULL != d)
01214     {
01215         CLinearTimeDelta ltdResult;
01216         ltdResult = ltaNow - d->last_time;
01217         return ltdResult.ReturnSeconds();
01218     }
01219     else
01220     {
01221         return -1;
01222     }
01223 }

int fetch_session ( dbref  target  ) 

Definition at line 1155 of file netcommon.cpp.

References DESC_ITER_PLAYER.

Referenced by FUNCTION().

01156 {
01157     DESC *d;
01158     int nCount = 0;
01159     DESC_ITER_PLAYER(target, d)
01160     {
01161         nCount++;
01162     }
01163     return nCount;
01164 }

int fetch_width ( dbref  target  ) 

Definition at line 1194 of file netcommon.cpp.

References find_least_idle(), and descriptor_data::width.

Referenced by FUNCTION().

01195 {
01196     DESC *d = find_least_idle(target);
01197     if (NULL != d)
01198     {
01199         return d->width;
01200     }
01201     return 78;
01202 }

dbref find_connected_name ( dbref  ,
char *   
)

Definition at line 2713 of file netcommon.cpp.

References DESC_ITER_CONN, Good_obj, Hidden, Name, NOTHING, descriptor_data::player, See_Hidden, and string_prefix().

Referenced by lookup_player().

02714 {
02715     DESC *d;
02716     dbref found = NOTHING;
02717     DESC_ITER_CONN(d)
02718     {
02719         if (  Good_obj(player)
02720            && !See_Hidden(player)
02721            && Hidden(d->player))
02722         {
02723             continue;
02724         }
02725         if (!string_prefix(Name(d->player), name))
02726         {
02727             continue;
02728         }
02729         if (  found != NOTHING
02730            && found != d->player)
02731         {
02732             return NOTHING;
02733         }
02734         found = d->player;
02735     }
02736     return found;
02737 }

void find_oldest ( dbref  target,
DESC dOldest[2] 
)

Definition at line 1229 of file netcommon.cpp.

References descriptor_data::connected_at, and DESC_ITER_PLAYER.

Referenced by fetch_connect(), and shutdownsock().

01230 {
01231     dOldest[0] = NULL;
01232     dOldest[1] = NULL;
01233 
01234     DESC *d;
01235     bool bFound = false;
01236     DESC_ITER_PLAYER(target, d)
01237     {
01238         if (  !bFound
01239            || d->connected_at < dOldest[0]->connected_at)
01240         {
01241             bFound = true;
01242             dOldest[1] = dOldest[0];
01243             dOldest[0] = d;
01244         }
01245     }
01246 }

void freeqs ( DESC  ) 

Definition at line 464 of file netcommon.cpp.

References free_lbuf, text_block::hdr, cmd_block::hdr, descriptor_data::height, descriptor_data::input_head, descriptor_data::input_tail, MEMFREE, descriptor_data::nOption, descriptor_data::nvt_eor_him_state, descriptor_data::nvt_eor_us_state, NVT_IS_NORMAL, descriptor_data::nvt_naws_him_state, descriptor_data::nvt_naws_us_state, descriptor_data::nvt_sga_him_state, descriptor_data::nvt_sga_us_state, text_block_hdr::nxt, cmd_block_hdr::nxt, OPTION_NO, descriptor_data::output_head, descriptor_data::output_tail, descriptor_data::raw_input, descriptor_data::raw_input_at, descriptor_data::raw_input_state, and descriptor_data::width.

00465 {
00466     TBLOCK *tb, *tnext;
00467     CBLK *cb, *cnext;
00468 
00469     tb = d->output_head;
00470     while (tb)
00471     {
00472         tnext = tb->hdr.nxt;
00473         MEMFREE(tb);
00474         tb = tnext;
00475     }
00476     d->output_head = NULL;
00477     d->output_tail = NULL;
00478 
00479     cb = d->input_head;
00480     while (cb)
00481     {
00482         cnext = (CBLK *) cb->hdr.nxt;
00483         free_lbuf(cb);
00484         cb = cnext;
00485     }
00486 
00487     d->input_head = NULL;
00488     d->input_tail = NULL;
00489 
00490     if (d->raw_input)
00491     {
00492         free_lbuf(d->raw_input);
00493     }
00494     d->raw_input = NULL;
00495 
00496     d->raw_input_at = NULL;
00497     d->nOption = 0;
00498     d->raw_input_state    = NVT_IS_NORMAL;
00499     d->nvt_sga_him_state  = OPTION_NO;
00500     d->nvt_sga_us_state   = OPTION_NO;
00501     d->nvt_eor_him_state  = OPTION_NO;
00502     d->nvt_eor_us_state   = OPTION_NO;
00503     d->nvt_naws_him_state = OPTION_NO;
00504     d->nvt_naws_us_state  = OPTION_NO;
00505     d->height = 24;
00506     d->width = 78;
00507 }

void handle_prog ( DESC d,
char *  message 
)

Definition at line 1151 of file predicates.cpp.

References A_PROGCMD, ANSI_HILITE, ANSI_NORMAL, atr_get, statedata::desc_htab, DESC_ITER_PLAYER, do_command(), free_lbuf, hashfindLEN(), MAX_GLOBAL_REGS, MEMFREE, mudstate, NOTHING, NVT_EOR, NVT_GA, NVT_IAC, OPTION_YES, descriptor_data::player, descriptor_data::program_data, queue_string(), queue_write_LEN(), TELNET_EOR, TELNET_SGA, tprintf(), UsState(), prog_data::wait_enactor, wait_que(), and prog_data::wait_regs.

Referenced by Task_ProcessCommand().

01152 {
01153     // Allow the player to pipe a command while in interactive mode.
01154     //
01155     if (*message == '|')
01156     {
01157         do_command(d, message + 1);
01158 
01159         if (d->program_data != NULL)
01160         {
01161             queue_string(d, tprintf("%s>%s ", ANSI_HILITE, ANSI_NORMAL));
01162 
01163             if (OPTION_YES == UsState(d, TELNET_EOR))
01164             {
01165                 // Use telnet protocol's EOR command to show prompt.
01166                 //
01167                 const char aEOR[2] = { NVT_IAC, NVT_EOR };
01168                 queue_write_LEN(d, aEOR, sizeof(aEOR));
01169             }
01170             else if (OPTION_YES != UsState(d, TELNET_SGA))
01171             {
01172                 // Use telnet protocol's GOAHEAD command to show prompt.
01173                 //
01174                 const char aGoAhead[2] = { NVT_IAC, NVT_GA };
01175                 queue_write_LEN(d, aGoAhead, sizeof(aGoAhead));
01176             }
01177         }
01178         return;
01179     }
01180     dbref aowner;
01181     int aflags, i;
01182     char *cmd = atr_get(d->player, A_PROGCMD, &aowner, &aflags);
01183     CLinearTimeAbsolute lta;
01184     wait_que(d->program_data->wait_enactor, d->player, d->player, false, lta,
01185         NOTHING, 0, cmd, (char **)&message, 1,
01186         (char **)d->program_data->wait_regs);
01187 
01188     // First, set 'all' to a descriptor we find for this player.
01189     //
01190     DESC *all = (DESC *)hashfindLEN(&(d->player), sizeof(d->player), &mudstate.desc_htab) ;
01191 
01192     if (all && all->program_data)
01193     {
01194         for (i = 0; i < MAX_GLOBAL_REGS; i++)
01195         {
01196             if (all->program_data->wait_regs[i])
01197             {
01198                 free_lbuf(all->program_data->wait_regs[i]);
01199                 all->program_data->wait_regs[i] = NULL;
01200             }
01201         }
01202 
01203         MEMFREE(all->program_data);
01204         all->program_data = NULL;
01205 
01206         // Set info for all player descriptors to NULL
01207         //
01208         DESC_ITER_PLAYER(d->player, all)
01209             all->program_data = NULL;
01210     }
01211     atr_clr(d->player, A_PROGCMD);
01212     free_lbuf(cmd);
01213 }

int HimState ( DESC d,
unsigned char  chOption 
)

Return the other side's negotiation state.

The negotiation of each optional feature of telnet can be in one of six states (defined in interface.h): OPTION_NO, OPTION_YES, OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, and OPTION_WANTYES_OPPOSITE.

An option is only enabled when it is in the OPTION_YES state.

Parameters:
d Player connection context.
chOption Telnet Option
Returns:
One of six states.

Definition at line 2629 of file bsd.cpp.

References descriptor_data::nvt_eor_him_state, descriptor_data::nvt_naws_him_state, descriptor_data::nvt_sga_him_state, OPTION_NO, TELNET_EOR, TELNET_NAWS, and TELNET_SGA.

Referenced by DisableHim(), DisableUs(), EnableHim(), EnableUs(), and process_input_helper().

02630 {
02631     if (TELNET_NAWS == chOption)
02632     {
02633         return d->nvt_naws_him_state;
02634     }
02635     else if (TELNET_EOR == chOption)
02636     {
02637         return d->nvt_eor_him_state;
02638     }
02639     else if (TELNET_SGA == chOption)
02640     {
02641         return d->nvt_sga_him_state;
02642     }
02643     return OPTION_NO;
02644 }

void make_port_ulist ( dbref  ,
char *  ,
char **   
)

Definition at line 58 of file netcommon.cpp.

References alloc_sbuf, DESC_ITER_CONN, descriptor_data::descriptor, free_sbuf, Hidden, ItemToList_AddStringLEN(), ItemToList_Final(), ItemToList_Init(), mux_ltoa(), descriptor_data::player, and See_Hidden.

Referenced by FUNCTION(), and make_ulist().

00059 {
00060     DESC *d;
00061     ITL itl;
00062     char *tmp = alloc_sbuf("make_port_ulist");
00063     ItemToList_Init(&itl, buff, bufc, '#');
00064     DESC_ITER_CONN(d)
00065     {
00066         if (  !See_Hidden(player)
00067            && Hidden(d->player))
00068         {
00069             continue;
00070         }
00071 
00072         // printf format: printf("%d:%d", d->player, d->descriptor);
00073         //
00074         char *p = tmp;
00075         p += mux_ltoa(d->player, p);
00076         *p++ = ':';
00077         p += mux_ltoa(d->descriptor, p);
00078 
00079         size_t n = p - tmp;
00080         if (!ItemToList_AddStringLEN(&itl, n, tmp))
00081         {
00082             break;
00083         }
00084     }
00085     ItemToList_Final(&itl);
00086     free_sbuf(tmp);
00087 }

void make_ulist ( dbref  ,
char *  ,
char **  ,
bool   
)

Definition at line 2680 of file netcommon.cpp.

References DESC_ITER_CONN, Hidden, ItemToList_AddInteger(), ItemToList_Final(), ItemToList_Init(), make_port_ulist(), descriptor_data::player, and See_Hidden.

Referenced by FUNCTION().

02681 {
02682     DESC *d;
02683     if (bPorts)
02684     {
02685         make_port_ulist(player, buff, bufc);
02686     }
02687     else
02688     {
02689         ITL pContext;
02690         ItemToList_Init(&pContext, buff, bufc, '#');
02691         DESC_ITER_CONN(d)
02692         {
02693             if (  !See_Hidden(player)
02694                && Hidden(d->player))
02695             {
02696                 continue;
02697             }
02698             if (!ItemToList_AddInteger(&pContext, d->player))
02699             {
02700                 break;
02701             }
02702         }
02703         ItemToList_Final(&pContext);
02704     }
02705 }

void process_output ( void *  ,
int   
)

Definition at line 2493 of file bsd.cpp.

References statedata::debug_cmd, descriptor_data::descriptor, text_block::hdr, IS_SOCKET_ERROR, MEMFREE, mudstate, text_block_hdr::nchars, text_block_hdr::nxt, descriptor_data::output_head, descriptor_data::output_size, descriptor_data::output_tail, R_SOCKDIED, shutdownsock(), SOCKET_EWOULDBLOCK, SOCKET_LAST_ERROR, SOCKET_WRITE, and text_block_hdr::start.

Referenced by main(), queue_write_LEN(), raw_broadcast(), shovechars(), shutdownsock(), and SiteMonSend().

02494 {
02495     DESC *d = (DESC *)dvoid;
02496 
02497     char *cmdsave = mudstate.debug_cmd;
02498     mudstate.debug_cmd = "< process_output >";
02499 
02500     TBLOCK *tb = d->output_head;
02501     while (tb != NULL)
02502     {
02503         while (tb->hdr.nchars > 0)
02504         {
02505             int cnt = SOCKET_WRITE(d->descriptor, tb->hdr.start, tb->hdr.nchars, 0);
02506             if (IS_SOCKET_ERROR(cnt))
02507             {
02508                 int iSocketError = SOCKET_LAST_ERROR;
02509                 mudstate.debug_cmd = cmdsave;
02510                 if (  iSocketError != SOCKET_EWOULDBLOCK
02511 #ifdef SOCKET_EAGAIN
02512                    && iSocketError != SOCKET_EAGAIN
02513 #endif // SOCKET_EAGAIN
02514                    && bHandleShutdown)
02515                 {
02516                     shutdownsock(d, R_SOCKDIED);
02517                 }
02518                 return;
02519             }
02520             d->output_size -= cnt;
02521             tb->hdr.nchars -= cnt;
02522             tb->hdr.start += cnt;
02523         }
02524         TBLOCK *save = tb;
02525         tb = tb->hdr.nxt;
02526         MEMFREE(save);
02527         save = NULL;
02528         d->output_head = tb;
02529         if (tb == NULL)
02530         {
02531             d->output_tail = NULL;
02532         }
02533     }
02534 
02535     mudstate.debug_cmd = cmdsave;
02536 }

void queue_string ( DESC ,
const char *   
)

Definition at line 431 of file netcommon.cpp.

References Ansi, DS_CONNECTED, encode_iac(), ESC_CHAR, descriptor_data::flags, NoAccents, NoBleed, normal_to_white(), descriptor_data::player, queue_write(), strip_accents(), and strip_ansi().

Referenced by boot_by_port(), boot_off(), close_sockets(), CGuests::Create(), do_command(), do_logged_out_internal(), do_prog(), dump_info(), dump_users(), failconn(), handle_prog(), process_input_helper(), raw_broadcast(), raw_notify(), raw_notify_html(), and SiteMonSend().

00432 {
00433     const char *p = s;
00434 
00435     if (d->flags & DS_CONNECTED)
00436     {
00437         if (  !Ansi(d->player)
00438            && strchr(s, ESC_CHAR))
00439         {
00440             p = strip_ansi(p);
00441         }
00442         else if (NoBleed(d->player))
00443         {
00444             p = normal_to_white(p);
00445         }
00446 
00447         if (NoAccents(d->player))
00448         {
00449             p = strip_accents(p);
00450         }
00451     }
00452     else
00453     {
00454         if (strchr(s, ESC_CHAR))
00455         {
00456             p = strip_ansi(p);
00457         }
00458         p = strip_accents(p);
00459     }
00460     p = encode_iac(p);
00461     queue_write(d, p);
00462 }

void queue_write ( DESC ,
const char *   
)

Definition at line 380 of file netcommon.cpp.

References queue_write_LEN().

Referenced by check_connect(), check_idle(), do_command(), dump_info(), dump_users(), and queue_string().

00381 {
00382     queue_write_LEN(d, b, strlen(b));
00383 }

void queue_write_LEN ( DESC ,
const char *  ,
int   
)

Definition at line 320 of file netcommon.cpp.

References add_to_output_queue(), descriptor_data::addr, alloc_lbuf, descriptor_data::descriptor, DS_CONNECTED, ENDLOG, descriptor_data::flags, free_lbuf, text_block::hdr, left, log_name(), LOG_NET, LOG_PROBLEMS, log_text(), MEMFREE, mudconf, text_block_hdr::nchars, text_block_hdr::nxt, descriptor_data::output_head, confdata::output_limit, descriptor_data::output_lost, descriptor_data::output_size, descriptor_data::output_tail, descriptor_data::output_tot, descriptor_data::player, process_output(), and STARTLOG.

Referenced by boot_by_port(), boot_off(), check_connect(), check_idle(), close_sockets(), do_command(), do_logged_out_internal(), do_prog(), dump_users(), failconn(), fcache_dump(), handle_prog(), queue_write(), raw_broadcast(), raw_notify(), raw_notify_newline(), SendDo(), SendDont(), SendWill(), SendWont(), and SiteMonSend().

00321 {
00322     if (n <= 0)
00323     {
00324         return;
00325     }
00326 
00327     if (d->output_size + n > mudconf.output_limit)
00328     {
00329         process_output(d, false);
00330     }
00331 
00332     int left = mudconf.output_limit - d->output_size - n;
00333     if (left < 0)
00334     {
00335         TBLOCK *tp = d->output_head;
00336         if (tp == NULL)
00337         {
00338             STARTLOG(LOG_PROBLEMS, "QUE", "WRITE");
00339             log_text("Flushing when output_head is null!");
00340             ENDLOG;
00341         }
00342         else
00343         {
00344             STARTLOG(LOG_NET, "NET", "WRITE");
00345             char *buf = alloc_lbuf("queue_write.LOG");
00346             sprintf(buf, "[%u/%s] Output buffer overflow, %d chars discarded by ", d->descriptor, d->addr, tp->hdr.nchars);
00347             log_text(buf);
00348             free_lbuf(buf);
00349             if (d->flags & DS_CONNECTED)
00350             {
00351                 log_name(d->player);
00352             }
00353             ENDLOG;
00354             d->output_size -= tp->hdr.nchars;
00355             d->output_head = tp->hdr.nxt;
00356             d->output_lost += tp->hdr.nchars;
00357             if (d->output_head == NULL)
00358             {
00359                 d->output_tail = NULL;
00360             }
00361             MEMFREE(tp);
00362             tp = NULL;
00363         }
00364     }
00365 
00366     add_to_output_queue(d, b, n);
00367     d->output_size += n;
00368     d->output_tot += n;
00369 
00370 #ifdef WIN32
00371     if (  platform == VER_PLATFORM_WIN32_NT
00372        && !d->bWritePending
00373        && !d->bConnectionDropped)
00374     {
00375         d->bCallProcessOutputLater = true;
00376     }
00377 #endif
00378 }

void raw_notify ( dbref  ,
const char *   
)

Definition at line 156 of file netcommon.cpp.

References Connected, DESC_ITER_PLAYER, statedata::inpipe, mudstate, statedata::poutbufc, statedata::poutnew, statedata::poutobj, queue_string(), queue_write_LEN(), and safe_str.

Referenced by announce_connect(), do_addcom(), do_allcom(), do_cemit(), do_chanlist(), do_channelwho(), do_chboot(), do_cheader(), do_chopen(), do_clearcom(), do_comconnectchannel(), do_comlast(), do_comlist(), do_comtitle(), do_comwho(), do_comwho_line(), do_createchannel(), do_delcom(), do_delcomchannel(), do_destroychannel(), do_editchannel(), do_joinchannel(), do_leavechannel(), do_listchannels(), do_processcom(), list_attrtable(), list_costs(), list_db_stats(), list_df_flags(), list_hashstat(), list_hashstats(), list_options(), list_process(), list_vattrs(), notify_check(), and report_timecheck().

00157 {
00158     DESC *d;
00159 
00160     if (!msg || !*msg)
00161     {
00162         return;
00163     }
00164 
00165     if (  mudstate.inpipe
00166        && player == mudstate.poutobj)
00167     {
00168         safe_str(msg, mudstate.poutnew, &mudstate.poutbufc);
00169         safe_str("\r\n", mudstate.poutnew, &mudstate.poutbufc);
00170         return;
00171     }
00172 
00173     if (!Connected(player))
00174     {
00175         return;
00176     }
00177 
00178     DESC_ITER_PLAYER(player, d)
00179     {
00180         queue_string(d, msg);
00181         queue_write_LEN(d, "\r\n", 2);
00182     }
00183 }

void raw_notify_newline ( dbref   ) 

Definition at line 185 of file netcommon.cpp.

References Connected, DESC_ITER_PLAYER, statedata::inpipe, mudstate, statedata::poutbufc, statedata::poutnew, statedata::poutobj, queue_write_LEN(), and safe_str.

Referenced by show_a_desc().

00186 {
00187     if (  mudstate.inpipe
00188        && player == mudstate.poutobj)
00189     {
00190         safe_str("\r\n", mudstate.poutnew, &mudstate.poutbufc);
00191         return;
00192     }
00193     if (!Connected(player))
00194     {
00195         return;
00196     }
00197 
00198     DESC *d;
00199     DESC_ITER_PLAYER(player, d)
00200     {
00201         queue_write_LEN(d, "\r\n", 2);
00202     }
00203 }

void record_login ( dbref  ,
bool  ,
char *  ,
char *  ,
char *  ,
char *   
)

Definition at line 125 of file player.cpp.

References A_LASTIP, A_LASTSITE, A_LOGINDATA, atr_add_raw(), atr_get, logindata::bad, decrypt_logindata(), hostdtm::dtm, encrypt_logindata(), free_lbuf, logindata::good, hostdtm::host, logindata::new_bad, notify, NUM_BAD, NUM_GOOD, logindata::tot_bad, logindata::tot_good, and tprintf().

Referenced by announce_connect(), and connect_player().

00133 {
00134     LDATA login_info;
00135     dbref aowner;
00136     int aflags, i;
00137 
00138     char *atrbuf = atr_get(player, A_LOGINDATA, &aowner, &aflags);
00139     decrypt_logindata(atrbuf, &login_info);
00140     if (isgood)
00141     {
00142         if (login_info.new_bad > 0)
00143         {
00144             notify(player, "");
00145             notify(player, tprintf("**** %d failed connect%s since your last successful connect. ****",
00146                 login_info.new_bad, (login_info.new_bad == 1 ? "" : "s")));
00147             notify(player, tprintf("Most recent attempt was from %s on %s.",
00148                 login_info.bad[0].host, login_info.bad[0].dtm));
00149             notify(player, "");
00150             login_info.new_bad = 0;
00151         }
00152         if (  login_info.good[0].host
00153            && *login_info.good[0].host
00154            && login_info.good[0].dtm
00155            && *login_info.good[0].dtm)
00156         {
00157             notify(player, tprintf("Last connect was from %s on %s.",
00158                 login_info.good[0].host, login_info.good[0].dtm));
00159         }
00160 
00161         for (i = NUM_GOOD - 1; i > 0; i--)
00162         {
00163             login_info.good[i].dtm = login_info.good[i - 1].dtm;
00164             login_info.good[i].host = login_info.good[i - 1].host;
00165         }
00166         login_info.good[0].dtm = ldate;
00167         login_info.good[0].host = lhost;
00168         login_info.tot_good++;
00169         if (*lusername)
00170         {
00171             atr_add_raw(player, A_LASTSITE, tprintf("%s@%s", lusername, lhost));
00172         }
00173         else
00174         {
00175             atr_add_raw(player, A_LASTSITE, lhost);
00176         }
00177 
00178         // Add the players last IP too.
00179         //
00180         atr_add_raw(player, A_LASTIP, lipaddr);
00181     }
00182     else
00183     {
00184         for (i = NUM_BAD - 1; i > 0; i--)
00185         {
00186             login_info.bad[i].dtm = login_info.bad[i - 1].dtm;
00187             login_info.bad[i].host = login_info.bad[i - 1].host;
00188         }
00189         login_info.bad[0].dtm = ldate;
00190         login_info.bad[0].host = lhost;
00191         login_info.tot_bad++;
00192         login_info.new_bad++;
00193     }
00194     encrypt_logindata(atrbuf, &login_info);
00195     atr_add_raw(player, A_LOGINDATA, atrbuf);
00196     free_lbuf(atrbuf);
00197 }

void save_command ( DESC ,
CBLK  
)

Definition at line 577 of file netcommon.cpp.

References CScheduler::DeferImmediateTask(), cmd_block::hdr, descriptor_data::input_head, descriptor_data::input_tail, cmd_block_hdr::nxt, PRIORITY_SYSTEM, scheduler, and Task_ProcessCommand().

Referenced by process_input_helper().

00578 {
00579     command->hdr.nxt = NULL;
00580     if (d->input_tail == NULL)
00581     {
00582         d->input_head = command;
00583 
00584         // We have added our first command to an empty list. Go process it later.
00585         //
00586         scheduler.DeferImmediateTask(PRIORITY_SYSTEM, Task_ProcessCommand, d, 0);
00587     }
00588     else
00589     {
00590         d->input_tail->hdr.nxt = command;
00591     }
00592     d->input_tail = command;
00593 }

void set_signals ( void   ) 

Definition at line 4015 of file bsd.cpp.

References CAST_SIGNAL_FUNC, and sighandler().

Referenced by main().

04016 {
04017 #ifndef WIN32
04018     sigset_t sigs;
04019 
04020     // We have to reset our signal mask, because of the possibility
04021     // that we triggered a restart on a SIGUSR1. If we did so, then
04022     // the signal became blocked, and stays blocked, since control
04023     // never returns to the caller; i.e., further attempts to send
04024     // a SIGUSR1 would fail.
04025     //
04026 #undef sigfillset
04027 #undef sigprocmask
04028     sigfillset(&sigs);
04029     sigprocmask(SIG_UNBLOCK, &sigs, NULL);
04030 #endif // !WIN32
04031 
04032     signal(SIGINT,  CAST_SIGNAL_FUNC sighandler);
04033     signal(SIGTERM, CAST_SIGNAL_FUNC sighandler);
04034     signal(SIGILL,  CAST_SIGNAL_FUNC sighandler);
04035     signal(SIGSEGV, CAST_SIGNAL_FUNC sighandler);
04036     signal(SIGABRT, CAST_SIGNAL_FUNC sighandler);
04037     signal(SIGFPE,  SIG_IGN);
04038 
04039 #ifndef WIN32
04040     signal(SIGCHLD, CAST_SIGNAL_FUNC sighandler);
04041     signal(SIGHUP,  CAST_SIGNAL_FUNC sighandler);
04042     signal(SIGQUIT, CAST_SIGNAL_FUNC sighandler);
04043     signal(SIGPIPE, SIG_IGN);
04044     signal(SIGUSR1, CAST_SIGNAL_FUNC sighandler);
04045     signal(SIGUSR2, CAST_SIGNAL_FUNC sighandler);
04046     signal(SIGTRAP, CAST_SIGNAL_FUNC sighandler);
04047     signal(SIGILL,  CAST_SIGNAL_FUNC sighandler);
04048 #ifdef HAVE_SETITIMER
04049     signal(SIGPROF,  CAST_SIGNAL_FUNC sighandler);
04050 #endif
04051 
04052 #ifdef SIGXCPU
04053     signal(SIGXCPU, CAST_SIGNAL_FUNC sighandler);
04054 #endif // SIGXCPU
04055 #ifdef SIGFSZ
04056     signal(SIGXFSZ, CAST_SIGNAL_FUNC sighandler);
04057 #endif // SIGFSZ
04058 #ifdef SIGEMT
04059     signal(SIGEMT, CAST_SIGNAL_FUNC sighandler);
04060 #endif // SIGEMT
04061 #ifdef SIGBUS
04062     signal(SIGBUS, CAST_SIGNAL_FUNC sighandler);
04063 #endif // SIGBUS
04064 #ifdef SIGSYS
04065     signal(SIGSYS, CAST_SIGNAL_FUNC sighandler);
04066 #endif // SIGSYS
04067 #endif // !WIN32
04068 }

void SetupPorts ( int *  pnPorts,
PortInfo  aPorts[],
IntArray pia 
)

Definition at line 1039 of file bsd.cpp.

References DebugTotalSockets, INVALID_SOCKET, tag_int_array::n, tag_int_array::pi, PortInfo::port, PortInfo::socket, and SOCKET_CLOSE.

Referenced by main().

01040 {
01041     // Any existing open port which does not appear in the requested set
01042     // should be closed.
01043     //
01044     int i, j, k;
01045     bool bFound;
01046     for (i = 0; i < *pnPorts; i++)
01047     {
01048         bFound = false;
01049         for (j = 0; j < pia->n; j++)
01050         {
01051             if (aPorts[i].port == pia->pi[j])
01052             {
01053                 bFound = true;
01054                 break;
01055             }
01056         }
01057         if (!bFound)
01058         {
01059             if (SOCKET_CLOSE(aPorts[i].socket) == 0)
01060             {
01061                 DebugTotalSockets--;
01062                 (*pnPorts)--;
01063                 k = *pnPorts;
01064                 if (i != k)
01065                 {
01066                     aPorts[i] = aPorts[k];
01067                 }
01068                 aPorts[k].port = 0;
01069                 aPorts[k].socket = INVALID_SOCKET;
01070             }
01071         }
01072     }
01073 
01074     // Any requested port which does not appear in the existing open set
01075     // of ports should be opened.
01076     //
01077     for (j = 0; j < pia->n; j++)
01078     {
01079         bFound = false;
01080         for (i = 0; i < *pnPorts; i++)
01081         {
01082             if (aPorts[i].port == pia->pi[j])
01083             {
01084                 bFound = true;
01085                 break;
01086             }
01087         }
01088         if (!bFound)
01089         {
01090             k = *pnPorts;
01091             (*pnPorts)++;
01092             aPorts[k].port = pia->pi[j];
01093             make_socket(aPorts+k);
01094         }
01095     }
01096 
01097 #ifndef WIN32
01098     for (i = 0; i < *pnPorts; i++)
01099     {
01100         if (maxd <= aPorts[i].socket)
01101         {
01102             maxd = aPorts[i].socket + 1;
01103         }
01104     }
01105 #endif
01106 }

void shovechars ( int  nPorts,
PortInfo  aPorts[] 
)

Definition at line 1417 of file bsd.cpp.

References boot_slave(), CheckInput, CheckOutput, d1, DARK, db, statedata::debug_cmd, DESC_ITER_ALL, DESC_ITER_PLAYER, DESC_SAFEITER_ALL, descriptor_data::descriptor, DS_AUTODARK, ENDLOG, FLAG_WORD1, descriptor_data::flags, object::fs, get_slave_result(), CLinearTimeAbsolute::GetUTC(), GOD, IS_INVALID_SOCKET, IS_SOCKET_ERROR, log_number(), log_perror(), LOG_PROBLEMS, log_text(), maxd, mudstate, ndescriptors, new_connection(), process_input(), process_output(), R_SOCKDIED, CScheduler::RunTasks(), scheduler, statedata::shutdown_flag, shutdownsock(), slave_socket, SOCKET_EBADF, SOCKET_EINTR, SOCKET_LAST_ERROR, STARTLOG, time_30m, update_quotas(), ValidSocket(), CScheduler::WhenNext(), and flagset::word.

Referenced by main().

01418 {
01419     fd_set input_set, output_set;
01420     int found;
01421     DESC *d, *dnext, *newd;
01422     unsigned int avail_descriptors;
01423     int maxfds;
01424     int i;
01425 
01426 #define CheckInput(x)     FD_ISSET(x, &input_set)
01427 #define CheckOutput(x)    FD_ISSET(x, &output_set)
01428 
01429     mudstate.debug_cmd = "< shovechars >";
01430 
01431     CLinearTimeAbsolute ltaLastSlice;
01432     ltaLastSlice.GetUTC();
01433 
01434 #ifdef HAVE_GETDTABLESIZE
01435     maxfds = getdtablesize();
01436 #else // HAVE_GETDTABLESIZE
01437     maxfds = sysconf(_SC_OPEN_MAX);
01438 #endif // HAVE_GETDTABLESIZE
01439 
01440     avail_descriptors = maxfds - 7;
01441 
01442     while (mudstate.shutdown_flag == 0)
01443     {
01444         CLinearTimeAbsolute ltaCurrent;
01445         ltaCurrent.GetUTC();
01446         update_quotas(ltaLastSlice, ltaCurrent);
01447 
01448         // Check the scheduler.
01449         //
01450         scheduler.RunTasks(ltaCurrent);
01451         CLinearTimeAbsolute ltaWakeUp;
01452         if (scheduler.WhenNext(&ltaWakeUp))
01453         {
01454             if (ltaWakeUp < ltaCurrent)
01455             {
01456                 ltaWakeUp = ltaCurrent;
01457             }
01458         }
01459         else
01460         {
01461             CLinearTimeDelta ltd = time_30m;
01462             ltaWakeUp = ltaCurrent + ltd;
01463         }
01464 
01465         if (mudstate.shutdown_flag)
01466         {
01467             break;
01468         }
01469 
01470         FD_ZERO(&input_set);
01471         FD_ZERO(&output_set);
01472 
01473         // Listen for new connections if there are free descriptors.
01474         //
01475         if (ndescriptors < avail_descriptors)
01476         {
01477             for (i = 0; i < nPorts; i++)
01478             {
01479                 FD_SET(aPorts[i].socket, &input_set);
01480             }
01481         }
01482 
01483         // Listen for replies from the slave socket.
01484         //
01485         if (!IS_INVALID_SOCKET(slave_socket))
01486         {
01487             FD_SET(slave_socket, &input_set);
01488         }
01489 
01490 #ifdef QUERY_SLAVE
01491         // Listen for replies from the sqlslave socket.
01492         //
01493         if (!IS_INVALID_SOCKET(sqlslave_socket))
01494         {
01495             FD_SET(sqlslave_socket, &input_set);
01496         }
01497 #endif // QUERY_SLAVE
01498 
01499         // Mark sockets that we want to test for change in status.
01500         //
01501         DESC_ITER_ALL(d)
01502         {
01503             if (!d->input_head)
01504             {
01505                 FD_SET(d->descriptor, &input_set);
01506             }
01507             if (d->output_head)
01508             {
01509                 FD_SET(d->descriptor, &output_set);
01510             }
01511         }
01512 
01513         // Wait for something to happen.
01514         //
01515         struct timeval timeout;
01516         CLinearTimeDelta ltdTimeout = ltaWakeUp - ltaCurrent;
01517         ltdTimeout.ReturnTimeValueStruct(&timeout);
01518         found = select(maxd, &input_set, &output_set, (fd_set *) NULL,
01519                    &timeout);
01520 
01521         if (IS_SOCKET_ERROR(found))
01522         {
01523             int iSocketError = SOCKET_LAST_ERROR;
01524             if (iSocketError == SOCKET_EBADF)
01525             {
01526                 // This one is bad, as it results in a spiral of
01527                 // doom, unless we can figure out what the bad file
01528                 // descriptor is and get rid of it.
01529                 //
01530                 log_perror("NET", "FAIL", "checking for activity", "select");
01531 
01532                 // Search for a bad socket amoungst the players.
01533                 //
01534                 DESC_ITER_ALL(d)
01535                 {
01536                     if (!ValidSocket(d->descriptor))
01537                     {
01538                         STARTLOG(LOG_PROBLEMS, "ERR", "EBADF");
01539                         log_text("Bad descriptor ");
01540                         log_number(d->descriptor);
01541                         ENDLOG;
01542                         shutdownsock(d, R_SOCKDIED);
01543                     }
01544                 }
01545                 if (  !IS_INVALID_SOCKET(slave_socket)
01546                    && !ValidSocket(slave_socket))
01547                 {
01548                     // Try to restart the slave, since it presumably
01549                     // died.
01550                     //
01551                     STARTLOG(LOG_PROBLEMS, "ERR", "EBADF");
01552                     log_text("Bad slave descriptor ");
01553                     log_number(slave_socket);
01554                     ENDLOG;
01555                     boot_slave(GOD, GOD, GOD, 0);
01556                 }
01557 
01558 #ifdef QUERY_SLAVE
01559                 if (  !IS_INVALID_SOCKET(sqlslave_socket)
01560                    && !ValidSocket(sqlslave_socket))
01561                 {
01562                     CleanUpSQLSlaveSocket();
01563                 }
01564 #endif // QUERY_SLAVE
01565 
01566                 for (i = 0; i < nPorts; i++)
01567                 {
01568                     if (!ValidSocket(aPorts[i].socket))
01569                     {
01570                         // That's it. Game over.
01571                         //
01572                         STARTLOG(LOG_PROBLEMS, "ERR", "EBADF");
01573                         log_text("Bad game port descriptor ");
01574                         log_number(aPorts[i].socket);
01575                         ENDLOG;
01576                         return;
01577                     }
01578                 }
01579             }
01580             else if (iSocketError != SOCKET_EINTR)
01581             {
01582                 log_perror("NET", "FAIL", "checking for activity", "select");
01583             }
01584             continue;
01585         }
01586 
01587         // Get usernames and hostnames.
01588         //
01589         if (  !IS_INVALID_SOCKET(slave_socket)
01590            && CheckInput(slave_socket))
01591         {
01592             while (get_slave_result() == 0)
01593             {
01594                 ; // Nothing.
01595             }
01596         }
01597 
01598 #ifdef QUERY_SLAVE
01599         // Get result sets from sqlslave.
01600         //
01601         if (  !IS_INVALID_SOCKET(sqlslave_socket)
01602            && CheckInput(sqlslave_socket))
01603         {
01604             while (get_sqlslave_result() == 0)
01605             {
01606                 ; // Nothing.
01607             }
01608         }
01609 #endif // QUERY_SLAVE
01610 
01611         // Check for new connection requests.
01612         //
01613         for (i = 0; i < nPorts; i++)
01614         {
01615             if (CheckInput(aPorts[i].socket))
01616             {
01617                 int iSocketError;
01618                 newd = new_connection(aPorts+i, &iSocketError);
01619                 if (!newd)
01620                 {
01621                     if (  iSocketError
01622                        && iSocketError != SOCKET_EINTR)
01623                     {
01624                         log_perror("NET", "FAIL", NULL, "new_connection");
01625                     }
01626                 }
01627                 else if (maxd <= newd->descriptor)
01628                 {
01629                     maxd = newd->descriptor + 1;
01630                 }
01631             }
01632         }
01633 
01634         // Check for activity on user sockets.
01635         //
01636         DESC_SAFEITER_ALL(d, dnext)
01637         {
01638             // Process input from sockets with pending input.
01639             //
01640             if (CheckInput(d->descriptor))
01641             {
01642                 // Undo autodark
01643                 //
01644                 if (d->flags & DS_AUTODARK)
01645                 {
01646                     // Clear the DS_AUTODARK on every related session.
01647                     //
01648                     DESC *d1;
01649                     DESC_ITER_PLAYER(d->player, d1)
01650                     {
01651                         d1->flags &= ~DS_AUTODARK;
01652                     }
01653                     db[d->player].fs.word[FLAG_WORD1] &= ~DARK;
01654                 }
01655 
01656                 // Process received data.
01657                 //
01658                 if (!process_input(d))
01659                 {
01660                     shutdownsock(d, R_SOCKDIED);
01661                     continue;
01662                 }
01663             }
01664 
01665             // Process output for sockets with pending output.
01666             //
01667             if (CheckOutput(d->descriptor))
01668             {
01669                 process_output(d, true);
01670             }
01671         }
01672     }
01673 }

void shutdownsock ( DESC ,
int   
)

Definition at line 1843 of file bsd.cpp.

References A_PROGCMD, A_REASON, statedata::access_list, descriptor_data::addr, descriptor_data::address, alloc_lbuf, alloc_mbuf, announce_disconnect(), atr_add_raw(), atr_clr(), CIF_LASTCONNECT, CIF_LONGESTCONNECT, CIF_NUMCONNECTS, CIF_TOTALTIME, clearstrings(), descriptor_data::command_count, descriptor_data::connected_at, db, decode_flags(), DESC_ITER_PLAYER, descriptor_data::descriptor, DS_CONNECTED, ENDLOG, FC_QUIT, fcache_dump(), fetch_ConnectionInfoFields(), find_oldest(), descriptor_data::flags, free_lbuf, free_mbuf, free_sbuf, CLinearTimeAbsolute::GetUTC(), GOD, H_FORBIDDEN, Location, LOG_ACCOUNTING, LOG_LOGIN, log_name(), LOG_NET, LOG_SECURITY, log_text(), MAX_GLOBAL_REGS, MEMFREE, mudstate, Name, Pennies(), descriptor_data::player, process_output(), descriptor_data::program_data, put_ConnectionInfoFields(), R_LOGOUT, R_QUIT, CLinearTimeDelta::ReturnSeconds(), site_check(), SiteMonSend(), STARTLOG, and prog_data::wait_regs.

Referenced by boot_by_port(), boot_off(), check_connect(), check_idle(), close_sockets(), do_logged_out_internal(), failconn(), load_restart_db(), process_output(), and shovechars().

01844 {
01845     char *buff, *buff2;
01846     int i, num;
01847     DESC *dtemp;
01848 
01849     if (  (reason == R_LOGOUT)
01850        && (site_check((d->address).sin_addr, mudstate.access_list) == H_FORBIDDEN))
01851     {
01852         reason = R_QUIT;
01853     }
01854 
01855     CLinearTimeAbsolute ltaNow;
01856     ltaNow.GetUTC();
01857 
01858     if (d->flags & DS_CONNECTED)
01859     {
01860         // Added by D.Piper (del@doofer.org) 1997 & 2000-APR
01861         //
01862 
01863         // Reason: attribute (disconnect reason)
01864         //
01865         atr_add_raw(d->player, A_REASON, (char *)disc_messages[reason]);
01866 
01867         // Update the A_CONNINFO attribute.
01868         //
01869         long anFields[4];
01870         fetch_ConnectionInfoFields(d->player, anFields);
01871 
01872         // One of the active sessions is going away. It doesn't matter which
01873         // one.
01874         //
01875         anFields[CIF_NUMCONNECTS]++;
01876 
01877         // What are the two longest sessions?
01878         //
01879         DESC *dOldest[2];
01880         find_oldest(d->player, dOldest);
01881 
01882         CLinearTimeDelta ltdFull;
01883         ltdFull = ltaNow - dOldest[0]->connected_at;
01884         long tFull = ltdFull.ReturnSeconds();
01885         if (dOldest[0] == d)
01886         {
01887             // We are dropping the oldest connection.
01888             //
01889             CLinearTimeDelta ltdPart;
01890             if (dOldest[1])
01891             {
01892                 // There is another (more recently made) connection.
01893                 //
01894                 ltdPart = dOldest[1]->connected_at - dOldest[0]->connected_at;
01895             }
01896             else
01897             {
01898                 // There is only one connection.
01899                 //
01900                 ltdPart = ltdFull;
01901             }
01902             long tPart = ltdPart.ReturnSeconds();
01903 
01904             anFields[CIF_TOTALTIME] += tPart;
01905             if (anFields[CIF_LONGESTCONNECT] < tFull)
01906             {
01907                 anFields[CIF_LONGESTCONNECT] = tFull;
01908             }
01909         }
01910         anFields[CIF_LASTCONNECT] = tFull;
01911 
01912         put_ConnectionInfoFields(d->player, anFields, ltaNow);
01913 
01914         // If we are doing a LOGOUT, keep the connection open so that the
01915         // player can connect to a different character. Otherwise, we
01916         // do the normal disconnect stuff.
01917         //
01918         if (reason == R_LOGOUT)
01919         {
01920             STARTLOG(LOG_NET | LOG_LOGIN, "NET", "LOGO")
01921             buff = alloc_mbuf("shutdownsock.LOG.logout");
01922             sprintf(buff, "[%u/%s] Logout by ", d->descriptor, d->addr);
01923             log_text(buff);
01924             log_name(d->player);
01925             sprintf(buff, " <Reason: %s>", disc_reasons[reason]);
01926             log_text(buff);
01927             free_mbuf(buff);
01928             ENDLOG;
01929         }
01930         else
01931         {
01932             fcache_dump(d, FC_QUIT);
01933             STARTLOG(LOG_NET | LOG_LOGIN, "NET", "DISC")
01934             buff = alloc_mbuf("shutdownsock.LOG.disconn");
01935             sprintf(buff, "[%u/%s] Logout by ", d->descriptor, d->addr);
01936             log_text(buff);
01937             log_name(d->player);
01938             sprintf(buff, " <Reason: %s>", disc_reasons[reason]);
01939             log_text(buff);
01940             free_mbuf(buff);
01941             ENDLOG;
01942             SiteMonSend(d->descriptor, d->addr, d, "Disconnection");
01943         }
01944 
01945         // If requested, write an accounting record of the form:
01946         // Plyr# Flags Cmds ConnTime Loc Money [Site] <DiscRsn> Name
01947         //
01948         STARTLOG(LOG_ACCOUNTING, "DIS", "ACCT");
01949         CLinearTimeDelta ltd = ltaNow - d->connected_at;
01950         int Seconds = ltd.ReturnSeconds();
01951         buff = alloc_lbuf("shutdownsock.LOG.accnt");
01952         buff2 = decode_flags(GOD, &(db[d->player].fs));
01953         sprintf(buff, "%d %s %d %d %d %d [%s] <%s> %s", d->player, buff2, d->command_count,
01954                 Seconds, Location(d->player), Pennies(d->player), d->addr, disc_reasons[reason],
01955                 Name(d->player));
01956         log_text(buff);
01957         free_lbuf(buff);
01958         free_sbuf(buff2);
01959         ENDLOG;
01960         announce_disconnect(d->player, d, disc_messages[reason]);
01961     }
01962     else
01963     {
01964         if (reason == R_LOGOUT)
01965         {
01966             reason = R_QUIT;
01967         }
01968         STARTLOG(LOG_SECURITY | LOG_NET, "NET", "DISC");
01969         buff = alloc_mbuf("shutdownsock.LOG.neverconn");
01970         sprintf(buff, "[%u/%s] Connection closed, never connected. <Reason: %s>", d->descriptor, d->addr, disc_reasons[reason]);
01971         log_text(buff);
01972         free_mbuf(buff);
01973         ENDLOG;
01974         SiteMonSend(d->descriptor, d->addr, d, "N/C Connection Closed");
01975     }
01976 
01977     process_output(d, false);
01978     clearstrings(d);
01979 
01980     d->flags &= ~DS_CONNECTED;
01981 
01982     // Is this desc still in interactive mode?
01983     //
01984     if (d->program_data != NULL)
01985     {
01986         num = 0;
01987         DESC_ITER_PLAYER(d->player, dtemp) num++;
01988 
01989         if (num == 0)
01990         {
01991             for (i = 0; i < MAX_GLOBAL_REGS; i++)
01992             {
01993                 if (d->program_data->wait_regs[i])
01994                 {
01995                     free_lbuf(d->program_data->wait_regs[i]);
01996                     d->program_data->wait_regs[i] = NULL;
01997                 }
01998             }
01999             MEMFREE(d->program_data);
02000             atr_clr(d->player, A_PROGCMD);
02001         }
02002         d->program_data = NULL;
02003     }
02004     if (reason == R_LOGOUT)
02005     {
02006         d->connected_at.GetUTC();
02007         d->retries_left = mudconf.retry_limit;
02008         d->command_count = 0;
02009         d->timeout = mudconf.idle_timeout;
02010         d->player = 0;
02011         d->doing[0] = '\0';
02012         d->quota = mudconf.cmd_quota_max;
02013         d->last_time = d->connected_at;
02014         d->host_info = site_check((d->address).sin_addr, mudstate.access_list)
02015                      | site_check((d->address).sin_addr, mudstate.suspect_list);
02016         d->input_tot = d->input_size;
02017         d->output_tot = 0;
02018         welcome_user(d);
02019     }
02020     else
02021     {
02022         // Cancel any scheduled processing on this descriptor.
02023         //
02024         scheduler.CancelTask(Task_ProcessCommand, d, 0);
02025 
02026 #ifdef WIN32
02027         if (platform == VER_PLATFORM_WIN32_NT)
02028         {
02029             // Don't close down the socket twice.
02030             //
02031             if (!d->bConnectionShutdown)
02032             {
02033                 // Make sure we don't try to initiate or process any
02034                 // outstanding IOs
02035                 //
02036                 d->bConnectionShutdown = true;
02037 
02038                 // Protect removing the descriptor from our linked list from
02039                 // any interference from the listening thread.
02040                 //
02041                 EnterCriticalSection(&csDescriptorList);
02042                 *d->prev = d->next;
02043                 if (d->next)
02044                 {
02045                     d->next->prev = d->prev;
02046                 }
02047                 LeaveCriticalSection(&csDescriptorList);
02048 
02049                 // This descriptor may hang around awhile, clear out the links.
02050                 //
02051                 d->next = 0;
02052                 d->prev = 0;
02053 
02054                 // Close the connection in 5 seconds.
02055                 //
02056                 scheduler.DeferTask(ltaNow + FACTOR_100NS_PER_SECOND*5,
02057                     PRIORITY_SYSTEM, Task_DeferredClose, d, 0);
02058             }
02059             return;
02060         }
02061 #endif
02062 
02063         shutdown(d->descriptor, SD_BOTH);
02064         if (SOCKET_CLOSE(d->descriptor) == 0)
02065         {
02066             DebugTotalSockets--;
02067         }
02068         d->descriptor = INVALID_SOCKET;
02069 
02070         *d->prev = d->next;
02071         if (d->next)
02072         {
02073             d->next->prev = d->prev;
02074         }
02075 
02076         // This descriptor may hang around awhile, clear out the links.
02077         //
02078         d->next = 0;
02079         d->prev = 0;
02080 
02081         // If we don't have queued IOs, then we can free these, now.
02082         //
02083         freeqs(d);
02084         free_desc(d);
02085         ndescriptors--;
02086     }
02087 }

int site_check ( struct  in_addr,
SITE  
)

Definition at line 2570 of file netcommon.cpp.

References site_data::address, site_data::flag, site_data::mask, and site_data::next.

Referenced by initializesock(), new_connection(), and shutdownsock().

02571 {
02572     SITE *this0;
02573 
02574     for (this0 = site_list; this0; this0 = this0->next)
02575     {
02576         if ((host.s_addr & this0->mask.s_addr) == this0->address.s_addr)
02577         {
02578             return this0->flag;
02579         }
02580     }
02581     return 0;
02582 }

void Task_ProcessCommand ( void *  arg_voidptr,
int  arg_iInteger 
)

Definition at line 2517 of file netcommon.cpp.

References cmd_block::cmd, CScheduler::DeferImmediateTask(), CScheduler::DeferTask(), do_command(), free_lbuf, CLinearTimeAbsolute::GetUTC(), handle_prog(), cmd_block::hdr, mudconf, cmd_block_hdr::nxt, PRIORITY_SYSTEM, scheduler, Task_ProcessCommand(), confdata::timeslice, and UNUSED_PARAMETER.

Referenced by CallBack_ShowDispatches(), save_command(), and Task_ProcessCommand().

02518 {
02519     UNUSED_PARAMETER(arg_iInteger);
02520 
02521     DESC *d = (DESC *)arg_voidptr;
02522     if (d)
02523     {
02524         CBLK *t = d->input_head;
02525         if (t)
02526         {
02527             if (d->quota > 0)
02528             {
02529                 d->quota--;
02530                 d->input_head = (CBLK *) t->hdr.nxt;
02531                 if (d->input_head)
02532                 {
02533                     // There are still commands to process, so schedule another looksee.
02534                     //
02535                     scheduler.DeferImmediateTask(PRIORITY_SYSTEM, Task_ProcessCommand, d, 0);
02536                 }
02537                 else
02538                 {
02539                     d->input_tail = NULL;
02540                 }
02541                 d->input_size -= strlen(t->cmd);
02542                 d->last_time.GetUTC();
02543                 if (d->program_data != NULL)
02544                 {
02545                     handle_prog(d, t->cmd);
02546                 }
02547                 else
02548                 {
02549                     do_command(d, t->cmd);
02550                 }
02551                 free_lbuf(t);
02552             }
02553             else
02554             {
02555                 // Don't bother looking for more quota until at least this much time has past.
02556                 //
02557                 CLinearTimeAbsolute lsaWhen;
02558                 lsaWhen.GetUTC();
02559 
02560                 scheduler.DeferTask(lsaWhen + mudconf.timeslice, PRIORITY_SYSTEM, Task_ProcessCommand, d, 0);
02561             }
02562         }
02563     }
02564 }

const char* time_format_1 ( int  Seconds,
size_t  maxWidth 
)

Definition at line 7740 of file functions.cpp.

References div, specs, and tf1_case_table.

Referenced by dump_users().

07741 {
07742     if (Seconds < 0)
07743     {
07744         Seconds = 0;
07745     }
07746 
07747     if (  maxWidth < 8
07748        || 12 < maxWidth)
07749     {
07750         strcpy(TimeBuffer80, "???");
07751         return TimeBuffer80;
07752     }
07753     int iWidth = maxWidth - 8;
07754 
07755     int iCase = 0;
07756     while (  iCase < 3
07757           && tf1_width_table[iWidth][iCase] < Seconds)
07758     {
07759         iCase++;
07760     }
07761 
07762     int i, n[3];
07763     for (i = 0; i < 3; i++)
07764     {
07765         n[i] = Seconds / tf1_case_table[iCase].div[i];
07766         Seconds -= n[i] *tf1_case_table[iCase].div[i];
07767     }
07768     sprintf(TimeBuffer80, tf1_case_table[iCase].specs[iWidth], n[0], n[1], n[2]);
07769     return TimeBuffer80;
07770 }

const char* time_format_2 ( int  Seconds  ) 

Definition at line 7774 of file functions.cpp.

References GeneralTimeConversion(), ISECONDS, and IYEARS.

Referenced by dump_users(), and FUNCTION().

07775 {
07776     // 2^63/86400 is 1.07E14 which is at most 15 digits.
07777     // '(15)d\0' is at most 17 characters.
07778     //
07779     GeneralTimeConversion(TimeBuffer64, Seconds, IYEARS, ISECONDS, true, false);
07780     return TimeBuffer64;
07781 }

void update_quotas ( CLinearTimeAbsolute tLast,
const CLinearTimeAbsolute tCurrent 
)

Definition at line 93 of file netcommon.cpp.

References confdata::cmd_quota_incr, confdata::cmd_quota_max, DESC_ITER_ALL, mudconf, descriptor_data::quota, and confdata::timeslice.

Referenced by shovechars().

00094 {
00095     if (ltaCurrent < ltaLast)
00096     {
00097         ltaLast = ltaCurrent;
00098         return;
00099     }
00100 
00101     CLinearTimeDelta ltdDiff = ltaCurrent - ltaLast;
00102     if (ltdDiff < mudconf.timeslice)
00103     {
00104         return;
00105     }
00106 
00107     int nSlices = ltdDiff / mudconf.timeslice;
00108     int nExtraQuota = mudconf.cmd_quota_incr * nSlices;
00109 
00110     if (nExtraQuota > 0)
00111     {
00112         DESC *d;
00113         DESC_ITER_ALL(d)
00114         {
00115             d->quota += nExtraQuota;
00116             if (d->quota > mudconf.cmd_quota_max)
00117             {
00118                 d->quota = mudconf.cmd_quota_max;
00119             }
00120         }
00121     }
00122     ltaLast += mudconf.timeslice * nSlices;
00123 }

int UsState ( DESC d,
unsigned char  chOption 
)

Return our side's negotiation state.

The negotiation of each optional feature of telnet can be in one of six states (defined in interface.h): OPTION_NO, OPTION_YES, OPTION_WANTNO_EMPTY, OPTION_WANTNO_OPPOSITE, OPTION_WANTYES_EMPTY, and OPTION_WANTYES_OPPOSITE.

An option is only enabled when it is in the OPTION_YES state.

Parameters:
d Player connection context.
chOption Telnet Option
Returns:
One of six states.

Definition at line 2660 of file bsd.cpp.

References descriptor_data::nvt_eor_us_state, descriptor_data::nvt_naws_us_state, descriptor_data::nvt_sga_us_state, OPTION_NO, TELNET_EOR, TELNET_NAWS, and TELNET_SGA.

Referenced by DesiredUsOption(), do_prog(), handle_prog(), and process_input_helper().

02661 {
02662     if (TELNET_NAWS == chOption)
02663     {
02664         return d->nvt_naws_us_state;
02665     }
02666     else if (TELNET_EOR == chOption)
02667     {
02668         return d->nvt_eor_us_state;
02669     }
02670     else if (TELNET_SGA == chOption)
02671     {
02672         return d->nvt_sga_us_state;
02673     }
02674     return OPTION_NO;
02675 }

void welcome_user ( DESC  ) 

Definition at line 565 of file netcommon.cpp.

References FC_CONN, FC_CONN_REG, fcache_dump(), H_REGISTRATION, and descriptor_data::host_info.

Referenced by check_connect(), and new_connection().

00566 {
00567     if (d->host_info & H_REGISTRATION)
00568     {
00569         fcache_dump(d, FC_CONN_REG);
00570     }
00571     else
00572     {
00573         fcache_dump(d, FC_CONN);
00574     }
00575 }


Variable Documentation

DESC* descriptor_list

Definition at line 36 of file bsd.cpp.

Referenced by get_slave_result(), initializesock(), and load_restart_db().

NAMETAB logout_cmdtable[]

Definition at line 1889 of file netcommon.cpp.

Referenced by init_logout_cmdtab().


Generated on Mon May 28 04:40:19 2007 for MUX by  doxygen 1.4.7