File: p_cmd.h

package info (click to toggle)
crossfire-client 1.11.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,036 kB
  • ctags: 2,857
  • sloc: ansic: 30,030; sh: 3,238; makefile: 248; perl: 48
file content (112 lines) | stat: -rw-r--r-- 3,725 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
    Crossfire client, a client program for the crossfire program.

    Copyright (C) 2005 Mark Wedel & Crossfire Development Team

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    The author can be reached via e-mail to crossfire-devel@real-time.com
*/


/*
 * Includes and prototypes for p_cmd.c.
 *
 * p_cmd.c has player-commands like '/magicmap'.
 */


/* Basically stolen piecemeal from the server branch. */

#ifndef PCMD_H
#define PCMD_H

/*
 * List of commands.
 */

typedef void (*CommFunc)(const char *params);

/* Cargo-cult from the above. Every entry in the table
 * complains about a type mismatch, too. :(
 */
typedef const char * (*CommHelpFunc)(void);

/* This is used for displaying lists of commands. */
typedef enum {
  COMM_CAT_MISC = 0,    /* Commands which can't be better sorted. */
  COMM_CAT_HELP = 1,
  COMM_CAT_INFO = 2,    /* A tad general. */
  COMM_CAT_SETUP = 3,   /* showicon, showweight, bind, commandkey... */
  COMM_CAT_SCRIPT = 4,  /* The four commands for the nifty-scripts. */
  COMM_CAT_DEBUG = 5,   /* Debugging commands - hide these? */
} CommCat;

/* Retrieves a Title Cased name for the above categories. */
const char * get_category_name(CommCat cat);


typedef struct {        /* global list's structure */
  const char * name;    /* Name of command - parsed against this. */
  CommCat cat;          /* What category the command is in. Used for sorting on display. */
  CommFunc dofunc;      /* If name is matched, this is called. */
  /* TODO Too specific? *sigh* Resolving *that* issue gives me a headache. */
  CommHelpFunc helpfunc;/* Returns a string documenting the command. - the *really* long desc. */
  const char * desc;    /* One-liner describing command. (Man page subtitle, anyone?) */
} ConsoleCommand;

extern const ConsoleCommand * find_command(const char * cmd);

/* Define this to let the toolkit give an array of toolkit-specific commands. */
#undef TOOLKIT_COMMANDS
#ifdef TOOLKIT_COMMANDS
extern ConsoleCommand ToolkitCommands[];
extern const int ToolkitCommandsSize;

/* Not defined in common, called at the very top of init_commands()
   so a toolkit can fill ToolkitCommands and ToolkitCommandsSize in.
*/
extern void init_toolkit_commands(void);
#endif

/**
 * Fills some internal arrays. Run this on startup, but not before filling in
 * ToolkitCommands and ToolkitCommandsSize.
 */
extern void init_commands(void);

extern int get_num_commands(void);
/**
 * Returns a pointer to the head of an array of ConsoleCommands
 * sorted by category, then by name.
 *
 * It's num_commands long.
 */
ConsoleCommand ** get_cat_sorted_commands(void);

/* Used only for searching the commands list for help, er. ... Oh, well. */
extern const ConsoleCommand * find_command(const char * cmd);

/* This searches ClientCommands; if there's nothing in there, it goes to the server.
 * With some exceptions. :(
 */
extern void extended_command(const char *ocommand);

extern const char * complete_command(const char * ocommand);

extern int handle_local_command(const char* cp, const char * cpnext);


#endif