Add copyright notices to all relevant files. (based on svn log)
[profile/ivi/pulseaudio.git] / src / daemon / cmdline.c
index ab876ed..dc757c9 100644 (file)
@@ -2,17 +2,19 @@
 
 /***
   This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+
   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,
   or (at your option) any later version.
+
   PulseAudio is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
+
   You should have received a copy of the GNU Lesser General Public License
   along with PulseAudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -59,6 +61,8 @@ enum {
     ARG_KILL,
     ARG_USE_PID_FILE,
     ARG_CHECK,
+    ARG_NO_CPU_LIMIT,
+    ARG_DISABLE_SHM,
     ARG_SYSTEM
 };
 
@@ -86,6 +90,8 @@ static struct option long_options[] = {
     {"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},
     {NULL, 0, 0, 0}
 };
 
@@ -96,7 +102,7 @@ void pa_cmdline_help(const char *argv0) {
         e++;
     else
         e = argv0;
-    
+
     printf("%s [options]\n\n"
            "COMMANDS:\n"
            "  -h, --help                            Show this help\n"
@@ -120,7 +126,7 @@ void pa_cmdline_help(const char *argv0) {
            "      --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" 
+           "  -v                                    Increase the verbosity level\n"
            "      --log-target={auto,syslog,stderr} Specify the log target\n"
            "  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
            "                                        objects (plugins)\n"
@@ -128,7 +134,10 @@ void pa_cmdline_help(const char *argv0) {
            "                                        (one of src-sinc-medium-quality,\n"
            "                                        src-sinc-best-quality,src-sinc-fastest\n"
            "                                        src-zero-order-hold,src-linear,trivial)\n"
-           "      --use-pid-file[=BOOL]             Create a PID file\n\n"
+           "      --use-pid-file[=BOOL]             Create a PID file\n"
+           "      --no-cpu-limit[=BOOL]             Do not install CPU load limiter on\n"
+           "                                        platforms that support it.\n"
+           "      --disable-shm[=BOOL]              Disable shared memory support.\n\n"
 
            "STARTUP SCRIPT:\n"
            "  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
@@ -136,7 +145,7 @@ void pa_cmdline_help(const char *argv0) {
            "  -F, --file=FILENAME                   Run the specified script\n"
            "  -C                                    Open a command line on the running TTY\n"
            "                                        after startup\n\n"
-           
+
            "  -n                                    Don't load default script file\n", e);
 }
 
@@ -149,7 +158,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
     if (conf->script_commands)
         pa_strbuf_puts(buf, conf->script_commands);
-    
+
     while ((c = getopt_long(argc, argv, "L:F:ChDnp:kv", long_options, NULL)) != -1) {
         switch (c) {
             case ARG_HELP:
@@ -177,32 +186,32 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
             case ARG_CHECK:
                 conf->cmd = PA_CMD_CHECK;
                 break;
-                
+
             case ARG_LOAD:
             case 'L':
                 pa_strbuf_printf(buf, "load-module %s\n", optarg);
                 break;
-                
+
             case ARG_FILE:
             case 'F':
                 pa_strbuf_printf(buf, ".include %s\n", optarg);
                 break;
-                
+
             case 'C':
                 pa_strbuf_puts(buf, "load-module module-cli exit_on_eof=1\n");
                 break;
-                
+
             case ARG_DAEMONIZE:
             case 'D':
                 if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log(__FILE__": --daemonize expects boolean argument");
+                    pa_log("--daemonize expects boolean argument");
                     goto fail;
                 }
                 break;
 
             case ARG_FAIL:
                 if ((conf->fail = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log(__FILE__": --fail expects boolean argument");
+                    pa_log("--fail expects boolean argument");
                     goto fail;
                 }
                 break;
@@ -212,43 +221,43 @@ 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(__FILE__": --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 {
                     if (conf->log_level < PA_LOG_LEVEL_MAX-1)
                         conf->log_level++;
                 }
-                
+
                 break;
 
             case ARG_HIGH_PRIORITY:
                 if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
-                    pa_log(__FILE__": --high-priority expects boolean argument");
+                    pa_log("--high-priority 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(__FILE__": --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) : 1) < 0) {
-                    pa_log(__FILE__": --use-pid-file expects boolean argument");
+                    pa_log("--use-pid-file expects boolean argument");
                     goto fail;
                 }
                 break;
-                
+
             case 'p':
             case ARG_DL_SEARCH_PATH:
                 pa_xfree(conf->dl_search_path);
                 conf->dl_search_path = *optarg ? pa_xstrdup(optarg) : NULL;
                 break;
-                
+
             case 'n':
                 pa_xfree(conf->default_script_file);
                 conf->default_script_file = NULL;
@@ -256,7 +265,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(__FILE__": Invalid log target: use either 'syslog', 'stderr' or 'auto'.");
+                    pa_log("Invalid log target: use either 'syslog', 'stderr' or 'auto'.");
                     goto fail;
                 }
                 break;
@@ -275,18 +284,32 @@ 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(__FILE__": 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(__FILE__": --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) : 1) < 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");
+                    goto fail;
+                }
+                break;
+
             default:
                 goto fail;
         }
@@ -301,12 +324,12 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
     }
 
     *d = optind;
-    
+
     return 0;
-    
+
 fail:
     if (buf)
         pa_strbuf_free(buf);
-    
+
     return -1;
 }