ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hybrid-ircservices-1/commands.h
Revision: 1209
Committed: Thu Aug 25 19:05:49 2011 UTC (12 years, 7 months ago) by michael
Content type: text/x-chdr
File size: 3968 byte(s)
Log Message:
- run everything thru indent
  "-bli0 -di1 -npcs -nut -cdw -bls -nbbo -bap"

File Contents

# Content
1 /* Declarations for command data.
2 *
3 * IRC Services is copyright (c) 1996-2009 Andrew Church.
4 * E-mail: <achurch@achurch.org>
5 * Parts written by Andrew Kempe and others.
6 * This program is free but copyrighted software; see the file GPL.txt for
7 * details.
8 */
9
10 #ifndef COMMANDS_H
11 #define COMMANDS_H
12
13 /* Note that modules.h MUST be included before this file (for the Module
14 * type). */
15
16 /*************************************************************************/
17
18 /* Structure for information about a *Serv command. */
19
20 typedef struct command_ Command;
21 struct command_
22 {
23 const char *name;
24 void (*routine) (User * u);
25 int (*has_priv) (const User * u); /* Returns 1 if user may use cmd, else 0 */
26 int helpmsg_all; /* Displayed to all users; -1 = no message */
27 int helpmsg_reg; /* Displayed to regular users only */
28 int helpmsg_oper; /* Displayed to IRC operators only */
29 const char *help_param1;
30 const char *help_param2;
31 const char *help_param3;
32 const char *help_param4;
33 Command *next; /* Next command with this name */
34 };
35
36 /*************************************************************************/
37
38 /* Commands must be registered with Services to be usable; an array of
39 * Command structures (terminated with name == NULL) can be registered and
40 * unregistered with the following routines. All routines return 1 on
41 * success, 0 on failure. ("Failure" occurs only when parameters are
42 * invalid.)
43 */
44
45 /* Set up a new command list using the given module pointer as an ID value.
46 * Fails if a command list associated with `id' already exists. */
47 extern int new_commandlist(Module * id);
48
49 /* Register a command array under the given ID. Fails if there is no
50 * command list associated with `id', `array' is NULL, `array' has already
51 * been added to the list, or there are multiple command entries in `array'
52 * with the same name (case-insensitive). If an entry in `array' has the
53 * same name as a previously-registered entry, the entry in `array' will
54 * take precendence, and a pointer to the previous entry will be stored in
55 * the `next' field of the entry. */
56 extern int register_commands(Module * id, Command * array);
57
58 /* Unregister a command array from the given ID. Fails if there is no
59 * command list associated with `id' or `array' was not in the list in the
60 * first place. */
61 extern int unregister_commands(Module * id, Command * array);
62
63 /* Delete the command list associated with the given ID. Fails if there is
64 * no command list associated with `id' or the command list is not empty. */
65 extern int del_commandlist(Module * id);
66
67 /*************************************************************************/
68
69 /* Routines for looking up and doing other things with commands. */
70
71 /* Returns the Command structure associated with the given command for the
72 * given command list (`id'), or NULL if no such command exists. */
73 extern Command *lookup_cmd(Module * id, const char *name);
74
75 /* Runs the routine associated with the given command, sending a help
76 * message if there is no such command or the user does not have privileges
77 * to use the command. Equivalent to
78 * lookup_cmd(id,name)->routine(u)
79 * with privilege and error checking. */
80 extern void run_cmd(const char *service, User * u, Module * id,
81 const char *cmd);
82
83 /* Sends the help message associated with the given command, or a generic
84 * "command not found" message if there is no such command. Multiple
85 * spaces in `cmd' will be compressed to a single space (thus modifying the
86 * string). */
87 extern void help_cmd(const char *service, User * u, Module * id, char *cmd);
88
89 /*************************************************************************/
90
91 #endif /* COMMANDS_H */
92
93 /*
94 * Local variables:
95 * c-file-style: "stroustrup"
96 * c-file-offsets: ((case-label . *) (statement-case-intro . *))
97 * indent-tabs-mode: nil
98 * End:
99 *
100 * vim: expandtab shiftwidth=4:
101 */