[Freeciv-Dev] Re: [RFC PATCH] init_techs
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
--- Justin Moore <justin@xxxxxxxxxxx> wrote:
> If the command they entered was invalid, tell them so. The command
> struct could easily be modified to facilitate a change by associating a
> function pointer with it. Thus:
>
> typedef void (*command_func)(char *args);
>
> struct command {
> char *name; /* name - will be matched by unique prefix */
> enum cmdlevel_id level; /* access level required to use the command */
> char *synopsis; /* one or few-line summary of usage */
> char *short_help; /* one line (about 70 chars) description */
> char *extra_help; /* extra help information; will be line-wrapped */
> command_func *fptr; /* Pointer to a callback function */
> };
To allow functions that take a list, the command should have a content model:
enum command_content {
CMD_STR,
CMD_INT,
CMD_STR_LIST,
CMD_INT_LIST
};
Or something. Otherwise the callback functions have to typecheck their
arguments. If the parsing code typechecks, the callback functions can be:
typedef void (*int_command_func) (int);
typedef void (*str_command_func) (char *);
typedef void (*int_list_command_func) (int, int *);
typedef void (*str_list_command_func) (int, char **);
(For the list callbacks, the first function is the size of the list).
Arien
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.
http://im.yahoo.com
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), (continued)
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/27
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Reinier Post, 2001/09/28
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/28
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Reinier Post, 2001/09/30
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/30
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/28
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/28
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Raimar Falke, 2001/09/30
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/30
- [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs), Ross W. Wetmore, 2001/09/25
- [Freeciv-Dev] Re: [RFC PATCH] init_techs,
Arien Malec <=
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/22
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Daniel L Speyer, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Raimar Falke, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/24
|
|