void run(const std::string & cmd, OscOptionalUnpacker & msg) { if(cmd == "color") { int r,g,b,a; a = 255; msg >> r >> g >> b >> a; cmd_color(r,g,b,a); }
static void call_cmd_from_index( BaseSequentialStream *chp, int argc, char *argv[], uint8_t cmd_index){ switch (cmd_index){ case CMD_ACCEL: cmd_accel(chp, argc, argv); break; case CMD_COLOR: cmd_color(chp, argc, argv); break; case CMD_LED: cmd_led(chp, argc, argv); break; case CMD_LOOP: cmd_loop(chp, argc, argv); break; } }
void command_parse(const u08 *cmd, u08 len) { u08 result = 0; switch(cmd[0]) { case 'c': result = cmd_color(cmd,len); break; case 'f': result = cmd_flags(cmd, len); break; case 'd': result = cmd_draw(cmd, len); break; case 'g': result = cmd_goto(cmd, len); break; case 'e': result = cmd_erase(cmd, len); break; case 's': /* do nothing - only return status */ result = CMD_OK; break; case 'q': result = cmd_query(cmd, len); break; case 'i': result = cmd_input(cmd, len); break; case 'p': result = cmd_picture(cmd, len); break; case 'y': result = cmd_display(cmd, len); break; default: result = CMD_UNKNOWN_ERR; break; } // report status back if(result != CMD_NO_REPLY) { cmd_status(result); } }
/* chatbuf points to the auto array in rcv_chat + 1 */ void command_chat (struct htlc_conn *htlc, u_int32_t cid, char *chatbuf) { if (!chatbuf[0]) return; switch (chatbuf[0]) { case '0': if (!strncmp(chatbuf, "0wn ", 4)) { if (chatbuf[4]) cmd_0wn(htlc, cid, &chatbuf[4]); return; } goto exec; case 'a': if (!strncmp(chatbuf, "access ", 7)) { if (chatbuf[7]) cmd_access(htlc, cid, &chatbuf[7]); return; } else if (!strncmp(chatbuf, "away", 4)) { if (htlc->flags.away == AWAY_INTERRUPTED) return; toggle_away(htlc); if (!htlc->flags.away) htlc->flags.away = AWAY_PERM; else htlc->flags.away = 0; if (hxd_cfg.options.away_time) { timer_delete_ptr(htlc); if (!htlc->flags.away) timer_add_secs(hxd_cfg.options.away_time, away_timer, htlc); } return; } else if (!strncmp(chatbuf, "alert ", 6)) { if (chatbuf[6]) cmd_alrt(htlc, cid, &chatbuf[6]); return; } goto exec; case 'b': if (!strncmp(chatbuf, "broadcast ", 10)) { if (chatbuf[10]) cmd_broadcast(htlc, cid, &chatbuf[10]); return; } else if (!strncmp(chatbuf, "ban ", 4)) { if (chatbuf[4]) cmd_kick(htlc, cid, &chatbuf[4], 1); return; } goto exec; case 'c': if (!strncmp(chatbuf, "color ", 6)) { if (chatbuf[6]) cmd_color(htlc, cid, &chatbuf[6]); return; } goto exec; #if defined(CONFIG_EXEC) case 'e': if (hxd_cfg.operation.exec) { if (!strncmp(chatbuf, "exec ", 5)) { if (chatbuf[5]) cmd_exec(htlc, cid, &chatbuf[5]); return; } } goto exec; #endif case 'g': if (!strncmp(chatbuf, "g0away", 6)) { cmd_visible(htlc, cid); return; } goto exec; case 'k': if (!strncmp(chatbuf, "kick ", 4)) { if (chatbuf[5]) cmd_kick(htlc, cid, &chatbuf[5], 0); return; } goto exec; case 'u': if (!strncmp(chatbuf, "users", 5)) { cmd_users(htlc, cid); return; } goto exec; case 'v': if (!strncmp(chatbuf, "visible", 7)) { cmd_visible(htlc, cid); return; } else if (!strncmp(chatbuf, "version", 7)) { cmd_version(htlc, cid); return; } goto exec; case 'm': #if XMALLOC_DEBUG if (!strncmp(chatbuf, "maltbl", 6) && htlc->access_extra.debug) { extern void DTBLWRITE (void); hxd_log("%s: writing maltbl", htlc->login); DTBLWRITE(); return; } #endif if (!strncmp(chatbuf, "me ", 3)) { if (chatbuf[3]) cmd_me(htlc, cid, &chatbuf[3]); return; } else if (!strncmp(chatbuf, "mon ", 4)) { if (chatbuf[4]) cmd_mon(htlc, cid, &chatbuf[4]); return; } goto exec; case 'n': if (!strncmp(chatbuf, "nick ", 5) && (htlc->access.use_any_name && !htlc->access_extra.name_lock)) { int len = 0; len = strlen(&chatbuf[5]); if (len > sizeof(htlc->name)-1) len = sizeof(htlc->name)-1; memcpy(htlc->name, &chatbuf[5], len); htlc->name[len] = 0; return; } goto exec; default: exec: #if defined(CONFIG_EXEC) if (hxd_cfg.operation.exec) { cmd_exec(htlc, cid, chatbuf); } else #endif cmd_notfound(htlc, cid, chatbuf); break; } }