xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/uffs/src/emu/cmdline.h (revision 104654410c56c573564690304ae786df310c91fc)
1*10465441SEvalZero /*
2*10465441SEvalZero   This file is part of UFFS, the Ultra-low-cost Flash File System.
3*10465441SEvalZero 
4*10465441SEvalZero   Copyright (C) 2005-2009 Ricky Zheng <[email protected]>
5*10465441SEvalZero 
6*10465441SEvalZero   UFFS is free software; you can redistribute it and/or modify it under
7*10465441SEvalZero   the GNU Library General Public License as published by the Free Software
8*10465441SEvalZero   Foundation; either version 2 of the License, or (at your option) any
9*10465441SEvalZero   later version.
10*10465441SEvalZero 
11*10465441SEvalZero   UFFS is distributed in the hope that it will be useful, but WITHOUT
12*10465441SEvalZero   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*10465441SEvalZero   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*10465441SEvalZero   or GNU Library General Public License, as applicable, for more details.
15*10465441SEvalZero 
16*10465441SEvalZero   You should have received a copy of the GNU General Public License
17*10465441SEvalZero   and GNU Library General Public License along with UFFS; if not, write
18*10465441SEvalZero   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19*10465441SEvalZero   Boston, MA  02110-1301, USA.
20*10465441SEvalZero 
21*10465441SEvalZero   As a special exception, if other files instantiate templates or use
22*10465441SEvalZero   macros or inline functions from this file, or you compile this file
23*10465441SEvalZero   and link it with other works to produce a work based on this file,
24*10465441SEvalZero   this file does not by itself cause the resulting work to be covered
25*10465441SEvalZero   by the GNU General Public License. However the source code for this
26*10465441SEvalZero   file must still be made available in accordance with section (3) of
27*10465441SEvalZero   the GNU General Public License v2.
28*10465441SEvalZero 
29*10465441SEvalZero   This exception does not invalidate any other reasons why a work based
30*10465441SEvalZero   on this file might be covered by the GNU General Public License.
31*10465441SEvalZero */
32*10465441SEvalZero 
33*10465441SEvalZero 
34*10465441SEvalZero #ifndef _UFFS_CLI_H_
35*10465441SEvalZero #define _UFFS_CLI_H_
36*10465441SEvalZero 
37*10465441SEvalZero #ifndef BOOL
38*10465441SEvalZero #define BOOL int
39*10465441SEvalZero #endif
40*10465441SEvalZero 
41*10465441SEvalZero #ifndef TRUE
42*10465441SEvalZero #define TRUE 1
43*10465441SEvalZero #endif
44*10465441SEvalZero #ifndef FALSE
45*10465441SEvalZero #define FALSE 0
46*10465441SEvalZero #endif
47*10465441SEvalZero 
48*10465441SEvalZero #define CLI_INVALID_ARG			-100
49*10465441SEvalZero 
50*10465441SEvalZero typedef int command_t(int argc, char *argv[]);
51*10465441SEvalZero 
52*10465441SEvalZero struct cli_command {
53*10465441SEvalZero     command_t *handler;
54*10465441SEvalZero     const char *cmd;
55*10465441SEvalZero     const char *args;
56*10465441SEvalZero     const char *descr;
57*10465441SEvalZero };
58*10465441SEvalZero 
59*10465441SEvalZero struct cli_commandset {
60*10465441SEvalZero 	const struct cli_command *cmds;
61*10465441SEvalZero 	struct cli_commandset *next;
62*10465441SEvalZero };
63*10465441SEvalZero 
64*10465441SEvalZero void cli_add_commandset(struct cli_commandset *set);
65*10465441SEvalZero int cli_interpret(const char *line);
66*10465441SEvalZero int cli_env_get(char env);
67*10465441SEvalZero int cli_env_set(char env, int val);
68*10465441SEvalZero void cli_main_entry();
69*10465441SEvalZero 
70*10465441SEvalZero #define u_assert(x) \
71*10465441SEvalZero 	((x) ? TRUE : \
72*10465441SEvalZero 			(uffs_PerrorRaw(UFFS_MSG_NORMAL, \
73*10465441SEvalZero 				"Assert failed at %s:%s:%d: '%s' is not true.\n", \
74*10465441SEvalZero 				__FILE__, __FUNCTION__, __LINE__, #x), FALSE))
75*10465441SEvalZero 
76*10465441SEvalZero 
77*10465441SEvalZero #define CHK_ARGC(min, max) \
78*10465441SEvalZero 	if (argc < min || (max > 0 && argc > max)) \
79*10465441SEvalZero 		return CLI_INVALID_ARG
80*10465441SEvalZero 
81*10465441SEvalZero #endif
82*10465441SEvalZero 
83*10465441SEvalZero 
84