예제 #1
0
static gint
slng_verbose(int argc, char *argv[], const gchar *mode)
{
  gint ret = 0;
  GString *rsp = NULL;
  gchar buff[256];

  if (!verbose_set)
    snprintf(buff, 255, "LOG %s\n", mode);
  else
    snprintf(buff, 255, "LOG %s %s\n", mode,
        strncasecmp(verbose_set, "on", 2) == 0 || verbose_set[0] == '1' ? "ON" : "OFF");

  g_strup(buff);

  rsp = slng_run_command(buff);
  if (rsp == NULL)
    return 1;

  if (!verbose_set)
    printf("%s\n", rsp->str);
  else
    ret = g_str_equal(rsp->str, "OK");

  g_string_free(rsp, TRUE);

  return ret;
}
예제 #2
0
static gint
slng_verbose(int argc, char *argv[], const gchar *mode, GOptionContext *ctx)
{
  gint ret = 0;
  GString *rsp = NULL;
  gchar buff[256];

  if (!verbose_set)
    g_snprintf(buff, 255, "LOG %s\n", mode);
  else
    g_snprintf(buff, 255, "LOG %s %s\n", mode,
               strncasecmp(verbose_set, "on", 2) == 0 || verbose_set[0] == '1' ? "ON" : "OFF");

  g_strup(buff);

  rsp = slng_run_command(buff);
  if (rsp == NULL)
    return 1;

  ret = _process_response_status(rsp);
  printf("%s\n", rsp->str);

  g_string_free(rsp, TRUE);

  return ret;
}
예제 #3
0
static gint
slng_reload(int argc, char *argv[], const gchar *mode)
{
  GString *rsp = slng_run_command("RELOAD\n");

  if (rsp == NULL)
    return 1;

  printf("%s\n", rsp->str);

  g_string_free(rsp, TRUE);

  return 0;
}
예제 #4
0
static gint
slng_stats(int argc, char *argv[], const gchar *mode)
{
  GString *rsp = slng_run_command(_stats_command_builder());

  if (rsp == NULL)
    return 1;

  printf("%s\n", rsp->str);

  g_string_free(rsp, TRUE);

  return 0;
}
예제 #5
0
static gint
_dispatch_command(const gchar *cmd)
{
  gint retval = 0;
  gchar *dispatchable_command = g_strdup_printf("%s\n", cmd);
  GString *rsp = slng_run_command(dispatchable_command);

  if (_is_response_empty(rsp))
    {
      retval = 1;
    }
  else
    {
      retval = _process_response_status(rsp);
      printf("%s\n", rsp->str);
    }

  clear_and_free(rsp);

  secret_storage_wipe(dispatchable_command, strlen(dispatchable_command));
  g_free(dispatchable_command);

  return retval;
}