structs.h
calisto-20000323/src/structs.h · 3.3 KB
From the archive calisto-20000323.tar.gz
Download the archive « Back to the archive contents
/*
Calisto (c) 1998-1999 Peter Howkins, Matthew Howkins, Simon Howkins
$Id: structs.h,v 1.2 2000/01/12 20:32:14 peter Exp $
$Log: structs.h,v $
Revision 1.2 2000/01/12 20:32:14 peter
Added CRYPT_PASSWORD_LENGTH and changed MAX_PASSWORD_LENGTH
Revision 1.1 1999/12/21 20:37:58 peter
Initial revision
*/
#ifndef structs_h
#define structs_h
#include <time.h>
#include "dllist.h"
#ifndef BOOL
#define BOOL
typedef int bool;
#define FALSE ((bool) 0)
#define TRUE ((bool) 1)
#endif /* BOOL */
#define MIN_NAME_LENGTH 1
#define MAX_NAME_LENGTH 12 /* Length of chars names */
#define MIN_PASSWORD_LENGTH 3
#define MAX_PASSWORD_LENGTH 8 /* Length of chars password */
#define CRYPT_PASSWORD_LENGTH 13 /* Length from crypt() function */
#define MAX_RAW_INPUT_BUFFER 512 /* Input buffer length */
#define MAX_HOST_NAME 256 /* host name len eg. fish.dripple.com */
#define MAX_TERMTYPE_LEN 20 /* terminal type eg xterm or vt100 */
#define MAX_PROMPT_LENGTH 12
#define OUTPUT_BUFFER 1024 /* Output buffer length */
#define MAX_GROUP_NAME_LENGTH 12
#define STATE_LOGIN 0
#define STATE_PASSWORD 1
#define STATE_PLAY 2
#define STATE_CLOSING 3
#define STATE_NEW1 4
#define STATE_NEW2 5
#define STATE_NEW3 6
typedef struct character character;
typedef struct descriptor descriptor;
typedef struct logindata logindata;
/* used when making a new char to remember some things */
struct logindata {
char name[MAX_NAME_LENGTH+1]; /* Chars name */
char password[CRYPT_PASSWORD_LENGTH+1]; /* Chars password */
};
struct character {
bool loggedin;
char name[MAX_NAME_LENGTH+1]; /* Chars name */
char password[CRYPT_PASSWORD_LENGTH+1]; /* Chars password */
unsigned long privs;
char prompt[MAX_PROMPT_LENGTH+1];
char group[MAX_GROUP_NAME_LENGTH+1];/* name of their group */
unsigned long prevtime; /* num of seconds, prev to this login */
time_t logintime; /* time they successfully logged in */
listnode characterlink; /* links together all active characters */
listnode roomlink; /* links together the characters in each room */
};
struct descriptor {
int sfd; /* socket descriptor */
int state; /* the state the socket is in (eg playing
or at password) */
char inbuf[MAX_RAW_INPUT_BUFFER]; /* the raw data from the socket */
int inbuf_used; /* number of bytes used in inbuf */
int inbuf_used_lines; /* number of bytes used for whole lines in inbuf */
char outbuf[OUTPUT_BUFFER];
time_t connecttime; /* time connection was made */
time_t idletime; /* time since last information received */
char termtype[MAX_TERMTYPE_LEN+1];
unsigned term_width; /* the terminals width and height */
unsigned term_height;
char hostname[MAX_HOST_NAME+1]; /* returned by gethostbyname */
/* HACK - used in login process, has to be a nicer way though */
logindata data;
/* HACK - needed cos its tricky to find out if a socket is connected */
bool safe;
listnode descriptorlink;
character player; /* The character using this socket */
};
#endif