/*
- * Copyright (C) 1997-2012 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2013 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
#include <regex.h>
#include <signal.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <osl.h>
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
- gettimeofday(¤t_time, NULL);
+ clock_get_realtime(¤t_time);
/*
* The calls to WRITE_STATUS_ITEM() below never fail because
* b->max_size is zero (unlimited), see para_printf(). However, clang
return send_sb(scc, msg, ret, band, false);
}
+/**
+ * Send an error message to a client.
+ *
+ * \param cc Client info.
+ * \param err The (positive) error code.
+ *
+ * \return The return value of the underlying call to send_sb_va().
+ */
int send_strerror(struct command_context *cc, int err)
{
return cc->use_sideband?
return ret;
}
-int com_sender(struct command_context *cc)
+static int com_sender(struct command_context *cc)
{
int i, ret = 0;
char *msg = NULL;
}
/* server info */
-int com_si(struct command_context *cc)
+static int com_si(struct command_context *cc)
{
int i, ret;
char *msg, *ut, *sender_info = NULL;
free(info);
}
ut = get_server_uptime_str(now);
- ret = xasprintf(&msg, "version: " GIT_VERSION "\n"
+ ret = xasprintf(&msg,
+ "version: %s\n"
"up: %s\nplayed: %u\n"
"server_pid: %d\n"
"afs_pid: %d\n"
"current loglevel: %s\n"
"supported audio formats: %s\n"
"%s",
+ version_git(),
ut, mmd->num_played,
(int)getppid(),
(int)mmd->afs_pid,
mmd->num_commands,
mmd->num_connects,
conf.loglevel_arg,
- SERVER_AUDIO_FORMATS,
+ AUDIO_FORMAT_HANDLERS,
sender_info
);
mutex_unlock(mmd_mutex);
}
/* version */
-int com_version(struct command_context *cc)
+static int com_version(struct command_context *cc)
{
char *msg;
size_t len;
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
- msg = VERSION_TEXT("server") "built: " BUILD_DATE "\n" UNAME_RS
- ", " CC_VERSION "\n";
- len = strlen(msg);
+ len = xasprintf(&msg, "%s", version_text("server"));
if (cc->use_sideband)
- return send_sb(&cc->scc, msg, len, SBD_OUTPUT, true);
+ return send_sb(&cc->scc, msg, len, SBD_OUTPUT, false);
return sc_send_bin_buffer(&cc->scc, msg, len);
}
+/** These status items are cleared if no audio file is currently open. */
#define EMPTY_STATUS_ITEMS \
ITEM(PATH) \
ITEM(DIRECTORY) \
ITEM(YEAR) \
ITEM(ALBUM) \
ITEM(COMMENT) \
- ITEM(AMPLIFICATION)
+ ITEM(MTIME) \
+ ITEM(FILE_SIZE) \
+ ITEM(CHUNK_TIME) \
+ ITEM(NUM_CHUNKS) \
+ ITEM(AMPLIFICATION) \
/**
* Write a list of audio-file related status items with empty values.
*/
static unsigned empty_status_items(int parser_friendly, char **result)
{
- static char *esi;
- static unsigned len;
-
- if (esi)
- goto out;
+ char *esi;
+ unsigned len;
if (parser_friendly)
len = xasprintf(&esi,
EMPTY_STATUS_ITEMS
#undef ITEM
);
-out:
*result = esi;
return len;
}
#undef EMPTY_STATUS_ITEMS
/* stat */
-int com_stat(struct command_context *cc)
+static int com_stat(struct command_context *cc)
{
int i, ret;
struct misc_meta_data tmp, *nmmd = &tmp;
- char *s, *esi = NULL;
+ char *s;
int32_t num = 0;
int parser_friendly = 0;
if (ret < 0)
goto out;
if (nmmd->vss_status_flags & VSS_NEXT) {
+ char *esi;
ret = empty_status_items(parser_friendly, &esi);
if (cc->use_sideband)
ret = send_sb(&cc->scc, esi, ret, SBD_OUTPUT,
- true);
- else
+ false);
+ else {
ret = sc_send_bin_buffer(&cc->scc, esi, ret);
+ free(esi);
+ }
if (ret < 0)
goto out;
} else
goto out;
}
out:
- free(esi);
return ret;
}
}
/* help */
-int com_help(struct command_context *cc)
+static int com_help(struct command_context *cc)
{
struct server_command *cmd;
char *perms, *handler, *buf;
}
/* hup */
-int com_hup(struct command_context *cc)
+static int com_hup(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* term */
-int com_term(struct command_context *cc)
+static int com_term(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
return 1;
}
-int com_play(struct command_context *cc)
+static int com_play(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* stop */
-int com_stop(struct command_context *cc)
+static int com_stop(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* pause */
-int com_pause(struct command_context *cc)
+static int com_pause(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* next */
-int com_next(struct command_context *cc)
+static int com_next(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* nomore */
-int com_nomore(struct command_context *cc)
+static int com_nomore(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* ff */
-int com_ff(struct command_context *cc)
+static int com_ff(struct command_context *cc)
{
long promille;
int ret, backwards = 0;
}
/* jmp */
-int com_jmp(struct command_context *cc)
+static int com_jmp(struct command_context *cc)
{
long unsigned int i;
int ret;
/* send Welcome message */
ret = write_va_buffer(fd, "This is para_server, version "
PACKAGE_VERSION ".\n"
- "Features: sideband,foo\n"
+ "Features: sideband\n"
);
if (ret < 0)
goto net_err;