void cli_shutdown(struct cli_state *cli) { struct cli_state *cli_head; if (cli == NULL) { return; } DLIST_HEAD(cli, cli_head); if (cli_head == cli) { /* * head of a DFS list, shutdown all subsidiary DFS * connections. */ struct cli_state *p, *next; for (p = cli_head->next; p; p = next) { next = p->next; DLIST_REMOVE(cli_head, p); _cli_shutdown(p); } } else { DLIST_REMOVE(cli_head, cli); } _cli_shutdown(cli); }
void *engine_cli_run(void *args) { engine *p_engine = (engine *) args; char input[ENGINE_CLI_BUFFER_SIZE]; while (p_engine->keep_running) { printf("TTS >: "); memset(input, 0, ENGINE_CLI_BUFFER_SIZE); scanf("%s", input); if (!strcmp(input, "exit")) { _cli_shutdown(p_engine); } else if (!strcmp(input, "clients")) { _cli_list_clients(&p_engine->netadapter); } else if (!strcmp(input, "connections")) { _cli_list_connections(&p_engine->netadapter); } else if (!strcmp(input, "status")) { _cli_status(p_engine); } else if (!strcmp(input, "rooms")) { _cli_list_rooms(p_engine); } } glog(LOG_FINE, "Engine CLI: Exittig"); return NULL; }