]> git.sesse.net Git - vlc/blob - src/interface/intf_cmd.h
c83ebe02f4fae5d748761248d6a39ef950ecc39f
[vlc] / src / interface / intf_cmd.h
1 /*****************************************************************************
2  * intf_cmd.h: interface commands parsing and executions functions
3  * (c)1999 VideoLAN
4  *****************************************************************************
5  * This file implements the interface commands execution functions. It is used
6  * by command-line oriented interfaces and scripts. The commands themselves are
7  * implemented in intf_ctrl.
8  *****************************************************************************
9  * Required headers:
10  *  none
11  *****************************************************************************/
12
13 /*****************************************************************************
14  * intf_arg_t: control fonction argument descriptor
15  *****************************************************************************
16  * This structure is used to control an argument type and to transmit
17  * arguments to control functions. It is also used to parse format string and
18  * build an easier to use array of arguments.
19  *****************************************************************************/
20 typedef struct
21 {
22     /* Argument type */
23     int         i_flags;                          /* argument type and flags */
24     int         i_index;                   /* index of mask in format string */
25
26     /* Converted arguments value */
27     char *      psz_str;                                     /* string value */
28     char *      ps_name;              /* name, can be '\0' or '=' terminated */
29     long        i_num;                                      /* integer value */
30     float       f_num;                                        /* float value */
31 } intf_arg_t;
32
33 /* Arguments flags */
34 #define INTF_STR_ARG            1                         /* string argument */
35 #define INTF_INT_ARG            2                        /* integer argument */
36 #define INTF_FLOAT_ARG          4                          /* float argument */
37 #define INTF_NAMED_ARG          16                         /* named argument */
38 #define INTF_OPT_ARG            256                    /* optionnal argument */
39 #define INTF_REP_ARG            512              /* argument can be repeated */
40 #define INTF_PRESENT_ARG        1024        /* argument has been encountered */
41
42 /*****************************************************************************
43  * intf_command_t: control command descriptor
44  *****************************************************************************
45  * This structure describes a control commands. It stores informations needed
46  * for argument type checking, command execution but also a short inline help.
47  * See control.c for more informations about fields.
48  *****************************************************************************/
49 typedef struct
50 {
51     /* Function control */
52     char *          psz_name;                                /* command name */
53     int (* function)( int i_argc, intf_arg_t *p_argv );          /* function */
54     char *          psz_format;                          /* arguments format */
55
56     /* Function informations */
57     char *          psz_summary;                                /* info text */
58     char *          psz_usage;                                 /* usage text */
59     char *          psz_help;                                   /* help text */
60 } intf_command_t;
61
62 /*****************************************************************************
63  * Error constants
64  *****************************************************************************
65  * These errors should be used as return values for control functions (see
66  * control.c). The intf_ExecCommand function as different behaviour depending
67  * of the error it received. Other errors numbers can be used, but their valued
68  * should be positive to avoid conflict with future error codes.
69  *****************************************************************************/
70
71 #define INTF_NO_ERROR       0                                     /* success */
72 #define INTF_FATAL_ERROR    -1          /* fatal error: the program will end */
73 #define INTF_CRITICAL_ERROR -2      /* critical error: the program will exit */
74 #define INTF_USAGE_ERROR    -3 /* usage error: command usage will be displayed */
75 #define INTF_OTHER_ERROR    -4/* other error: command prints its own message */
76
77 /*****************************************************************************
78  * Prototypes
79  *****************************************************************************/
80 int intf_ExecCommand    ( char *psz_cmd );
81 int intf_ExecScript     ( char *psz_filename );