1#define _CRT_SECURE_NO_WARNINGS
10void send_message(ptrCLIENTINFO info,
char* msg, ...)
12 char sendMSG[2 * BUFSIZ];
15 vsprintf(sendMSG, msg, l);
16 if (info->clientType == CLIENTTYPE_SOCKET)
17 send_to_socket(info, sendMSG, (
int)strlen(sendMSG) + 1);
18 else if (info->clientType == CLIENTTYPE_FILE)
19 write_to_file(info, sendMSG, (
int)strlen(sendMSG) + 1);
20 else if (info->clientType == CLIENTTYPE_STRING)
21 add_to_string(info, sendMSG, (
int)strlen(sendMSG) + 1);
24static void commandProcessor(ptrCLIENTINFO info,
char* command)
26 ptrCOMMANDARRAY ls = get_commandArray(command);
27 char* first = ls->commands[0];
28 if (!_stricmp(first, CMD_CONTINUE))
29 cli_continue_simulation(info);
30 else if (!_stricmp(first, CMD_PAUSE))
31 cli_pause_simulation(info);
32 else if (!_stricmp(first, CMD_PAUSEAT))
33 cli_pause_simulation_at(info, atof(ls->commands[1]));
34 else if (!_stricmp(first, CMD_STOP))
35 cli_stop_simulation(info);
36 else if (!_stricmp(first, CMD_EXIT))
37 cli_clear_prompt(info);
40 if (validate_command(info, ls))
42 if (isCommandAsDeviceName(ls->commands[0]))
44 pass_to_SDNModule(info, ls);
48 execute_command(info, ls, info->deviceId);
53 free_commandArray(ls);
56void process_command(ptrCLIENTINFO clientInfo,
char* command,
int len)
58 commandProcessor(clientInfo, command);