Crossfire Client, Trunk  R19673
p_cmd.h
Go to the documentation of this file.
1 /*
2  Crossfire client, a client program for the crossfire program.
3 
4  Copyright (C) 2005 Mark Wedel & Crossfire Development Team
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 
20  The author can be reached via e-mail to crossfire-devel@real-time.com
21 */
22 
29 #ifndef PCMD_H
30 #define PCMD_H
31 
32 /*
33  * List of commands.
34  */
35 
36 typedef void (*CommFunc)(const char *params);
37 
38 /* Cargo-cult from the above. Every entry in the table
39  * complains about a type mismatch, too. :(
40  */
41 typedef const char * (*CommHelpFunc)(void);
42 
43 /* This is used for displaying lists of commands. */
44 typedef enum {
45  COMM_CAT_MISC = 0, /* Commands which can't be better sorted. */
47  COMM_CAT_INFO = 2, /* A tad general. */
48  COMM_CAT_SETUP = 3, /* showicon, showweight, bind, commandkey... */
49  COMM_CAT_SCRIPT = 4, /* The four commands for the nifty-scripts. */
50  COMM_CAT_DEBUG = 5, /* Debugging commands - hide these? */
51 } CommCat;
52 
53 /* Retrieves a Title Cased name for the above categories. */
54 const char * get_category_name(CommCat cat);
55 
56 
57 typedef struct { /* global list's structure */
58  const char * name; /* Name of command - parsed against this. */
59  CommCat cat; /* What category the command is in. Used for sorting on display. */
60  CommFunc dofunc; /* If name is matched, this is called. */
61  /* TODO Too specific? *sigh* Resolving *that* issue gives me a headache. */
62  CommHelpFunc helpfunc;/* Returns a string documenting the command. - the *really* long desc. */
63  const char * desc; /* One-liner describing command. (Man page subtitle, anyone?) */
65 
66 extern const ConsoleCommand * find_command(const char * cmd);
67 
68 /* Define this to let the toolkit give an array of toolkit-specific commands. */
69 #undef TOOLKIT_COMMANDS
70 #ifdef TOOLKIT_COMMANDS
71 extern ConsoleCommand ToolkitCommands[];
72 extern const int ToolkitCommandsSize;
73 
74 /* Not defined in common, called at the very top of init_commands()
75  so a toolkit can fill ToolkitCommands and ToolkitCommandsSize in.
76 */
77 extern void init_toolkit_commands(void);
78 #endif
79 
84 extern void init_commands(void);
85 
86 extern int get_num_commands(void);
94 
95 /* Used only for searching the commands list for help, er. ... Oh, well. */
96 extern const ConsoleCommand * find_command(const char * cmd);
97 
98 /* This searches ClientCommands; if there's nothing in there, it goes to the server.
99  * With some exceptions. :(
100  */
101 extern void extended_command(const char *ocommand);
102 
103 extern const char * complete_command(const char * ocommand);
104 
105 extern int handle_local_command(const char* cp, const char * cpnext);
106 
107 
108 #endif
const char * get_category_name(CommCat cat)
Definition: p_cmd.c:366
int get_num_commands(void)
Definition: p_cmd.c:857
CommFunc dofunc
Definition: p_cmd.h:60
const char *(* CommHelpFunc)(void)
Definition: p_cmd.h:41
CommCat cat
Definition: p_cmd.h:59
CommCat
Definition: p_cmd.h:44
void extended_command(const char *ocommand)
This is an extended command (ie, 'who, 'whatever, etc).
Definition: p_cmd.c:1044
const char * desc
Definition: p_cmd.h:63
const char * name
Definition: p_cmd.h:58
int handle_local_command(const char *cp, const char *cpnext)
Tries to handle command cp (with optional params in cpnext, which may be null) as a local command...
Definition: p_cmd.c:1009
void(* CommFunc)(const char *params)
Definition: p_cmd.h:36
const ConsoleCommand * find_command(const char *cmd)
Definition: p_cmd.c:954
CommHelpFunc helpfunc
Definition: p_cmd.h:62
const char * complete_command(const char *ocommand)
Player has entered 'command' and hit tab to complete it.
Definition: p_cmd.c:1144
void init_commands(void)
Fills some internal arrays.
Definition: p_cmd.c:902
ConsoleCommand ** get_cat_sorted_commands(void)
Returns a pointer to the head of an array of ConsoleCommands sorted by category, then by name...
Definition: p_cmd.c:995