]> git.sesse.net Git - vlc/blob - src/interface/intf_cmd.h
Encore un commit venu tout droit des abysses de l'enfer, d�sol� pour
[vlc] / src / interface / intf_cmd.h
1 /*****************************************************************************
2  * intf_cmd.h: interface commands parsing and executions functions
3  * This file implements the interface commands execution functions. It is used
4  * by command-line oriented interfaces and scripts. The commands themselves are
5  * implemented in intf_ctrl.
6  *****************************************************************************
7  * Copyright (C) 1999, 2000 VideoLAN
8  *
9  * Authors:
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this program; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Required headers:
29  *  none
30  *****************************************************************************/
31
32 /*****************************************************************************
33  * intf_arg_t: control fonction argument descriptor
34  *****************************************************************************
35  * This structure is used to control an argument type and to transmit
36  * arguments to control functions. It is also used to parse format string and
37  * build an easier to use array of arguments.
38  *****************************************************************************/
39 typedef struct
40 {
41     /* Argument type */
42     int         i_flags;                          /* argument type and flags */
43     int         i_index;                   /* index of mask in format string */
44
45     /* Converted arguments value */
46     char *      psz_str;                                     /* string value */
47     char *      ps_name;              /* name, can be '\0' or '=' terminated */
48     long        i_num;                                      /* integer value */
49     float       f_num;                                        /* float value */
50 } intf_arg_t;
51
52 /* Arguments flags */
53 #define INTF_STR_ARG            1                         /* string argument */
54 #define INTF_INT_ARG            2                        /* integer argument */
55 #define INTF_FLOAT_ARG          4                          /* float argument */
56 #define INTF_NAMED_ARG          16                         /* named argument */
57 #define INTF_OPT_ARG            256                    /* optionnal argument */
58 #define INTF_REP_ARG            512              /* argument can be repeated */
59 #define INTF_PRESENT_ARG        1024        /* argument has been encountered */
60
61 /*****************************************************************************
62  * intf_command_t: control command descriptor
63  *****************************************************************************
64  * This structure describes a control commands. It stores informations needed
65  * for argument type checking, command execution but also a short inline help.
66  * See control.c for more informations about fields.
67  *****************************************************************************/
68 typedef struct
69 {
70     /* Function control */
71     char *          psz_name;                                /* command name */
72     int (* function)( int i_argc, intf_arg_t *p_argv );          /* function */
73     char *          psz_format;                          /* arguments format */
74
75     /* Function informations */
76     char *          psz_summary;                                /* info text */
77     char *          psz_usage;                                 /* usage text */
78     char *          psz_help;                                   /* help text */
79 } intf_command_t;
80
81 /*****************************************************************************
82  * Error constants
83  *****************************************************************************
84  * These errors should be used as return values for control functions (see
85  * control.c). The intf_ExecCommand function as different behaviour depending
86  * of the error it received. Other errors numbers can be used, but their valued
87  * should be positive to avoid conflict with future error codes.
88  *****************************************************************************/
89
90 #define INTF_NO_ERROR       0                                     /* success */
91 #define INTF_FATAL_ERROR    -1          /* fatal error: the program will end */
92 #define INTF_CRITICAL_ERROR -2      /* critical error: the program will exit */
93 #define INTF_USAGE_ERROR    -3 /* usage error: command usage will be displayed */
94 #define INTF_OTHER_ERROR    -4/* other error: command prints its own message */
95
96 /*****************************************************************************
97  * Prototypes
98  *****************************************************************************/
99 int intf_ExecCommand    ( char *psz_cmd );
100 int intf_ExecScript     ( char *psz_filename );