sima/autoconf/
sima/hosts/i386/
sima/mudlib/
sima/mudlib/kernel/
sima/mudlib/obj/
sima/mudlib/sys/
sima/synhash/mips/
#ifndef COMM_H
#define COMM_H

#include <sys/socket.h>
#ifdef _AIX
#include <sys/socketvar.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

#include "mudlib/sys/driver_hook.h"
#include "uid.h"

/* stdin,stdout,stderr,erq,accept,file */
#define MAX_MISC_DESCRIPTORS 6

#define USER_INPUT_BUFSIZE	1024
#ifndef MAX_OUTPUT_PACKET_SIZE
#if defined(sgi) && defined(mips) && defined(unix)
/* Work around for an irix kernel bug that can leave the process unresponsive
 * and unkillable.
 */
#define MAX_OUTPUT_PACKET_SIZE   200
#else
#define MAX_OUTPUT_PACKET_SIZE  1024
#endif /* irix */
#endif /* MAX_OUTPUT_PACKET_SIZE */

struct interactive {
    union svalue object;
    union svalue hook[NUM_INTERACTIVE_HOOKS];
    struct in_addr addr;
    short socket;
    short message_length;
    struct interactive *next_user_for_flush, *previous_user_for_flush;
#ifdef ACCESS_CONTROL
    long access_class;
#endif
    char charset[32];
    struct eval_cost eval_cost;
    p_int last_command_time;
    p_int total_commands;
    p_int in_total;
    p_int out_packets;
    p_int out_total;
    char quote_iac;
    char padding_dummy;
    char tn_state;
    char tn_data_state;		/* TS_{COMMAND,{CHAR,STRING}MODE,SYNCH} */
    char tn_data_state2;	/* TS_{COMMAND,{CHAR,STRING}MODE} */
    char pad[3];		/* unused */
    short input_end;            /* first free char in buffer */
    short command_start;        /* used for charmode */
    short command_end;          /* where we are up to in player cmd buffer */
    short tn_start;             /* first char of pending telnet neg */
    short tn_end;               /* first char to check for telnet negotiation */
    short chars_ready;
    struct interactive *next_pending; /* next user with buffered commands */

    /* We rely on input being aligned, thus don't move unaligned stuff in front */
    char input[USER_INPUT_BUFSIZE];
    char message_buf[MAX_OUTPUT_PACKET_SIZE];
};

extern int comm_nfds;
extern struct interactive **pending_link;

/* map all user descriptors & interprocess communication descriptors */
extern struct fd_entry {
    void (*f)();
    struct interactive *ip;
} fd_table[MAX_USER+MAX_MISC_DESCRIPTORS];

struct interactive *trace_origin;

void start_comm(fd_set *);
void walk_fdset(fd_set *set, int n);
void pending_commands(struct interactive *ip);
char *allow_host_access (); 

#endif /* COMM_H */