/* * Creates and returns a command from the specified command name. */ command* command::create (const char *name) { #define CREATE_HANDLER(NAME) [] { return static_cast<command *> (new cmd_##NAME ()); } #define DEFINE_CMD(NAME) { #NAME , CREATE_HANDLER(NAME) } const static std::unordered_map<std::string, command* (*) ()> _map { DEFINE_CMD(help) }; auto itr = _map.find (name); if (itr == _map.end ()) return nullptr; return itr->second (); }
void h2o_headers_register_configurator(h2o_globalconf_t *conf) { struct headers_configurator_t *c = (void *)h2o_configurator_create(conf, sizeof(*c)); c->super.enter = on_config_enter; c->super.exit = on_config_exit; #define DEFINE_CMD(name, cb) \ h2o_configurator_define_command(&c->super, name, H2O_CONFIGURATOR_FLAG_ALL_LEVELS | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR, cb) DEFINE_CMD("header.add", on_config_header_add); DEFINE_CMD("header.append", on_config_header_append); DEFINE_CMD("header.merge", on_config_header_merge); DEFINE_CMD("header.set", on_config_header_set); DEFINE_CMD("header.setifempty", on_config_header_setifempty); DEFINE_CMD("header.unset", on_config_header_unset); #undef DEFINE_CMD c->cmds = c->_cmd_stack; }
void h2o_headers_register_configurator(h2o_globalconf_t *conf) { struct headers_configurator_t *c = (void *)h2o_configurator_create(conf, sizeof(*c)); c->super.enter = on_config_enter; c->super.exit = on_config_exit; #define DEFINE_CMD(name, cb, desc) \ h2o_configurator_define_command(&c->super, name, H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_HOST | \ H2O_CONFIGURATOR_FLAG_PATH | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR, \ cb, desc) DEFINE_CMD("header.add", on_config_header_add, "adds a new header line to the response headers"); DEFINE_CMD("header.append", on_config_header_append, "adds a new header line, or appends the value to the existing header with\n" "the same name (separated by `,`)"); DEFINE_CMD("header.merge", on_config_header_merge, "adds a new header line, or merges the value to the existing header of\n" "comma-separated values"); DEFINE_CMD("header.set", on_config_header_set, "sets a header line, removing headers with the same name (if exist)"); DEFINE_CMD("header.setifempty", on_config_header_setifempty, "sets a header line, only when a header with the same name does not exist"); DEFINE_CMD("header.unset", on_config_header_unset, "removes headers with the specified name"); #undef DEFINE_CMD c->cmds = c->_cmd_stack; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) Microsoft Corporation. All rights reserved. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "..\core\Core.h" #include <TinyCLR_Debugging.h> #define DEFINE_CMD(cmd) { CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd } #define DEFINE_CMD2(cmd) { CLR_DBG_Debugger::Monitor_##cmd , CLR_DBG_Commands::c_Monitor_##cmd } #define DEFINE_CMD3(cmd) { &CLR_DBG_Debugger::Profiling_##cmd, CLR_DBG_Commands::c_Profiling_##cmd } const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] = { DEFINE_CMD(Execution_QueryCLRCapabilities), DEFINE_CMD2(Ping ), DEFINE_CMD2(ReadMemory ), DEFINE_CMD2(WriteMemory), DEFINE_CMD2(CheckMemory), DEFINE_CMD2(EraseMemory), // DEFINE_CMD2(Execute ), DEFINE_CMD2(Reboot ), DEFINE_CMD2(MemoryMap ), DEFINE_CMD2(FlashSectorMap), DEFINE_CMD2(DeploymentMap), // DEFINE_CMD(Execution_BasePtr ), DEFINE_CMD(Execution_ChangeConditions), // DEFINE_CMD(Execution_Allocate ),
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) Microsoft Corporation. All rights reserved. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "..\core\Core.h" #include <TinyCLR_Debugging.h> #define DEFINE_CMD(cmd) { CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd } #define DEFINE_CMD2(cmd) { CLR_DBG_Debugger::Monitor_##cmd , CLR_DBG_Commands::c_Monitor_##cmd } const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] = { DEFINE_CMD2(Ping ), DEFINE_CMD2(Reboot ), DEFINE_CMD(Execution_QueryCLRCapabilities), DEFINE_CMD2(ReadMemory ), DEFINE_CMD2(WriteMemory), DEFINE_CMD2(EraseMemory), // DEFINE_CMD2(Execute ), DEFINE_CMD2(MemoryMap ), DEFINE_CMD2(FlashSectorMap), DEFINE_CMD(UpgradeToSsl), DEFINE_CMD(MFUpdate_Start ), DEFINE_CMD(MFUpdate_AuthCommand ), DEFINE_CMD(MFUpdate_Authenticate ), DEFINE_CMD(MFUpdate_GetMissingPkts ), DEFINE_CMD(MFUpdate_AddPacket ),
void cmdFuncZCP(char *param) { // printf("Hello, I'm help function %s\r\n", ":)"); int i; MOTOR* p; p = &(motor[M2_IDX]); sscanf(param, "%d", &i); zcp = i; } const shellCmd_t shellCmdTable[] = { DEFINE_CMD(Help), DEFINE_CMD(Start), DEFINE_CMD(Pwm), DEFINE_CMD(Time), DEFINE_CMD(ZCP), }; #define CMD_NUM (sizeof shellCmdTable / sizeof shellCmdTable[0]) void shellPrintCR() { printf("\r\n"); } void shellPrintR() {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) Microsoft Corporation. All rights reserved. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "..\core\Core.h" #include <TinyCLR_Debugging.h> #define DEFINE_CMD(cmd) { CLR_DBG_Debugger::Debugging_##cmd, CLR_DBG_Commands::c_Debugging_##cmd } #define DEFINE_CMD2(cmd) { CLR_DBG_Debugger::Monitor_##cmd , CLR_DBG_Commands::c_Monitor_##cmd } #define DEFINE_CMD3(cmd) { &CLR_DBG_Debugger::Profiling_##cmd, CLR_DBG_Commands::c_Profiling_##cmd } const CLR_Messaging_CommandHandlerLookup c_Debugger_Lookup_Request[] = { DEFINE_CMD(Execution_QueryCLRCapabilities), DEFINE_CMD2(Ping ), DEFINE_CMD2(ReadMemory ), DEFINE_CMD2(WriteMemory), DEFINE_CMD2(CheckMemory), DEFINE_CMD2(EraseMemory), // DEFINE_CMD2(Execute ), DEFINE_CMD2(Reboot ), DEFINE_CMD2(MemoryMap ), DEFINE_CMD2(FlashSectorMap), // DEFINE_CMD(Execution_BasePtr ), DEFINE_CMD(Execution_ChangeConditions), // DEFINE_CMD(Execution_Allocate ), // #if defined(TINYCLR_PROFILE_NEW)