1 //--------------------------------------------------------------------------
2 // Mamer.hh - Class header for the Mamer class
4 // Matthew E. Moses & Michael A. Long
7 // $Date: 2002/07/02 00:05:19 $
10 // Revision 1.13 2002/07/02 00:05:19 tridge
11 // got rid of a bunch of RCS tags now that its in CVS
13 // Revision 1.12 2002/07/02 00:02:40 tridge
14 // - fixed compile on g++ 2.96
15 // - updated for lasker 'rmatch'
17 // Revision 1.11 1998/09/10 19:58:41 mlong
18 // lots of little bug fixes and a few new features.
20 // Revision 1.10 1998/06/18 18:41:52 mlong
21 // prepairing for yet another move.
23 // Revision 1.9 1998/04/29 15:24:07 mlong
24 // prepairing for the move to daimi
25 // new sorting routine.
27 // Revision 1.8 1998/04/18 18:46:31 mlong
28 // fixed delete bug and
29 // added delete tourney function
31 // Revision 1.5 1997/05/15 18:29:12 chess
32 // added pending and TourneyPlayers support
33 // added HandleGetPlayerInfo & HandleGetGameInfo
35 // Revision 1.4 1997/04/13 03:21:32 chess
36 // TellUser and ParseParams added
38 // Revision 1.3 1997/03/21 15:31:49 moses
39 // added some defines to support the solaris sun compile
41 // Revision 1.2 1996/10/01 20:14:43 moses
42 // Changes to support the new command list,
43 // to correctly have the commands, I had to derive this class from the
46 // Revision 1.1 1996/09/30 20:52:48 moses
49 //--------------------------------------------------------------------------
58 #include <sys/param.h>
59 #include <sys/types.h>
70 #include <sys/signal.h>
73 #include <sys/socket.h>
74 #include <netinet/in.h>
76 #include <arpa/inet.h>
84 #define INADDR_NONE -1
89 #include "linklist.hh"
93 #include "CommandEntry.hh"
105 //#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
106 //#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
108 class Mamer : public CommandEntry {
114 int Initialize(int argc, char **argv);
115 char *s_and_r(char *, char *, char *);
116 int OpenServerConnection(void);
117 void ListenLoop(void);
119 int GivePlace(int, Tourney *);
120 void AnnounceTourneyEnd(Tourney *);
121 void savePlayerData(Tourney *);
123 void DumpConfiguration(void);
125 int XServerCom(char *, ...);
126 void TellUser(reasons, char *);
127 void TellUser(Command *, char *);
128 void TellUser(reasons, char *, char *);
129 void TellUser(reasons, char *, int);
130 void TellUser(reasons, char *, char *, int);
131 void TellUser(reasons, char *, char *, char *);
132 void TellUser(reasons, char *, char *, char *, int);
134 #define MAX_WORD_SIZE 1024
135 #define MAX_LINE_SIZE 1024
137 int UserIsLoaded(char *);
138 int ParseParams(Command *, char *);
139 int isWhiteSpace(int);
140 char *getWord(char *);
141 char *eatWord(char *);
142 char *eatWhite(char *);
143 char *eatTailWhite(char *);
144 char *nextWord(char *);
145 char *stolower(char *);
147 int GenerateTourneyNumber(void);
149 Tourney *FindTourney(int);
150 User *FindUser(char *);
151 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 *);
171 Player *FindPending(char *);
174 char configFilename[MAXPATHLEN];
186 char logFilename[MAXPATHLEN];
187 char dataFilePath[MAXPATHLEN];
188 char homeFilePath[MAXPATHLEN];
189 char userFilePath[MAXPATHLEN];
190 char helpFilePath[MAXPATHLEN];
194 long countOfTourneysSinceRestart;
196 TourneyParameters tourneyParams;
198 LinkList<Tourney> tourneyList;
199 LinkList<Player> pendingList;
200 LinkList<User> userList;
201 LinkList<Command> commandList;
202 LinkList<Storage> storageList;