diff --git a/extensions/test/inc/test.h b/extensions/test/inc/test.h new file mode 100644 index 0000000..1f97066 --- /dev/null +++ b/extensions/test/inc/test.h @@ -0,0 +1,30 @@ +/* + * @Author: your name + * @Date: 2021-09-22 22:33:24 + * @LastEditTime: 2021-09-22 22:52:45 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: /xcmd/extensions/test/test.h + */ + +#ifndef TEST_H +#define TEST_H + +#include "xcmd.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +void test_cmd_init(void); +void test_keys_init(void); + +#ifdef __cplusplus + } +#endif + + +#endif /* TEST_H */ + + diff --git a/extensions/test/src/test.c b/extensions/test/src/test.c new file mode 100644 index 0000000..86cad59 --- /dev/null +++ b/extensions/test/src/test.c @@ -0,0 +1,128 @@ +/* + * @Author: your name + * @Date: 2021-09-22 22:33:17 + * @LastEditTime: 2021-09-22 23:17:02 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: /xcmd/extensions/test/test.c + */ +#include "test.h" +#include +#include + +#define EXIT_MESSAGE() xcmd_print(g_cmder, "press \"q\" or \"Q\" to exit!\r\n") + +#define EXIT_CHECK() \ + do \ + (toupper(GET_CHAR()) == 'Q') \ + { \ + uint8_t c; \ + if (GET_CHAR(&c)) \ + { \ + switch (c) \ + case 'q': \ + case 'Q': \ + case 0x1B: \ + return; \ + } \ + } \ + while (0); + +static uint8_t param_check(int need, int argc, char*argv[]) +{ + uint8_t i,ret = 0; + if(need<(argc)) + { + ret = 1; + } + else + { + xcmd_print("err need %d but input %d:\r\n", need, argc-1); + xcmd_print("input= "); + for(i=0; i