Exemple #1
0
int command_process(netcon_client_t *netcon_client, const char *command) {
  char *tokens[MAX_TOKENS];
  char str[1024];
  int num_tokens;

  syslog(LOG_DEBUG, "Command: %s", command);

  // Make a copy of the command since we modify it
  strncpy(str, command, sizeof(str));

  num_tokens = str_split(str, tokens, MAX_TOKENS, ' ');
  if (num_tokens == 0) {
    return 0;
  }

  if (strcmp(tokens[0], "get") == 0) {
    command_get(netcon_client, tokens, num_tokens);
  } else if (strcmp(tokens[0], "toggle") == 0) {
    command_toggle(netcon_client, tokens, num_tokens);
  } else if (strcmp(tokens[0], "exit") == 0) {
    command_exit(netcon_client, tokens, num_tokens);
  } else {
    syslog(LOG_WARNING, "Invalid command: %s", command);
  }

  return 0;
}
Exemple #2
0
static gboolean _command_exit_command_function (const char* line) {
    gboolean result;
    result = command_exit (line);
    return result;
}