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 
23 /**
24  * @file common/p_cmd.h
25  * Includes and prototypes for p_cmd.c for player-commands like '/magicmap'.
26  * Basically stolen piecemeal from the server branch.
27  */
28 
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?) */
63 } ConsoleCommand;
64 
65 extern const ConsoleCommand * find_command(const char * cmd);
66 
67 /**
68  * Fills some internal arrays. Run this on startup, but not before filling in
69  * ToolkitCommands and ToolkitCommandsSize.
70  */
71 extern void init_commands(void);
72 
73 /**
74  * Returns a pointer to the head of an array of ConsoleCommands
75  * sorted by category, then by name.
76  *
77  * It's num_commands long.
78  */
79 ConsoleCommand ** get_cat_sorted_commands(void);
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
95