1 //--------------------------------------------------------------------------
2 // Mamer.hh - Class header for the Mamer class
4 // Matthew E. Moses & Michael A. Long
7 // $Date: 1998/09/10 19:58:41 $
13 // Revision 1.11 1998/09/10 19:58:41 mlong
14 // lots of little bug fixes and a few new features.
16 // Revision 1.10 1998/06/18 18:41:52 mlong
17 // prepairing for yet another move.
19 // Revision 1.9 1998/04/29 15:24:07 mlong
20 // prepairing for the move to daimi
21 // new sorting routine.
23 // Revision 1.8 1998/04/18 18:46:31 mlong
24 // fixed delete bug and
25 // added delete tourney function
27 // Revision 1.5 1997/05/15 18:29:12 chess
28 // added pending and TourneyPlayers support
29 // added HandleGetPlayerInfo & HandleGetGameInfo
31 // Revision 1.4 1997/04/13 03:21:32 chess
32 // TellUser and ParseParams added
34 // Revision 1.3 1997/03/21 15:31:49 moses
35 // added some defines to support the solaris sun compile
37 // Revision 1.2 1996/10/01 20:14:43 moses
38 // Changes to support the new command list,
39 // to correctly have the commands, I had to derive this class from the
42 // Revision 1.1 1996/09/30 20:52:48 moses
45 //--------------------------------------------------------------------------
56 #include <sys/param.h>
57 #include <sys/types.h>
68 #include <sys/signal.h>
71 #include <sys/socket.h>
72 #include <netinet/in.h>
74 #include <arpa/inet.h>
82 #define INADDR_NONE -1
87 #include "linklist.hh"
91 #include "CommandEntry.hh"
103 //#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
104 //#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
106 class Mamer : public CommandEntry {
112 int Initialize(int argc, char **argv);
113 char *s_and_r(char *, char *, char *);
114 int OpenServerConnection(void);
115 void ListenLoop(void);
117 int GivePlace(int, Tourney *);
118 void AnnounceTourneyEnd(Tourney *);
119 void savePlayerData(Tourney *);
121 void DumpConfiguration(void);
123 int XServerCom(char *, ...);
124 void TellUser(reasons, char *);
125 void TellUser(Command *, char *);
126 void TellUser(reasons, char *, char *);
127 void TellUser(reasons, char *, int);
128 void TellUser(reasons, char *, char *, int);
129 void TellUser(reasons, char *, char *, char *);
130 void TellUser(reasons, char *, char *, char *, int);
132 #define MAX_WORD_SIZE 1024
133 #define MAX_LINE_SIZE 1024
135 int UserIsLoaded(char *);
136 int ParseParams(Command *, char *);
137 int isWhiteSpace(int);
138 char *getWord(char *);
139 char *eatWord(char *);
140 char *eatWhite(char *);
141 char *eatTailWhite(char *);
142 char *nextWord(char *);
143 char *stolower(char *);
145 int GenerateTourneyNumber(void);
147 Tourney *FindTourney(int);
148 User *FindUser(char *);
149 Command *FindCommand(char *, char *);
155 void LoadConfigurationFile(void);
156 void BuildCommandList(void);
157 void CheckUser(char *);
158 void AdjustManagerList(int, char *);
160 int HandleQtell(char *);
161 int HandleTell(char *);
162 int HandleChannel(char *);
163 int HandleConnect(char *);
164 int HandleDisconnect(char *);
165 int HandleGame(char *);
166 int HandleGameInfo(char *);
167 int HandlePlayerInfo(char *);
169 Player *FindPending(char *);
172 char configFilename[MAXPATHLEN];
184 char logFilename[MAXPATHLEN];
185 char dataFilePath[MAXPATHLEN];
186 char homeFilePath[MAXPATHLEN];
187 char userFilePath[MAXPATHLEN];
188 char helpFilePath[MAXPATHLEN];
192 long countOfTourneysSinceRestart;
194 TourneyParameters tourneyParams;
196 LinkList<Tourney> tourneyList;
197 LinkList<Player> pendingList;
198 LinkList<User> userList;
199 LinkList<Command> commandList;
200 LinkList<Storage> storageList;