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 //--------------------------------------------------------------------------
54 #include <sys/param.h>
55 #include <sys/types.h>
66 #include <sys/signal.h>
69 #include <sys/socket.h>
70 #include <netinet/in.h>
72 #include <arpa/inet.h>
80 #define INADDR_NONE -1
85 #include "linklist.hh"
89 #include "CommandEntry.hh"
101 //#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
102 //#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
104 class Mamer : public CommandEntry {
110 int Initialize(int argc, char **argv);
111 char *s_and_r(char *, char *, char *);
112 int OpenServerConnection(void);
113 void ListenLoop(void);
115 int GivePlace(int, Tourney *);
116 void AnnounceTourneyEnd(Tourney *);
117 void savePlayerData(Tourney *);
119 void DumpConfiguration(void);
121 int XServerCom(char *, ...);
122 void TellUser(reasons, char *);
123 void TellUser(Command *, char *);
124 void TellUser(reasons, char *, char *);
125 void TellUser(reasons, char *, int);
126 void TellUser(reasons, char *, char *, int);
127 void TellUser(reasons, char *, char *, char *);
128 void TellUser(reasons, char *, char *, char *, int);
130 #define MAX_WORD_SIZE 1024
131 #define MAX_LINE_SIZE 1024
133 int UserIsLoaded(char *);
134 int ParseParams(Command *, char *);
135 int isWhiteSpace(int);
136 char *getWord(char *);
137 char *eatWord(char *);
138 char *eatWhite(char *);
139 char *eatTailWhite(char *);
140 char *nextWord(char *);
141 char *stolower(char *);
143 int GenerateTourneyNumber(void);
145 Tourney *FindTourney(int);
146 User *FindUser(char *);
147 Command *FindCommand(char *, char *);
151 void LoadConfigurationFile(void);
152 void BuildCommandList(void);
153 void CheckUser(char *);
154 void AdjustManagerList(int, char *);
156 int HandleQtell(char *);
157 int HandleTell(char *);
158 int HandleChannel(char *);
159 int HandleConnect(char *);
160 int HandleDisconnect(char *);
161 int HandleGame(char *);
162 int HandleGameInfo(char *);
163 int HandlePlayerInfo(char *);
167 Player *FindPending(char *);
170 char configFilename[MAXPATHLEN];
182 char logFilename[MAXPATHLEN];
183 char dataFilePath[MAXPATHLEN];
184 char homeFilePath[MAXPATHLEN];
185 char userFilePath[MAXPATHLEN];
186 char helpFilePath[MAXPATHLEN];
190 long countOfTourneysSinceRestart;
192 TourneyParameters tourneyParams;
194 LinkList<Tourney> tourneyList;
195 LinkList<Player> pendingList;
196 LinkList<User> userList;
197 LinkList<Command> commandList;
198 LinkList<Storage> storageList;