src/interface.h File Reference

#include "copyright.h"
#include "db.h"
#include "htab.h"
#include "alloc.h"
#include "config.h"
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <event.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
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_MASK   0xff
#define CMD_NOxFIX   0x100
#define DOINGLEN   45
#define HUDKEYLEN   21
#define DS_CONNECTED   0x0001
#define DS_AUTODARK   0x0002
#define DS_IDENTIFIED   0x0008
#define DS_DEAD   0x10000000
#define DESC_ITER_PLAYER(p, d)   for (d=(DESC *)rb_find(mudstate.desctree, (void *)p);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_CONN(d, n)
#define DESC_SAFEITER_ALL(d, n)

Typedefs

typedef cmd_block CBLK
typedef prog_data PROG
typedef descriptor_data DESC

Functions

void emergency_shutdown (void)
void shutdownsock (DESC *, int)
void shovechars (int)
void set_signals (void)
timeval timeval_sub (struct timeval, struct timeval)
int msec_diff (struct timeval now, struct timeval then)
timeval msec_add (struct timeval, int)
timeval update_quotas (struct timeval, struct timeval)
void handle_http (DESC *, char *)
void raw_notify (dbref, const char *)
void raw_notify_raw (dbref, const char *, char *)
void raw_notify_newline (dbref)
void hudinfo_notify (DESC *, const char *, const char *, const char *)
void clearstrings (DESC *)
void queue_write (DESC *, char *, int)
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_off (dbref, char *)
int boot_by_port (int, int, char *)
int fetch_idle (dbref)
int fetch_connect (dbref)
void check_idle (void)
void process_commands (void)
int site_check (struct sockaddr_storage *, int, SITE *)
void make_ulist (dbref, char *, char **)
dbref find_connected_name (dbref, char *)

Variables

int shutdown_flag
NAMETAB logout_cmdtable []
DESCdescriptor_list


Define Documentation

#define CMD_DOING   3

Definition at line 46 of file interface.h.

Referenced by do_command(), and do_unauth_command().

#define CMD_LOGOUT   7

Definition at line 49 of file interface.h.

#define CMD_MASK   0xff

Definition at line 53 of file interface.h.

Referenced by do_command(), and do_unauth_command().

#define CMD_NOxFIX   0x100

Definition at line 54 of file interface.h.

Referenced by do_unauth_command().

#define CMD_PREFIX   5

Definition at line 47 of file interface.h.

Referenced by do_command(), and do_unauth_command().

#define CMD_PUEBLOCLIENT   9

Definition at line 51 of file interface.h.

#define CMD_QUIT   1

Definition at line 44 of file interface.h.

Referenced by do_command(), and do_unauth_command().

#define CMD_SESSION   8

Definition at line 50 of file interface.h.

Referenced by dump_users().

#define CMD_SUFFIX   6

Definition at line 48 of file interface.h.

Referenced by do_command(), and do_unauth_command().

#define CMD_WHO   2

Definition at line 45 of file interface.h.

Referenced by do_command(), do_unauth_command(), and dump_users().

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

Definition at line 172 of file interface.h.

Referenced by update_quotas().

#define DESC_ITER_CONN (  ) 

Value:

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

Definition at line 168 of file interface.h.

Referenced by announce_connect(), check_connect(), dump_users(), find_connected_name(), fun_doing(), load_restart_db(), load_restart_db_xdr(), make_portlist(), make_ulist(), and raw_broadcast().

#define DESC_ITER_PLAYER ( p,
 )     for (d=(DESC *)rb_find(mudstate.desctree, (void *)p);d;d=d->hashnext)

Definition at line 165 of file interface.h.

Referenced by announce_connect(), announce_disconnect(), check_connect(), desc_reload(), do_doing(), do_prog(), do_quitprog(), fcache_send(), fetch_connect(), fetch_idle(), handle_prog(), notify_printf(), raw_notify_newline(), raw_notify_raw(), and release_descriptor().

#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 187 of file interface.h.

Referenced by boot_by_port(), check_idle(), close_sockets(), eradicate_broken_fd(), and flush_sockets().

#define DESC_SAFEITER_CONN ( d,
 ) 

Value:

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

Definition at line 181 of file interface.h.

#define DESC_SAFEITER_PLAYER ( p,
d,
 ) 

Value:

for (d=(DESC *)rb_find(mudstate.desctree, (void *)p), \
                n=((d!=NULL) ? d->hashnext : NULL); \
             d; \
             d=n,n=((n!=NULL) ? n->hashnext : NULL))

Definition at line 175 of file interface.h.

Referenced by boot_off().

#define DOINGLEN   45

Definition at line 71 of file interface.h.

Referenced by do_doing().

#define DS_AUTODARK   0x0002

Definition at line 117 of file interface.h.

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

#define DS_CONNECTED   0x0001

Definition at line 116 of file interface.h.

Referenced by check_connect(), check_idle(), do_command(), do_unauth_command(), dump_users(), process_input(), and shutdownsock().

#define DS_DEAD   0x10000000

Definition at line 119 of file interface.h.

Referenced by do_unauth_command(), process_input(), and shutdownsock().

#define DS_IDENTIFIED   0x0008

Definition at line 118 of file interface.h.

#define HUDKEYLEN   21

Definition at line 72 of file interface.h.

Referenced by load_restart_db().

#define R_BADLOGIN   6

Definition at line 37 of file interface.h.

Referenced by check_connect().

#define R_BOOT   3

Definition at line 34 of file interface.h.

Referenced by boot_by_port(), and boot_off().

#define R_GAMEDOWN   7

Definition at line 38 of file interface.h.

Referenced by check_connect().

#define R_GAMEFULL   9

Definition at line 40 of file interface.h.

Referenced by check_connect().

#define R_GOING_DOWN   5

Definition at line 36 of file interface.h.

Referenced by close_sockets().

#define R_LOGOUT   8

Definition at line 39 of file interface.h.

Referenced by shutdownsock().

#define R_QUIT   1

Definition at line 32 of file interface.h.

Referenced by do_command(), do_unauth_command(), load_restart_db(), load_restart_db_xdr(), and process_input().

#define R_SOCKDIED   4

Definition at line 35 of file interface.h.

Referenced by eradicate_broken_fd(), and process_input().

#define R_TIMEOUT   2

Definition at line 33 of file interface.h.

Referenced by check_idle().


Typedef Documentation

typedef struct cmd_block CBLK

Definition at line 58 of file interface.h.

typedef struct descriptor_data DESC

Definition at line 74 of file interface.h.

typedef struct prog_data PROG

Definition at line 65 of file interface.h.


Function Documentation

void announce_disconnect ( dbref  ,
DESC ,
const char *   
)

Definition at line 672 of file netcommon.c.

References A_ADISCONNECT, descriptor_data::addr, alloc_mbuf, atr_pget(), c_Connected, Contents, statedata::curr_enactor, Dark, DARK, DESC_ITER_PLAYER, do_comdisconnect(), do_mail_purge(), DOLIST, DS_AUTODARK, descriptor_data::flags, Flags, free_lbuf, free_mbuf, Guest, H_SUSPECT, confdata::have_comsys, confdata::have_mailer, confdata::have_zones, descriptor_data::host_info, loc, Location, log_text(), confdata::master_room, MONITOR, MSG_FWDLIST, MSG_INV, MSG_LOC, MSG_NBR, MSG_NBR_EXITS, mudconf, mudstate, Name(), NOTHING, notify_checked(), descriptor_data::player, raw_broadcast(), release_player(), s_Flags, send_channel(), Suspect, toast_player(), tprintf(), TYPE_ROOM, TYPE_THING, Typeof, wait_que(), Wizard, and Zone.

Referenced by shutdownsock().

00673 {
00674         dbref loc, aowner, temp, zone, obj;
00675         int num, aflags, key;
00676         char *buf, *atr_temp;
00677         DESC *dtemp;
00678         char *argv[1];
00679 
00680         if(Suspect(player)) {
00681                 send_channel("Suspect", "%s has disconnected.", Name(player));
00682         }
00683         if(d->host_info & H_SUSPECT) {
00684                 send_channel("Suspect", "[Suspect site: %s] %s has disconnected.",
00685                                          d->addr, Name(d->player));
00686         }
00687         loc = Location(player);
00688         num = 0;
00689         DESC_ITER_PLAYER(player, dtemp) num++;
00690 
00691         temp = mudstate.curr_enactor;
00692         mudstate.curr_enactor = player;
00693 
00694         if(num < 2) {
00695                 buf = alloc_mbuf("announce_disconnect.only");
00696 
00697                 sprintf(buf, "%s has disconnected.", Name(player));
00698                 key = MSG_INV;
00699                 if((loc != NOTHING) && !(Dark(player) && Wizard(player)))
00700                         key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST);
00701                 notify_checked(player, player, buf, key);
00702                 free_mbuf(buf);
00703 
00704                 if(mudconf.have_comsys)
00705                         do_comdisconnect(player);
00706 
00707                 if(mudconf.have_mailer)
00708                         do_mail_purge(player);
00709 
00710                 raw_broadcast(MONITOR, (char *) "GAME: %s has disconnected.",
00711                                           Name(player), 0, 0, 0, 0, 0);
00712 
00713                 if(Guest(player) && mudconf.have_comsys)
00714                         toast_player(player);
00715 
00716                 argv[0] = (char *) reason;
00717                 c_Connected(player);
00718 
00719                 atr_temp = atr_pget(player, A_ADISCONNECT, &aowner, &aflags);
00720                 if(atr_temp && *atr_temp)
00721                         wait_que(player, player, 0, NOTHING, 0, atr_temp, argv, 1, NULL);
00722                 free_lbuf(atr_temp);
00723                 if(mudconf.master_room != NOTHING) {
00724                         atr_temp =
00725                                 atr_pget(mudconf.master_room, A_ADISCONNECT, &aowner,
00726                                                  &aflags);
00727                         if(atr_temp)
00728                                 wait_que(mudconf.master_room, player, 0, NOTHING, 0,
00729                                                  atr_temp, (char **) NULL, 0, NULL);
00730                         free_lbuf(atr_temp);
00731                         DOLIST(obj, Contents(mudconf.master_room)) {
00732                                 atr_temp = atr_pget(obj, A_ADISCONNECT, &aowner, &aflags);
00733                                 if(atr_temp) {
00734                                         wait_que(obj, player, 0, NOTHING, 0, atr_temp,
00735                                                          (char **) NULL, 0, NULL);
00736                                 }
00737                                 free_lbuf(atr_temp);
00738                         }
00739                 }
00740                 /*
00741                  * do the zone of the player's location's possible * * *
00742                  * adisconnect 
00743                  */
00744                 if(mudconf.have_zones && ((zone = Zone(loc)) != NOTHING)) {
00745                         switch (Typeof(zone)) {
00746                         case TYPE_THING:
00747                                 atr_temp = atr_pget(zone, A_ADISCONNECT, &aowner, &aflags);
00748                                 if(atr_temp) {
00749                                         wait_que(zone, player, 0, NOTHING, 0, atr_temp,
00750                                                          (char **) NULL, 0, NULL);
00751                                 }
00752                                 free_lbuf(atr_temp);
00753                                 break;
00754                         case TYPE_ROOM:
00755                                 /*
00756                                  * check every object in the room for a * * * 
00757                                  * connect action 
00758                                  */
00759                                 DOLIST(obj, Contents(zone)) {
00760                                         atr_temp = atr_pget(obj, A_ADISCONNECT, &aowner, &aflags);
00761                                         if(atr_temp) {
00762                                                 wait_que(obj, player, 0, NOTHING, 0, atr_temp,
00763                                                                  (char **) NULL, 0, NULL);
00764                                         }
00765                                         free_lbuf(atr_temp);
00766                                 }
00767                                 break;
00768                         default:
00769                                 log_text(tprintf
00770                                                  ("Invalid zone #%d for %s(#%d) has bad type %d",
00771                                                   zone, Name(player), player, Typeof(zone)));
00772                         }
00773                 }
00774                 if(d->flags & DS_AUTODARK) {
00775                         s_Flags(d->player, Flags(d->player) & ~DARK);
00776                         d->flags &= ~DS_AUTODARK;
00777                 }
00778 
00779                 if(Guest(player))
00780                         s_Flags(player, Flags(player) | DARK);
00781         } else {
00782                 buf = alloc_mbuf("announce_disconnect.partial");
00783                 sprintf(buf, "%s has partially disconnected.", Name(player));
00784                 key = MSG_INV;
00785                 if((loc != NOTHING) && !(Dark(player) && Wizard(player)))
00786                         key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST);
00787                 notify_checked(player, player, buf, key);
00788                 raw_broadcast(MONITOR,
00789                                           (char *) "GAME: %s has partially disconnected.",
00790                                           Name(player), 0, 0, 0, 0, 0);
00791                 free_mbuf(buf);
00792         }
00793 
00794         mudstate.curr_enactor = temp;
00795         release_player(player);
00796 }

int boot_by_port ( int  ,
int  ,
char *   
)

Definition at line 815 of file netcommon.c.

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

Referenced by do_boot().

00816 {
00817         DESC *d, *dnext;
00818         int count;
00819 
00820         count = 0;
00821         DESC_SAFEITER_ALL(d, dnext) {
00822                 if((d->descriptor == port) && (!no_god || !God(d->player))) {
00823                         if(message && *message) {
00824                                 queue_string(d, message);
00825                                 queue_string(d, "\r\n");
00826                         }
00827                         shutdownsock(d, R_BOOT);
00828                         count++;
00829                 }
00830         }
00831         return count;
00832 }

int boot_off ( dbref  ,
char *   
)

Definition at line 798 of file netcommon.c.

Referenced by destroy_player(), do_boot(), and do_toad().

00799 {
00800         DESC *d, *dnext;
00801         int count;
00802 
00803         count = 0;
00804         DESC_SAFEITER_PLAYER(player, d, dnext) {
00805                 if(message && *message) {
00806                         queue_string(d, message);
00807                         queue_string(d, "\r\n");
00808                 }
00809                 shutdownsock(d, R_BOOT);
00810                 count++;
00811         }
00812         return count;
00813 }

void check_idle ( void   ) 

Definition at line 56 of file timer.c.

References Can_Idle, confdata::conn_timeout, descriptor_data::connected_at, Dark, DARK, DESC_SAFEITER_ALL, DS_AUTODARK, DS_CONNECTED, descriptor_data::flags, Flags, confdata::idle_timeout, confdata::idle_wiz_dark, descriptor_data::last_time, mudconf, mudstate, statedata::now, descriptor_data::player, queue_string(), R_TIMEOUT, s_Flags, shutdownsock(), and descriptor_data::timeout.

Referenced by dispatch().

00057 {
00058     DESC *d, *dnext;
00059     time_t idletime;
00060     
00061     DESC_SAFEITER_ALL(d, dnext) {
00062         if(d->flags & DS_CONNECTED) {
00063             idletime = mudstate.now - d->last_time;
00064             if((idletime > d->timeout) && !Can_Idle(d->player)) {
00065                 queue_string(d, "*** Inactivity Timeout ***\r\n");
00066                 shutdownsock(d, R_TIMEOUT);
00067             } else if(mudconf.idle_wiz_dark &&
00068                       (idletime > mudconf.idle_timeout) && Can_Idle(d->player)
00069                       && !Dark(d->player)) {
00070                 s_Flags(d->player, Flags(d->player) | DARK);
00071                 d->flags |= DS_AUTODARK;
00072             }   
00073         } else {
00074             idletime = mudstate.now - d->connected_at;
00075             if(idletime > mudconf.conn_timeout) {
00076                 queue_string(d, "*** Login Timeout ***\r\n");
00077                 shutdownsock(d, R_TIMEOUT);
00078             }   
00079         }   
00080     }   
00081 }   

void clearstrings ( DESC  ) 

Definition at line 338 of file netcommon.c.

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

Referenced by release_descriptor().

00339 {
00340         if(d->output_prefix) {
00341                 free_lbuf(d->output_prefix);
00342                 d->output_prefix = NULL;
00343         }
00344         if(d->output_suffix) {
00345                 free_lbuf(d->output_suffix);
00346                 d->output_suffix = NULL;
00347         }
00348 }

void emergency_shutdown ( void   ) 

Definition at line 748 of file bsd.c.

References close_sockets().

Referenced by do_shutdown().

00748                               {
00749         close_sockets(1, (char *) "Going down - Bye.\n");
00750 }

int fetch_connect ( dbref   ) 

Definition at line 877 of file netcommon.c.

References descriptor_data::connected_at, DESC_ITER_PLAYER, mudstate, and statedata::now.

00878 {
00879         DESC *d;
00880         int result, conntime;
00881 
00882         result = -1;
00883         DESC_ITER_PLAYER(target, d) {
00884                 conntime = (mudstate.now - d->connected_at);
00885                 if(conntime > result)
00886                         result = conntime;
00887         }
00888         return result;
00889 }

int fetch_idle ( dbref   ) 

Definition at line 863 of file netcommon.c.

References DESC_ITER_PLAYER, descriptor_data::last_time, mudstate, and statedata::now.

00864 {
00865         DESC *d;
00866         int result, idletime;
00867 
00868         result = -1;
00869         DESC_ITER_PLAYER(target, d) {
00870                 idletime = (mudstate.now - d->last_time);
00871                 if((result == -1) || (idletime < result))
00872                         result = idletime;
00873         }
00874         return result;
00875 }

dbref find_connected_name ( dbref  ,
char *   
)

Definition at line 1738 of file netcommon.c.

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

Referenced by lookup_player().

01739 {
01740         DESC *d;
01741         dbref found;
01742 
01743         found = NOTHING;
01744         DESC_ITER_CONN(d) {
01745                 if(Good_obj(player) && !Wizard(player) && Hidden(d->player))
01746                         continue;
01747                 if(!string_prefix(Name(d->player), name))
01748                         continue;
01749                 if((found != NOTHING) && (found != d->player))
01750                         return NOTHING;
01751                 found = d->player;
01752         }
01753         return found;
01754 }

void freeqs ( DESC  ) 

Definition at line 378 of file netcommon.c.

References descriptor_data::input, and descriptor_data::input_tail.

Referenced by release_descriptor().

00379 {
00380         CBLK *cb, *cnext;
00381 
00382     d->input_tail = 0;
00383     memset(d->input, 0, sizeof(d->input));
00384 }

void handle_http ( DESC ,
char *   
)

void hudinfo_notify ( DESC ,
const char *  ,
const char *  ,
const char *   
)

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

Definition at line 1715 of file netcommon.c.

References DESC_ITER_CONN, Hidden, descriptor_data::player, safe_chr, safe_str, tprintf(), and WizRoy.

01716 {
01717         DESC *d;
01718         char *cp;
01719 
01720         cp = *bufc;
01721         DESC_ITER_CONN(d) {
01722                 if(!WizRoy(player) && Hidden(d->player))
01723                         continue;
01724                 if(cp != *bufc)
01725                         safe_chr(' ', buff, bufc);
01726                 safe_chr('#', buff, bufc);
01727                 safe_str(tprintf("%d", d->player), buff, bufc);
01728         }
01729 }

struct timeval msec_add ( struct  timeval,
int   
)

Definition at line 100 of file netcommon.c.

References x.

Referenced by update_quotas().

00101 {
00102         t.tv_sec += x / 1000;
00103         t.tv_usec += (x % 1000) * 1000;
00104         if(t.tv_usec >= 1000000) {
00105                 t.tv_sec += t.tv_usec / 1000000;
00106                 t.tv_usec = t.tv_usec % 1000000;
00107         }
00108         return t;
00109 }

int msec_diff ( struct timeval  now,
struct timeval  then 
)

Definition at line 89 of file netcommon.c.

Referenced by update_quotas().

00090 {
00091         return ((now.tv_sec - then.tv_sec) * 1000 + (now.tv_usec -
00092                                                                                                  then.tv_usec) / 1000);
00093 }

void process_commands ( void   ) 

void queue_string ( DESC ,
const char *   
)

Definition at line 366 of file netcommon.c.

References Ansi, ESC_CHAR, LBUF_SIZE, descriptor_data::player, queue_write(), and strip_ansi_r().

Referenced by announce_connect(), boot_by_port(), boot_off(), check_connect(), check_idle(), close_sockets(), do_command(), do_prog(), do_unauth_command(), dump_users(), failconn(), handle_prog(), make_guest(), notify_printf(), process_input(), raw_notify_raw(), and run_command().

00367 {
00368         char new[LBUF_SIZE];
00369 
00370         strncpy(new, s, LBUF_SIZE-1);
00371         new[LBUF_SIZE-1] = '\0';
00372 
00373         if(!Ansi(d->player) && index(s, ESC_CHAR)) 
00374                 strip_ansi_r(new, s, strlen(s));
00375     queue_write(d, new, strlen(new));
00376 }

void queue_write ( DESC ,
char *  ,
int   
)

Definition at line 355 of file netcommon.c.

References descriptor_data::output_tot, and descriptor_data::sock_buff.

Referenced by close_sockets(), failconn(), fcache_dumpbase(), queue_string(), raw_broadcast(), raw_notify_newline(), and raw_notify_raw().

00356 {
00357         int retval;
00358         if(n <= 0)
00359                 return;
00360 
00361         bufferevent_write(d->sock_buff, b, n);
00362         d->output_tot += n;
00363         return;
00364 }

void raw_notify ( dbref  ,
const char *   
)

Definition at line 243 of file netcommon.c.

References raw_notify_raw().

00244 {
00245         raw_notify_raw(player, msg, "\r\n");
00246 }

void raw_notify_newline ( dbref   ) 

Definition at line 268 of file netcommon.c.

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

Referenced by show_a_desc().

00269 {
00270         DESC *d;
00271 
00272         if(mudstate.inpipe && (player == mudstate.poutobj)) {
00273                 safe_str("\r\n", mudstate.poutnew, &mudstate.poutbufc);
00274                 return;
00275         }
00276         if(!Connected(player))
00277                 return;
00278 
00279         DESC_ITER_PLAYER(player, d) {
00280                 queue_write(d, "\r\n", 2);
00281         }
00282 }

void raw_notify_raw ( dbref  ,
const char *  ,
char *   
)

Definition at line 218 of file netcommon.c.

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

Referenced by raw_notify().

00219 {
00220         DESC *d;
00221 
00222         if(!msg || !*msg)
00223                 return;
00224 
00225         if(mudstate.inpipe && (player == mudstate.poutobj)) {
00226                 safe_str((char *) msg, mudstate.poutnew, &mudstate.poutbufc);
00227                 if(append != NULL)
00228                         safe_str(append, mudstate.poutnew, &mudstate.poutbufc);
00229                 return;
00230         }
00231 
00232         if(!Connected(player))
00233                 return;
00234 
00235         DESC_ITER_PLAYER(player, d) {
00236                 queue_string(d, msg);
00237                 if(append != NULL)
00238                         queue_write(d, append, strlen(append));
00239         }
00240 }

void save_command ( DESC ,
CBLK  
)

void set_signals ( void   ) 

void shovechars ( int   ) 

Definition at line 350 of file bsd.c.

References accept_new_connection(), bind_mux_socket(), current_time, dprintk, get_tod, listen_sock_ev, mudconf, mux_bound_socket, queue_ev, queue_slice, runqueues(), and confdata::timeslice.

Referenced by main().

00351 {
00352         unsigned int flags;
00353         queue_slice.tv_sec = 0;
00354         queue_slice.tv_usec = mudconf.timeslice * 1000;
00355 
00356         dprintk("shovechars starting, sock is %d.", mux_bound_socket);
00357 #ifdef IPV6_SUPPORT
00358         dprintk("shovechars starting, ipv6 sock is %d.", mux_bound_socket);
00359 #endif
00360 
00361         if(mux_bound_socket < 0) {
00362                 mux_bound_socket = bind_mux_socket(port);
00363         }
00364         event_set(&listen_sock_ev, mux_bound_socket, EV_READ | EV_PERSIST,
00365                           accept_new_connection, NULL);
00366         event_add(&listen_sock_ev, NULL);
00367 
00368         flags = fcntl(2, F_GETFD, 0); 
00369         dprintk("stderr is %x", flags);
00370 #ifdef IPV6_SUPPORT
00371         if(mux_bound_socket6 < 0) {
00372                 mux_bound_socket6 = bind_mux6_socket(port);
00373         }
00374         event_set(&listen6_sock_ev, mux_bound_socket6, EV_READ | EV_PERSIST,
00375                           accept_new6_connection, NULL);
00376         event_add(&listen6_sock_ev, NULL);
00377 #endif
00378 
00379         evtimer_set(&queue_ev, runqueues, NULL);
00380         evtimer_add(&queue_ev, &queue_slice);
00381 
00382         get_tod(&last_slice);
00383         get_tod(&current_time);
00384 
00385         event_dispatch();
00386 }

void shutdownsock ( DESC ,
int   
)

Definition at line 460 of file bsd.c.

References descriptor_data::addr, announce_disconnect(), descriptor_data::command_count, descriptor_data::connected_at, decode_flags(), desc_delhash(), descriptor_data::descriptor, disc_messages, disc_reasons, dnschild_kill(), DS_CONNECTED, DS_DEAD, FC_QUIT, fcache_dump(), Flags, descriptor_data::flags, Flags2, Flags3, GOD, Location, LOG_ACCOUNTING, log_error(), LOG_LOGIN, LOG_NET, mudstate, Name(), statedata::now, descriptor_data::outstanding_dnschild_query, Pennies(), descriptor_data::player, R_LOGOUT, and release_descriptor().

Referenced by boot_by_port(), boot_off(), check_connect(), check_idle(), close_sockets(), do_command(), do_unauth_command(), eradicate_broken_fd(), failconn(), load_restart_db(), load_restart_db_xdr(), and process_input().

00461 {
00462         char *buff, *buff2;
00463         time_t now;
00464         int i, num;
00465         DESC *dtemp;
00466 
00467 /*    dprintk("shutdownsock called on %p %s(#%d) refcount %d", 
00468         d, (d->player?Name(d->player):""), d->player, d->refcount); */
00469 
00470     if(d->flags & DS_CONNECTED) {
00471                 if(d->outstanding_dnschild_query)
00472                         dnschild_kill(d->outstanding_dnschild_query);
00473 
00474                 /*
00475                  * Do the disconnect stuff if we aren't doing a LOGOUT * * *
00476                  * * * * (which keeps the connection open so the player can *
00477                  * * connect * * * * to a different character). 
00478                  */
00479 
00480                 if(reason != R_LOGOUT) {
00481                         fcache_dump(d, FC_QUIT);
00482                 }
00483 
00484                 log_error(LOG_NET | LOG_LOGIN, "NET", "DISC",
00485                                   "[%d/%s] Logout by %s(#%d), <Reason: %s>",
00486                                   d->descriptor, d->addr, Name(d->player), d->player,
00487                                   disc_reasons[reason]);
00488 
00489                 /*
00490                  * If requested, write an accounting record of the form: * *
00491                  * * * * * Plyr# Flags Cmds ConnTime Loc Money [Site]
00492                  * <DiscRsn>  * *  * Name 
00493                  */
00494 
00495                 log_error(LOG_ACCOUNTING, "DIS", "ACCT",
00496                                   "%d %s %d %d %d %d [%s] <%s> %s",
00497                                   d->player, decode_flags(GOD, Flags(d->player),
00498                                                                                   Flags2(d->player),
00499                                                                                   Flags3(d->player)),
00500                                   d->command_count, mudstate.now - d->connected_at,
00501                                   Location(d->player), Pennies(d->player), d->addr,
00502                                   disc_reasons[reason], Name(d->player));
00503 
00504         announce_disconnect(d->player, d, disc_messages[reason]);
00505         desc_delhash(d);
00506 
00507         }
00508     d->flags |= DS_DEAD;
00509     release_descriptor(d);
00510    /* dprintk("shutdown."); */
00511 }

int site_check ( struct sockaddr_storage *  ,
int  ,
SITE  
)

Definition at line 1625 of file netcommon.c.

Referenced by accept_new_connection(), and initializesock().

01627 {
01628         SITE *this;
01629 #ifdef XXX
01630         for(this = site_list; this; this = this->next) {
01631                 if((host.s_addr & this->mask.s_addr) == this->saddr.s_addr)
01632                         return this->flag;
01633         }
01634 #endif
01635         return 0;
01636 }

struct timeval timeval_sub ( struct  timeval,
struct  timeval 
)

Definition at line 73 of file netcommon.c.

00074 {
00075         now.tv_sec -= then.tv_sec;
00076         now.tv_usec -= then.tv_usec;
00077         if(now.tv_usec < 0) {
00078                 now.tv_usec += 1000000;
00079                 now.tv_sec--;
00080         }
00081         return now;
00082 }

struct timeval update_quotas ( struct  timeval,
struct  timeval 
)

Definition at line 116 of file netcommon.c.

References confdata::cmd_quota_incr, confdata::cmd_quota_max, DESC_ITER_ALL, msec_add(), msec_diff(), mudconf, and confdata::timeslice.

Referenced by runqueues().

00117 {
00118         int nslices;
00119         DESC *d;
00120 
00121         nslices =
00122                 msec_diff(current,
00123                                   last) / (mudconf.timeslice > 0 ? mudconf.timeslice : 1);
00124 
00125         if(nslices > 0) {
00126                 DESC_ITER_ALL(d) {
00127                         d->quota += mudconf.cmd_quota_incr * nslices;
00128                         if(d->quota > mudconf.cmd_quota_max)
00129                                 d->quota = mudconf.cmd_quota_max;
00130                 }
00131         }
00132         return msec_add(last, nslices * mudconf.timeslice);
00133 }

void welcome_user ( DESC  ) 

Definition at line 387 of file netcommon.c.

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

Referenced by check_connect(), initializesock(), and network_initialize_socket().

00388 {
00389         if(d->host_info & H_REGISTRATION)
00390                 fcache_dump(d, FC_CONN_REG);
00391         else {
00392                 if(fcache_conn_c) {
00393                         fcache_dump_conn(d, rand() % fcache_conn_c);
00394                         return;
00395                 }
00396                 fcache_dump(d, FC_CONN);
00397         }
00398 }


Variable Documentation

DESC* descriptor_list

Definition at line 48 of file bsd.c.

NAMETAB logout_cmdtable[]

Definition at line 1133 of file netcommon.c.

Referenced by init_logout_cmdtab().

int shutdown_flag


Generated on Mon May 28 04:25:45 2007 for BattletechMUX by  doxygen 1.4.7