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