// // Created by MightyPork on 2018/12/02. // #ifndef CSPEMU_CMD_COMMON_H #define CSPEMU_CMD_COMMON_H #include "console_server.h" //// prototypes (TODO remove..) //void csp_vprintf(const char *format, va_list args); //void csp_printf(const char *format, ...); #define EOL "\r\n" #define console_printf_e(format, ...) console_printf("\x1b[31m" format "\x1b[m", ##__VA_ARGS__) #define console_printf_w(format, ...) console_printf("\x1b[33m" format "\x1b[m", ##__VA_ARGS__) #define console_fputs(str) console_print(str) #define console_fputsn(str, len) console_write(str, len) #define console_fputc(c) console_write(&c, 1) #define MSG_ON "\x1b[32mON\x1b[m" #define MSG_ENABLED "\x1b[32mENABLED\x1b[m" #define MSG_OFF "\x1b[31mOFF\x1b[m" #define MSG_DISABLED "\x1b[31mDISABLED\x1b[m" //#define ARG_OPTIONAL_NODE_ID() cmd_args.node->count ? cmd_args.node->ival[0] : csp_get_address() #if 0 struct cmd_no_args_s { struct arg_end *end; }; extern struct cmd_no_args_s cmd_no_args; #define CMD_CHECK_ARGS(struct_var) do { \ int nerrors = arg_parse(argc, argv, (void**) &struct_var); \ if (nerrors != 0) { \ console_print_errors(struct_var.end, argv[0]); \ return 1; \ } \ } while(0) /** Report & return error if any args were given to this command */ #define CMD_CHECK_NO_ARGS() CMD_CHECK_ARGS(cmd_no_args) #endif #endif //CSPEMU_CMD_COMMON_H