Crossfire Client, Branch  R11627
p_cmd.h
Go to the documentation of this file.
00001 /*
00002     Crossfire client, a client program for the crossfire program.
00003 
00004     Copyright (C) 2005 Mark Wedel & Crossfire Development Team
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 
00020     The author can be reached via e-mail to crossfire-devel@real-time.com
00021 */
00022 
00023 
00024 /*
00025  * Includes and prototypes for p_cmd.c.
00026  *
00027  * p_cmd.c has player-commands like '/magicmap'.
00028  */
00029 
00030 
00031 /* Basically stolen piecemeal from the server branch. */
00032 
00033 #ifndef PCMD_H
00034 #define PCMD_H
00035 
00036 /*
00037  * List of commands.
00038  */
00039 
00040 typedef void (*CommFunc)(const char *params);
00041 
00042 /* Cargo-cult from the above. Every entry in the table
00043  * complains about a type mismatch, too. :(
00044  */
00045 typedef const char * (*CommHelpFunc)(void);
00046 
00047 /* This is used for displaying lists of commands. */
00048 typedef enum {
00049   COMM_CAT_MISC = 0,    /* Commands which can't be better sorted. */
00050   COMM_CAT_HELP = 1,
00051   COMM_CAT_INFO = 2,    /* A tad general. */
00052   COMM_CAT_SETUP = 3,   /* showicon, showweight, bind, commandkey... */
00053   COMM_CAT_SCRIPT = 4,  /* The four commands for the nifty-scripts. */
00054   COMM_CAT_DEBUG = 5,   /* Debugging commands - hide these? */
00055 } CommCat;
00056 
00057 /* Retrieves a Title Cased name for the above categories. */
00058 const char * get_category_name(CommCat cat);
00059 
00060 
00061 typedef struct {        /* global list's structure */
00062   const char * name;    /* Name of command - parsed against this. */
00063   CommCat cat;          /* What category the command is in. Used for sorting on display. */
00064   CommFunc dofunc;      /* If name is matched, this is called. */
00065   /* TODO Too specific? *sigh* Resolving *that* issue gives me a headache. */
00066   CommHelpFunc helpfunc;/* Returns a string documenting the command. - the *really* long desc. */
00067   const char * desc;    /* One-liner describing command. (Man page subtitle, anyone?) */
00068 } ConsoleCommand;
00069 
00070 extern const ConsoleCommand * find_command(const char * cmd);
00071 
00072 /* Define this to let the toolkit give an array of toolkit-specific commands. */
00073 #undef TOOLKIT_COMMANDS
00074 #ifdef TOOLKIT_COMMANDS
00075 extern ConsoleCommand ToolkitCommands[];
00076 extern const int ToolkitCommandsSize;
00077 
00078 /* Not defined in common, called at the very top of init_commands()
00079    so a toolkit can fill ToolkitCommands and ToolkitCommandsSize in.
00080 */
00081 extern void init_toolkit_commands(void);
00082 #endif
00083 
00088 extern void init_commands(void);
00089 
00090 extern int get_num_commands(void);
00097 ConsoleCommand ** get_cat_sorted_commands(void);
00098 
00099 /* Used only for searching the commands list for help, er. ... Oh, well. */
00100 extern const ConsoleCommand * find_command(const char * cmd);
00101 
00102 /* This searches ClientCommands; if there's nothing in there, it goes to the server.
00103  * With some exceptions. :(
00104  */
00105 extern void extended_command(const char *ocommand);
00106 
00107 extern const char * complete_command(const char * ocommand);
00108 
00109 extern int handle_local_command(const char* cp, const char * cpnext);
00110 
00111 
00112 #endif