1
/*
2
 * Copyright 2008-2011 Various Authors
3
 * Copyright 2004-2006 Timo Hirvonen
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License as
7
 * published by the Free Software Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
#ifndef _COMMAND_MODE_H
20
#define _COMMAND_MODE_H
21
22
#include "uchar.h"
23
24
enum {
25
	/* executing command is disabled over net */
26
	CMD_UNSAFE	= 1 << 0,
27
	/* execute command after every typed/deleted character */
28
	CMD_LIVE	= 1 << 1,
29
};
30
31
struct command {
32
	const char *name;
33
	void (*func)(char *arg);
34
35
	/* min/max number of arguments */
36
	int min_args;
37
	int max_args;
38
39
	void (*expand)(const char *str);
40
41
	/* bind count (0 means: unbound) */
42
	int bc;
43
44
	/* CMD_* */
45
	unsigned int flags;
46
};
47
48
extern struct command commands[];
49
extern int run_only_safe_commands;
50
51
void command_mode_ch(uchar ch);
52
void command_mode_escape(int c);
53
void command_mode_key(int key);
54
void commands_init(void);
55
void commands_exit(void);
56
int parse_command(const char *buf, char **cmdp, char **argp);
57
void run_parsed_command(char *cmd, char *arg);
58
void run_command(const char *buf);
59
60
struct command *get_command(const char *str);
61
62
void view_clear(int view);
63
void view_add(int view, char *arg, int prepend);
64
void view_load(int view, char *arg);
65
void view_save(int view, char *arg, int to_stdout, int filtered, int extended);
66
67
#endif