1 /*
2  * Copyright (c) 1995-2009, 2014-2016, 2018, 2020 Paul Mattes.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the names of Paul Mattes nor the names of his contributors
13  *       may be used to endorse or promote products derived from this software
14  *       without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  *	actions.h
30  *		Global declarations for actions.c.
31  */
32 
33 typedef struct {
34     const char *name;
35     action_t *action;
36     unsigned flags;
37     unsigned help_flags;
38     const char *help_parms;
39     const char *help_text;
40     ia_t ia_restrict;
41 } action_table_t;
42 #define ACTION_KE	0x1	/* action is valid from key events */
43 #define ACTION_HIDDEN	0x2	/* action does not have help or tab expansion */
44 
45 typedef struct action_elt {
46     llist_t list;		/* linkage */
47     action_table_t t;		/* payload */
48 } action_elt_t;
49 
50 extern llist_t actions_list;
51 extern unsigned actions_list_count;
52 
53 extern const char       *ia_name[];
54 
55 extern const char *current_action_name;
56 
57 void action_debug(const char *aname, ia_t ia, unsigned argc,
58 	const char **argv);
59 bool run_action(const char *name, enum iaction cause, const char *parm1,
60 	const char *parm2);
61 bool run_action_a(const char *name, enum iaction cause, unsigned count,
62 	const char **parms);
63 bool run_action_entry(action_elt_t *e, enum iaction cause, unsigned count,
64 	const char **parms);
65 int check_argc(const char *aname, unsigned nargs, unsigned nargs_min,
66 	unsigned nargs_max);
67 void register_actions(action_table_t *actions, unsigned count);
68 char *safe_param(const char *s);
69 void disable_keyboard(bool disable, bool explicit, const char *why);
70 #define DISABLE		true
71 #define ENABLE		false
72 #define EXPLICIT	true
73 #define IMPLICIT	false
74 void force_enable_keyboard(void);
75 bool keyboard_disabled(void);
76 const char *all_actions(void);
77 bool action_args_are(const char *name, ...);
78