]> code.delx.au - pulseaudio/blobdiff - src/daemon/cmdline.c
add i18n support
[pulseaudio] / src / daemon / cmdline.c
index 97c75f3711bcc936e418271a72fe4d88e0a006db..3121da60e7b9c341ecbd8de053dc7866ffa99aac 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -32,6 +30,7 @@
 #include <sys/stat.h>
 
 #include <pulse/xmalloc.h>
+#include <pulse/i18n.h>
 
 #include <pulsecore/core-util.h>
 #include <pulsecore/strbuf.h>
@@ -66,7 +65,8 @@ enum {
     ARG_DISABLE_SHM,
     ARG_DUMP_RESAMPLE_METHODS,
     ARG_SYSTEM,
-    ARG_CLEANUP_SHM
+    ARG_CLEANUP_SHM,
+    ARG_START
 };
 
 /* Tabel for getopt_long() */
@@ -91,6 +91,7 @@ static const struct option long_options[] = {
     {"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},
@@ -111,7 +112,7 @@ void pa_cmdline_help(const char *argv0) {
     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"
@@ -119,6 +120,7 @@ void pa_cmdline_help(const char *argv0) {
            "      --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"
 
@@ -159,7 +161,7 @@ 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"), e);
 }
 
 int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
@@ -207,6 +209,11 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
                 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;
@@ -231,14 +238,14 @@ 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) : TRUE) < 0) {
-                    pa_log("--daemonize expects boolean argument");
+                    pa_log(_("--daemonize expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_FAIL:
                 if ((conf->fail = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--fail expects boolean argument");
+                    pa_log(_("--fail expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -248,7 +255,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 {
@@ -260,28 +267,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_HIGH_PRIORITY:
                 if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--high-priority expects boolean argument");
+                    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");
+                    pa_log(_("--realtime expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_DISALLOW_MODULE_LOADING:
                 if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--disallow-module-loading expects boolean argument");
+                    pa_log(_("--disallow-module-loading expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_USE_PID_FILE:
                 if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--use-pid-file expects boolean argument");
+                    pa_log(_("--use-pid-file expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -298,7 +305,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             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'."));
                     goto fail;
                 }
                 break;
@@ -317,28 +324,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) : TRUE) < 0) {
-                    pa_log("--system expects boolean argument");
+                    pa_log(_("--system expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_NO_CPU_LIMIT:
                 if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--no-cpu-limit expects boolean argument");
+                    pa_log(_("--no-cpu-limit expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_DISABLE_SHM:
                 if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log("--disable-shm expects boolean argument");
+                    pa_log(_("--disable-shm expects boolean argument"));
                     goto fail;
                 }
                 break;