]> code.delx.au - pulseaudio/blobdiff - src/daemon/cmdline.c
daemon: Drop --module-idle-time from docs
[pulseaudio] / src / daemon / cmdline.c
index a3f1ff032f7c5a76ffc333f3303716aef1cc6da5..2c4c4b513f911cabaf47086e80416c7eec382dab 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -7,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
 #include <config.h>
 #endif
 
-#include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <getopt.h>
-#include <sys/stat.h>
 
 #include <pulse/xmalloc.h>
+#include <pulse/util.h>
 
 #include <pulsecore/core-util.h>
+#include <pulsecore/i18n.h>
 #include <pulsecore/strbuf.h>
 #include <pulsecore/macro.h>
 
@@ -49,11 +47,15 @@ enum {
     ARG_FAIL,
     ARG_LOG_LEVEL,
     ARG_HIGH_PRIORITY,
+    ARG_REALTIME,
     ARG_DISALLOW_MODULE_LOADING,
+    ARG_DISALLOW_EXIT,
     ARG_EXIT_IDLE_TIME,
-    ARG_MODULE_IDLE_TIME,
     ARG_SCACHE_IDLE_TIME,
     ARG_LOG_TARGET,
+    ARG_LOG_META,
+    ARG_LOG_TIME,
+    ARG_LOG_BACKTRACE,
     ARG_LOAD,
     ARG_FILE,
     ARG_DL_SEARCH_PATH,
@@ -64,11 +66,13 @@ enum {
     ARG_NO_CPU_LIMIT,
     ARG_DISABLE_SHM,
     ARG_DUMP_RESAMPLE_METHODS,
-    ARG_SYSTEM
+    ARG_SYSTEM,
+    ARG_CLEANUP_SHM,
+    ARG_START
 };
 
-/* Tabel for getopt_long() */
-static struct option long_options[] = {
+/* Table for getopt_long() */
+static const struct option long_options[] = {
     {"help",                        0, 0, ARG_HELP},
     {"version",                     0, 0, ARG_VERSION},
     {"dump-conf",                   0, 0, ARG_DUMP_CONF},
@@ -78,64 +82,73 @@ static struct option long_options[] = {
     {"verbose",                     2, 0, ARG_LOG_LEVEL},
     {"log-level",                   2, 0, ARG_LOG_LEVEL},
     {"high-priority",               2, 0, ARG_HIGH_PRIORITY},
+    {"realtime",                    2, 0, ARG_REALTIME},
     {"disallow-module-loading",     2, 0, ARG_DISALLOW_MODULE_LOADING},
-    {"exit-idle-time",              2, 0, ARG_EXIT_IDLE_TIME},
-    {"module-idle-time",            2, 0, ARG_MODULE_IDLE_TIME},
-    {"scache-idle-time",            2, 0, ARG_SCACHE_IDLE_TIME},
+    {"disallow-exit",               2, 0, ARG_DISALLOW_EXIT},
+    {"exit-idle-time",              1, 0, ARG_EXIT_IDLE_TIME},
+    {"scache-idle-time",            1, 0, ARG_SCACHE_IDLE_TIME},
     {"log-target",                  1, 0, ARG_LOG_TARGET},
+    {"log-meta",                    2, 0, ARG_LOG_META},
+    {"log-time",                    2, 0, ARG_LOG_TIME},
+    {"log-backtrace",               1, 0, ARG_LOG_BACKTRACE},
     {"load",                        1, 0, ARG_LOAD},
     {"file",                        1, 0, ARG_FILE},
     {"dl-search-path",              1, 0, ARG_DL_SEARCH_PATH},
     {"resample-method",             1, 0, ARG_RESAMPLE_METHOD},
     {"kill",                        0, 0, ARG_KILL},
+    {"start",                       0, 0, ARG_START},
     {"use-pid-file",                2, 0, ARG_USE_PID_FILE},
     {"check",                       0, 0, ARG_CHECK},
     {"system",                      2, 0, ARG_SYSTEM},
     {"no-cpu-limit",                2, 0, ARG_NO_CPU_LIMIT},
     {"disable-shm",                 2, 0, ARG_DISABLE_SHM},
     {"dump-resample-methods",       2, 0, ARG_DUMP_RESAMPLE_METHODS},
+    {"cleanup-shm",                 2, 0, ARG_CLEANUP_SHM},
     {NULL, 0, 0, 0}
 };
 
 void pa_cmdline_help(const char *argv0) {
-    const char *e;
-
     pa_assert(argv0);
-    
-    if ((e = strrchr(argv0, '/')))
-        e++;
-    else
-        e = argv0;
 
-    printf("%s [options]\n\n"
+    printf(_("%s [options]\n\n"
            "COMMANDS:\n"
            "  -h, --help                            Show this help\n"
            "      --version                         Show version\n"
            "      --dump-conf                       Dump default configuration\n"
            "      --dump-modules                    Dump list of available modules\n"
            "      --dump-resample-methods           Dump available resample methods\n"
+           "      --cleanup-shm                     Cleanup stale shared memory segments\n"
+           "      --start                           Start the daemon if it is not running\n"
            "  -k  --kill                            Kill a running daemon\n"
-           "      --check                           Check for a running daemon\n\n"
+           "      --check                           Check for a running daemon (only returns exit code)\n\n"
 
            "OPTIONS:\n"
            "      --system[=BOOL]                   Run as system-wide instance\n"
            "  -D, --daemonize[=BOOL]                Daemonize after startup\n"
            "      --fail[=BOOL]                     Quit when startup fails\n"
-           "      --high-priority[=BOOL]            Try to set high process priority\n"
-           "                                        (only available as root)\n"
-           "      --disallow-module-loading[=BOOL]  Disallow module loading after startup\n"
+           "      --high-priority[=BOOL]            Try to set high nice level\n"
+           "                                        (only available as root, when SUID or\n"
+           "                                        with elevated RLIMIT_NICE)\n"
+           "      --realtime[=BOOL]                 Try to enable realtime scheduling\n"
+           "                                        (only available as root, when SUID or\n"
+           "                                        with elevated RLIMIT_RTPRIO)\n"
+           "      --disallow-module-loading[=BOOL]  Disallow module user requested module\n"
+           "                                        loading/unloading after startup\n"
+           "      --disallow-exit[=BOOL]            Disallow user requested exit\n"
            "      --exit-idle-time=SECS             Terminate the daemon when idle and this\n"
            "                                        time passed\n"
-           "      --module-idle-time=SECS           Unload autoloaded modules when idle and\n"
-           "                                        this time passed\n"
            "      --scache-idle-time=SECS           Unload autoloaded samples when idle and\n"
            "                                        this time passed\n"
            "      --log-level[=LEVEL]               Increase or set verbosity level\n"
            "  -v                                    Increase the verbosity level\n"
-           "      --log-target={auto,syslog,stderr} Specify the log target\n"
+           "      --log-target={auto,syslog,stderr,file:PATH}\n"
+           "                                        Specify the log target\n"
+           "      --log-meta[=BOOL]                 Include code location in log messages\n"
+           "      --log-time[=BOOL]                 Include timestamps in log messages\n"
+           "      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
            "  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
            "                                        objects (plugins)\n"
-           "      --resample-method=[METHOD]        Use the specified resampling method\n"
+           "      --resample-method=METHOD          Use the specified resampling method\n"
            "                                        (See --dump-resample-methods for\n"
            "                                        possible values)\n"
            "      --use-pid-file[=BOOL]             Create a PID file\n"
@@ -150,13 +163,14 @@ void pa_cmdline_help(const char *argv0) {
            "  -C                                    Open a command line on the running TTY\n"
            "                                        after startup\n\n"
 
-           "  -n                                    Don't load default script file\n", e);
+           "  -n                                    Don't load default script file\n"),
+           pa_path_get_filename(argv0));
 }
 
 int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
     pa_strbuf *buf = NULL;
     int c;
-    
+
     pa_assert(conf);
     pa_assert(argc > 0);
     pa_assert(argv);
@@ -188,12 +202,21 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
             case ARG_DUMP_RESAMPLE_METHODS:
                 conf->cmd = PA_CMD_DUMP_RESAMPLE_METHODS;
                 break;
-                
+
+            case ARG_CLEANUP_SHM:
+                conf->cmd = PA_CMD_CLEANUP_SHM;
+                break;
+
             case 'k':
             case ARG_KILL:
                 conf->cmd = PA_CMD_KILL;
                 break;
 
+            case ARG_START:
+                conf->cmd = PA_CMD_START;
+                conf->daemonize = TRUE;
+                break;
+
             case ARG_CHECK:
                 conf->cmd = PA_CMD_CHECK;
                 break;
@@ -217,15 +240,15 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_DAEMONIZE:
             case 'D':
-                if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--daemonize expects boolean argument");
+                if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--daemonize expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_FAIL:
-                if ((conf->fail = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--fail expects boolean argument");
+                if ((conf->fail = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--fail expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -235,7 +258,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
                 if (optarg) {
                     if (pa_daemon_conf_set_log_level(conf, optarg) < 0) {
-                        pa_log("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error).");
+                        pa_log(_("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."));
                         goto fail;
                     }
                 } else {
@@ -246,22 +269,36 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
                 break;
 
             case ARG_HIGH_PRIORITY:
-                if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--high-priority expects boolean argument");
+                if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--high-priority expects boolean argument"));
+                    goto fail;
+                }
+                break;
+
+            case ARG_REALTIME:
+                if ((conf->realtime_scheduling = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--realtime expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_DISALLOW_MODULE_LOADING:
-                if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--disallow-module-loading expects boolean argument");
+                if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--disallow-module-loading expects boolean argument"));
+                    goto fail;
+                }
+                break;
+
+            case ARG_DISALLOW_EXIT:
+                if ((conf->disallow_exit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--disallow-exit expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_USE_PID_FILE:
-                if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--use-pid-file expects boolean argument");
+                if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--use-pid-file expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -273,23 +310,36 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
                 break;
 
             case 'n':
-                pa_xfree(conf->default_script_file);
-                conf->default_script_file = NULL;
+                conf->load_default_script_file = FALSE;
                 break;
 
             case ARG_LOG_TARGET:
                 if (pa_daemon_conf_set_log_target(conf, optarg) < 0) {
-                    pa_log("Invalid log target: use either 'syslog', 'stderr' or 'auto'.");
+                    pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>'."));
                     goto fail;
                 }
                 break;
 
-            case ARG_EXIT_IDLE_TIME:
-                conf->exit_idle_time = atoi(optarg);
+            case ARG_LOG_TIME:
+                if ((conf->log_time = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--log-time expects boolean argument"));
+                    goto fail;
+                }
                 break;
 
-            case ARG_MODULE_IDLE_TIME:
-                conf->module_idle_time = atoi(optarg);
+            case ARG_LOG_META:
+                if ((conf->log_meta = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--log-meta expects boolean argument"));
+                    goto fail;
+                }
+                break;
+
+            case ARG_LOG_BACKTRACE:
+                conf->log_backtrace = (unsigned) atoi(optarg);
+                break;
+
+            case ARG_EXIT_IDLE_TIME:
+                conf->exit_idle_time = atoi(optarg);
                 break;
 
             case ARG_SCACHE_IDLE_TIME:
@@ -298,28 +348,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_RESAMPLE_METHOD:
                 if (pa_daemon_conf_set_resample_method(conf, optarg) < 0) {
-                    pa_log("Invalid resample method '%s'.", optarg);
+                    pa_log(_("Invalid resample method '%s'."), optarg);
                     goto fail;
                 }
                 break;
 
             case ARG_SYSTEM:
-                if ((conf->system_instance = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--system expects boolean argument");
+                if ((conf->system_instance = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--system expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_NO_CPU_LIMIT:
-                if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--no-cpu-limit expects boolean argument");
+                if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--no-cpu-limit expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_DISABLE_SHM:
-                if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log("--disable-shm expects boolean argument");
+                if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--disable-shm expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -332,11 +382,6 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
     pa_xfree(conf->script_commands);
     conf->script_commands = pa_strbuf_tostring_free(buf);
 
-    if (!conf->script_commands) {
-        pa_xfree(conf->script_commands);
-        conf->script_commands = NULL;
-    }
-
     *d = optind;
 
     return 0;