Fix color assignment by mamer
[capablanca.git] / lasker-2.2.3 / bots / mamer / Command.cc
1 //--------------------------------------------------------------------------
2 // Command.cc - Source file for the Command class
3 //
4 // Matthew E. Moses
5 //
6 // $Revision: 1.9 $
7 // $Date: 2002/07/02 00:05:19 $
8 //
9 // $Author: tridge $
10 // $Locker:  $
11 //
12 // $Log: Command.cc,v $
13 // Revision 1.9  2002/07/02 00:05:19  tridge
14 // got rid of a bunch of RCS tags now that its in CVS
15 //
16 // Revision 1.8  1998/09/10 19:57:17  mlong
17 // lots of little bug fixes and a few new features
18 //
19 // Revision 1.7  1998/04/15 16:56:17  mlong
20 // *** empty log message ***
21 //
22 // Revision 1.6  1998/02/12 18:43:26  mlong
23 // *** empty log message ***
24 //
25 // Revision 1.5  1997/05/15 18:27:53  chess
26 // added pending and TourneyPlayers support
27 // added HandleGetPlayerInfo & HandleGetGameInfo
28 //
29 // Revision 1.4  1997/04/13 03:14:35  chess
30 // command class changed to have a parameter list.
31 //
32 // Revision 1.3  1997/04/07 22:21:49  chess
33 // *** empty log message ***
34 //
35 // Revision 1.2  1996/10/03 18:11:10  moses
36 // made sure string are null termindated
37 //
38 // Revision 1.1  1996/10/01  20:14:43  moses
39 // Initial revision
40 //
41 //
42 //--------------------------------------------------------------------------
43
44 #include "Command.hh"
45
46 //- constructor -----------------------------------------------------------
47 Command::Command() {
48     name = alias = description = NULL;
49     managerLevel = USER;
50     userFunction = 0;
51     tournFunction = 0;
52 } //- End of constructor
53
54 Command::Command(char *n, char *a, ranks m, char *d, char *paramTypeList, USERFP u) {
55     name = new char[strlen(n)+1];
56
57     if(NULL == name) return;
58     memset(name, '\0', strlen(n));
59     strncpy(name, n, strlen(n));
60     name[strlen(n)] = '\0';
61
62     memset(parameterList, '\0', MAXNUMPARAMS);
63     strncpy(parameterList, paramTypeList, strlen(paramTypeList));
64     parameterList[strlen(paramTypeList)] = '\0';
65
66     alias = new char[strlen(a)+1];
67     if(NULL == alias) return;
68     memset(alias, '\0', strlen(a));
69     strncpy(alias, a, strlen(a));
70     alias[strlen(a)] = '\0';
71
72     managerLevel = m;
73
74     description = new char[strlen(d)+1];
75     if(NULL == description) return;
76     memset(description, '\0', strlen(d));
77     strncpy(description, d, strlen(d));
78     description[strlen(d)] = '\0';
79
80     userFunction = u;
81 } //- End of constructor
82
83 Command::Command(char *n, char *a, ranks m, char *d, char *paramTypeList, TOURNFP t) {
84     name = new char[strlen(n)+1];
85     if(NULL == name) return;
86     memset(name, '\0', strlen(n));
87     strncpy(name, n, strlen(n));
88     name[strlen(n)] = '\0';
89
90     memset(parameterList, '\0', MAXNUMPARAMS);
91     strncpy(parameterList, paramTypeList, strlen(paramTypeList));
92     parameterList[strlen(paramTypeList)] = '\0';
93
94     alias = new char[strlen(a)+1];
95     if(NULL == alias) return;
96     memset(alias, '\0', strlen(a));
97     strncpy(alias, a, strlen(a));
98     alias[strlen(a)] = '\0';
99
100     managerLevel = m;
101
102     description = new char[strlen(d)+1];
103     if(NULL == description) return;
104     memset(description, '\0', strlen(d));
105     strncpy(description, d, strlen(d));
106     description[strlen(d)] = '\0';
107
108     tournFunction = t;
109 } //- End of constructor
110
111 //- deconstructor ---------------------------------------------------------
112 Command::~Command() {
113     if(NULL != name)
114         delete [] name;
115
116     if(NULL != alias)
117         delete [] alias;
118     
119     if(NULL != description)
120         delete [] description;
121 } //- End of deconstructor
122
123 //- IsCommand ------------------------------------------------------
124 int Command::IsCommand(char *comm) {
125   int length = strlen(comm);
126   if((0 == strncasecmp(comm, name, MIN(length, (int)strlen(name)))) ||
127      (0 == strncasecmp(comm, alias, MIN(length, (int)strlen(alias)))))
128     return(1);
129   
130   return(0);
131 } //- End of IsCommand
132
133 //- GetCommandName ------------------------------------------------
134 char *Command::GetCommandName() {
135   return name;
136 } //- End of GetCommandName 
137
138 //- GetCommandDescription ------------------------------------------------
139 char *Command::GetCommandDescription() {
140   return description;
141 } //- End of GetCommandDescription 
142
143 //- GetCommandAlias ------------------------------------------------
144 char *Command::GetCommandAlias() {
145   return alias;
146 } //- End of GetCommandAlias 
147
148 //- GetManagerLevel -----------------------------------------------
149 ranks Command::GetManagerLevel() {
150   return managerLevel;
151 } //- End of GetManagerLevel
152
153 //- SetManagerLevel -----------------------------------------------
154 void Command::SetManagerLevel(ranks newvalue) {
155   managerLevel = newvalue;
156 } //- end of SetManagerLevel