The opus audio format handler.
[paraslash.git] / command.c
index 72f8e04e7fe949c89bba065c857a0e7d9ab0820c..ec822c82978d78649b6641d2206f41db44ab3bd7 100644 (file)
--- a/command.c
+++ b/command.c
@@ -1,5 +1,5 @@
 /*
- * 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.
  */
@@ -8,7 +8,6 @@
 
 #include <regex.h>
 #include <signal.h>
-#include <sys/time.h>
 #include <sys/types.h>
 #include <osl.h>
 
@@ -36,6 +35,9 @@
 #include "signal.h"
 #include "version.h"
 
+struct server_command afs_cmds[] = {DEFINE_AFS_CMD_ARRAY};
+struct server_command server_cmds[] = {DEFINE_SERVER_CMD_ARRAY};
+
 /** Commands including options must be shorter than this. */
 #define MAX_COMMAND_LEN 32768
 
@@ -121,7 +123,7 @@ static unsigned get_status(struct misc_meta_data *nmmd, int parser_friendly,
                localtime_r(&nmmd->mtime, &mtime_tm);
                strftime(mtime, 29, "%b %d %Y", &mtime_tm);
        }
-       gettimeofday(&current_time, NULL);
+       clock_get_realtime(&current_time);
        /*
         * The calls to WRITE_STATUS_ITEM() below never fail because
         * b->max_size is zero (unlimited), see para_printf(). However, clang
@@ -256,6 +258,14 @@ __printf_3_4 int send_sb_va(struct stream_cipher_context *scc, int band,
        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?
@@ -314,7 +324,7 @@ fail:
        return ret;
 }
 
-int com_sender(struct command_context *cc)
+static int com_sender(struct command_context *cc)
 {
        int i, ret = 0;
        char *msg = NULL;
@@ -371,7 +381,7 @@ int com_sender(struct command_context *cc)
 }
 
 /* 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;
@@ -400,7 +410,7 @@ int com_si(struct command_context *cc)
                mmd->num_commands,
                mmd->num_connects,
                conf.loglevel_arg,
-               SERVER_AUDIO_FORMATS,
+               AUDIO_FORMAT_HANDLERS,
                sender_info
        );
        mutex_unlock(mmd_mutex);
@@ -414,7 +424,7 @@ int com_si(struct command_context *cc)
 }
 
 /* version */
-int com_version(struct command_context *cc)
+static int com_version(struct command_context *cc)
 {
        char *msg;
        size_t len;
@@ -495,7 +505,7 @@ out:
 #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;
@@ -605,7 +615,7 @@ static struct server_command *get_cmd_ptr(const char *name, char **handler)
 }
 
 /* help */
-int com_help(struct command_context *cc)
+static int com_help(struct command_context *cc)
 {
        struct server_command *cmd;
        char *perms, *handler, *buf;
@@ -644,7 +654,7 @@ int com_help(struct command_context *cc)
 }
 
 /* hup */
-int com_hup(struct command_context *cc)
+static int com_hup(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -653,7 +663,7 @@ int com_hup(struct command_context *cc)
 }
 
 /* term */
-int com_term(struct command_context *cc)
+static int com_term(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -661,7 +671,7 @@ int com_term(struct command_context *cc)
        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;
@@ -673,7 +683,7 @@ int com_play(struct command_context *cc)
 }
 
 /* stop */
-int com_stop(struct command_context *cc)
+static int com_stop(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -686,7 +696,7 @@ int com_stop(struct command_context *cc)
 }
 
 /* pause */
-int com_pause(struct command_context *cc)
+static int com_pause(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -701,7 +711,7 @@ int com_pause(struct command_context *cc)
 }
 
 /* next */
-int com_next(struct command_context *cc)
+static int com_next(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -713,7 +723,7 @@ int com_next(struct command_context *cc)
 }
 
 /* nomore */
-int com_nomore(struct command_context *cc)
+static int com_nomore(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -725,7 +735,7 @@ int com_nomore(struct command_context *cc)
 }
 
 /* ff */
-int com_ff(struct command_context *cc)
+static int com_ff(struct command_context *cc)
 {
        long promille;
        int ret, backwards = 0;
@@ -764,7 +774,7 @@ out:
 }
 
 /* jmp */
-int com_jmp(struct command_context *cc)
+static int com_jmp(struct command_context *cc)
 {
        long unsigned int i;
        int ret;
@@ -981,7 +991,7 @@ __noreturn void handle_connect(int fd, const char *peername)
        /* 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;