Crossfire Client, Trunk  R19362
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 
00029 #ifndef PCMD_H
00030 #define PCMD_H
00031 
00032 /*
00033  * List of commands.
00034  */
00035 
00036 typedef void (*CommFunc)(const char *params);
00037 
00038 /* Cargo-cult from the above. Every entry in the table
00039  * complains about a type mismatch, too. :(
00040  */
00041 typedef const char * (*CommHelpFunc)(void);
00042 
00043 /* This is used for displaying lists of commands. */
00044 typedef enum {
00045   COMM_CAT_MISC = 0,    /* Commands which can't be better sorted. */
00046   COMM_CAT_HELP = 1,
00047   COMM_CAT_INFO = 2,    /* A tad general. */
00048   COMM_CAT_SETUP = 3,   /* showicon, showweight, bind, commandkey... */
00049   COMM_CAT_SCRIPT = 4,  /* The four commands for the nifty-scripts. */
00050   COMM_CAT_DEBUG = 5,   /* Debugging commands - hide these? */
00051 } CommCat;
00052 
00053 /* Retrieves a Title Cased name for the above categories. */
00054 const char * get_category_name(CommCat cat);
00055 
00056 
00057 typedef struct {        /* global list's structure */
00058   const char * name;    /* Name of command - parsed against this. */
00059   CommCat cat;          /* What category the command is in. Used for sorting on display. */
00060   CommFunc dofunc;      /* If name is matched, this is called. */
00061   /* TODO Too specific? *sigh* Resolving *that* issue gives me a headache. */
00062   CommHelpFunc helpfunc;/* Returns a string documenting the command. - the *really* long desc. */
00063   const char * desc;    /* One-liner describing command. (Man page subtitle, anyone?) */
00064 } ConsoleCommand;
00065 
00066 extern const ConsoleCommand * find_command(const char * cmd);
00067 
00068 /* Define this to let the toolkit give an array of toolkit-specific commands. */
00069 #undef TOOLKIT_COMMANDS
00070 #ifdef TOOLKIT_COMMANDS
00071 extern ConsoleCommand ToolkitCommands[];
00072 extern const int ToolkitCommandsSize;
00073 
00074 /* Not defined in common, called at the very top of init_commands()
00075    so a toolkit can fill ToolkitCommands and ToolkitCommandsSize in.
00076 */
00077 extern void init_toolkit_commands(void);
00078 #endif
00079 
00084 extern void init_commands(void);
00085 
00086 extern int get_num_commands(void);
00093 ConsoleCommand ** get_cat_sorted_commands(void);
00094 
00095 /* Used only for searching the commands list for help, er. ... Oh, well. */
00096 extern const ConsoleCommand * find_command(const char * cmd);
00097 
00098 /* This searches ClientCommands; if there's nothing in there, it goes to the server.
00099  * With some exceptions. :(
00100  */
00101 extern void extended_command(const char *ocommand);
00102 
00103 extern const char * complete_command(const char * ocommand);
00104 
00105 extern int handle_local_command(const char* cp, const char * cpnext);
00106 
00107 
00108 #endif