示例#1
0
文件: result.c 项目: Acidburn0zzz/mpd
void
command_error_v(struct client *client, enum ack error,
		const char *fmt, va_list args)
{
	assert(client != NULL);
	assert(current_command != NULL);

	client_printf(client, "ACK [%i@%i] {%s} ",
		      (int)error, command_list_num, current_command);
	client_vprintf(client, fmt, args);
	client_puts(client, "\n");

	current_command = NULL;
}
示例#2
0
文件: client.c 项目: rsenn/tichu
/* -------------------------------------------------------------------------- *
 * Schreibt einen Log-Eintrag auf die Konsole oder auf stderr                 *
 * -------------------------------------------------------------------------- */
void client_write(int mod, int lev, const char *s, ...)
{
  char    msg[4096];
  va_list args;
  size_t  n = 0;
  
  if(lev > LOGLEVEL)
    return;
  
  va_start(args, s);
  
  strncpy(&msg[n], client_symbols[mod], sizeof(msg) - n);
  n += 3;
  msg[n++] = ' ';
  
#if defined(DEBUG) && defined(DEBUG_TICKS)
  {
    uint32_t ticks = (client_subsystems ? SDL_GetTicks() : 0);
    sprintf(&msg[n], "(%04u.%03u)", (ticks / 1000) % 10000, ticks % 1000);
    n += 10;
    msg[n++] = ' ';
  }
#endif
  
  strncpy(&msg[n], client_modules[mod], sizeof(msg) - n);
  n += strlen(&msg[n]);
  msg[n++] = ':';
  msg[n++] = ' ';
  
  vsnprintf(&msg[n], sizeof(msg) - n, s, args);
  
  /* Auf die aktive Konsole damit */
  if(lev <= CONSOLE)
    client_puts("%s", &msg[n]);
  
  if(lev != CONSOLE)
    fprintf(stderr, "%s\n", msg);
  
  va_end(args);
  
  if(lev == ERROR)
    client_shutdown();
}
示例#3
0
static enum command_return
client_process_command_list(struct client *client, bool list_ok, GSList *list)
{
    enum command_return ret = COMMAND_RETURN_OK;
    unsigned num = 0;

    for (GSList *cur = list; cur != NULL; cur = g_slist_next(cur)) {
        char *cmd = cur->data;

        g_debug("command_process_list: process command \"%s\"",
        cmd);
        ret = command_process(client, num++, cmd);
        g_debug("command_process_list: command returned %i", ret);
        if (ret != COMMAND_RETURN_OK || client_is_expired(client))
            break;
        else if (list_ok)
            client_puts(client, "list_OK\n");
    }

    return ret;
}
示例#4
0
文件: client.c 项目: azuwis/mpd
/**
 * Send "idle" response to this client.
 */
static void
client_idle_notify(struct client *client)
{
    unsigned flags, i;
    const char *const* idle_names;

    assert(client->idle_waiting);
    assert(client->idle_flags != 0);

    flags = client->idle_flags;
    client->idle_flags = 0;
    client->idle_waiting = false;

    idle_names = idle_get_names();
    for (i = 0; idle_names[i]; ++i) {
        if (flags & (1 << i) & client->idle_subscriptions)
            client_printf(client, "changed: %s\n",
                          idle_names[i]);
    }

    client_puts(client, "OK\n");
    client->lastTime = time(NULL);
}
示例#5
0
文件: result.c 项目: Acidburn0zzz/mpd
void
command_success(struct client *client)
{
	client_puts(client, "OK\n");
}