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
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.
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
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
29 *****************************************************************************/
31 /*****************************************************************************
32 * intf_arg_t: control fonction argument descriptor
33 *****************************************************************************
34 * This structure is used to control an argument type and to transmit
35 * arguments to control functions. It is also used to parse format string and
36 * build an easier to use array of arguments.
37 *****************************************************************************/
41 int i_flags; /* argument type and flags */
42 int i_index; /* index of mask in format string */
44 /* Converted arguments value */
45 char * psz_str; /* string value */
46 char * ps_name; /* name, can be '\0' or '=' terminated */
47 long i_num; /* integer value */
48 float f_num; /* float value */
52 #define INTF_STR_ARG 1 /* string argument */
53 #define INTF_INT_ARG 2 /* integer argument */
54 #define INTF_FLOAT_ARG 4 /* float argument */
55 #define INTF_NAMED_ARG 16 /* named argument */
56 #define INTF_OPT_ARG 256 /* optionnal argument */
57 #define INTF_REP_ARG 512 /* argument can be repeated */
58 #define INTF_PRESENT_ARG 1024 /* argument has been encountered */
60 /*****************************************************************************
61 * intf_command_t: control command descriptor
62 *****************************************************************************
63 * This structure describes a control commands. It stores informations needed
64 * for argument type checking, command execution but also a short inline help.
65 * See control.c for more informations about fields.
66 *****************************************************************************/
69 /* Function control */
70 char * psz_name; /* command name */
71 int (* function)( int i_argc, intf_arg_t *p_argv ); /* function */
72 char * psz_format; /* arguments format */
74 /* Function informations */
75 char * psz_summary; /* info text */
76 char * psz_usage; /* usage text */
77 char * psz_help; /* help text */
80 /*****************************************************************************
82 *****************************************************************************
83 * These errors should be used as return values for control functions (see
84 * control.c). The intf_ExecCommand function as different behaviour depending
85 * of the error it received. Other errors numbers can be used, but their valued
86 * should be positive to avoid conflict with future error codes.
87 *****************************************************************************/
89 #define INTF_NO_ERROR 0 /* success */
90 #define INTF_FATAL_ERROR -1 /* fatal error: the program will end */
91 #define INTF_CRITICAL_ERROR -2 /* critical error: the program will exit */
92 #define INTF_USAGE_ERROR -3 /* usage error: command usage will be displayed */
93 #define INTF_OTHER_ERROR -4/* other error: command prints its own message */
95 /*****************************************************************************
97 *****************************************************************************/
98 int intf_ExecCommand ( char *psz_cmd );
99 int intf_ExecScript ( char *psz_filename );