Crossfire Client, Trunk
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. */
46  COMM_CAT_INFO = 2, /* A tad general. */
47  COMM_CAT_SETUP = 3, /* showicon, showweight, bind, commandkey... */
48  COMM_CAT_SCRIPT = 4, /* The four commands for the nifty-scripts. */
49  COMM_CAT_DEBUG = 5, /* Debugging commands - hide these? */
50 } CommCat;
51 
52 /* Retrieves a Title Cased name for the above categories. */
53 const char * get_category_name(CommCat cat);
54 
55 
56 typedef struct { /* global list's structure */
57  const char * name; /* Name of command - parsed against this. */
58  CommCat cat; /* What category the command is in. Used for sorting on display. */
59  CommFunc dofunc; /* If name is matched, this is called. */
60  /* TODO Too specific? *sigh* Resolving *that* issue gives me a headache. */
61  CommHelpFunc helpfunc;/* Returns a string documenting the command. - the *really* long desc. */
62  const char * desc; /* One-liner describing command. (Man page subtitle, anyone?) */
64 
65 extern const ConsoleCommand * find_command(const char * cmd);
66 
71 extern void init_commands(void);
72 
80 
81 /* Used only for searching the commands list for help, er. ... Oh, well. */
82 extern const ConsoleCommand * find_command(const char * cmd);
83 
84 /* This searches ClientCommands; if there's nothing in there, it goes to the server.
85  * With some exceptions. :(
86  */
87 extern void extended_command(const char *ocommand);
88 
89 extern const char * complete_command(const char * ocommand);
90 
91 extern int handle_local_command(const char* cp, const char * cpnext);
92 
93 
94 #endif
COMM_CAT_INFO
@ COMM_CAT_INFO
Definition: p_cmd.h:46
get_category_name
const char * get_category_name(CommCat cat)
Definition: p_cmd.c:166
ConsoleCommand::name
const char * name
Definition: p_cmd.h:57
COMM_CAT_MISC
@ COMM_CAT_MISC
Definition: p_cmd.h:45
CommCat
CommCat
Definition: p_cmd.h:44
handle_local_command
int handle_local_command(const char *cp, const char *cpnext)
Definition: p_cmd.c:481
CommHelpFunc
const typedef char *(* CommHelpFunc)(void)
Definition: p_cmd.h:41
complete_command
const char * complete_command(const char *ocommand)
Definition: p_cmd.c:614
ConsoleCommand::cat
CommCat cat
Definition: p_cmd.h:58
COMM_CAT_DEBUG
@ COMM_CAT_DEBUG
Definition: p_cmd.h:49
COMM_CAT_SCRIPT
@ COMM_CAT_SCRIPT
Definition: p_cmd.h:48
COMM_CAT_SETUP
@ COMM_CAT_SETUP
Definition: p_cmd.h:47
find_command
const ConsoleCommand * find_command(const char *cmd)
Definition: p_cmd.c:428
ConsoleCommand::dofunc
CommFunc dofunc
Definition: p_cmd.h:59
get_cat_sorted_commands
ConsoleCommand ** get_cat_sorted_commands(void)
Definition: p_cmd.c:468
ConsoleCommand::helpfunc
CommHelpFunc helpfunc
Definition: p_cmd.h:61
ConsoleCommand
Definition: p_cmd.h:56
ConsoleCommand::desc
const char * desc
Definition: p_cmd.h:62
extended_command
void extended_command(const char *ocommand)
Definition: p_cmd.c:515
init_commands
void init_commands(void)
Definition: p_cmd.c:407
CommFunc
void(* CommFunc)(const char *params)
Definition: p_cmd.h:36