]> code.delx.au - pulseaudio/blobdiff - src/pulse/client-conf.c
add i18n support
[pulseaudio] / src / pulse / client-conf.c
index bb9123359d1be920e49d4d8cc1679908d9879324..739ef1610aae0e8674a02d4092429fb54f070891 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
 
-#include <pulsecore/core-error.h>
 #include <pulse/xmalloc.h>
+#include <pulse/i18n.h>
 
+#include <pulsecore/macro.h>
+#include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
 #include <pulsecore/conf-parser.h>
 #include <pulsecore/core-util.h>
 
 #include "client-conf.h"
 
-#ifndef OS_IS_WIN32
-# define PATH_SEP "/"
-#else
-# define PATH_SEP "\\"
-#endif
-
-#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PATH_SEP "client.conf"
+#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "client.conf"
 #define DEFAULT_CLIENT_CONFIG_FILE_USER "client.conf"
 
 #define ENV_CLIENT_CONFIG_FILE "PULSE_CLIENTCONFIG"
@@ -64,24 +57,24 @@ static const pa_client_conf default_conf = {
     .default_sink = NULL,
     .default_source = NULL,
     .default_server = NULL,
-    .autospawn = 0,
-    .disable_shm = 0,
+    .autospawn = TRUE,
+    .disable_shm = FALSE,
     .cookie_file = NULL,
-    .cookie_valid = 0,
+    .cookie_valid = FALSE,
 };
 
 pa_client_conf *pa_client_conf_new(void) {
     pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
 
     c->daemon_binary = pa_xstrdup(PA_BINARY);
-    c->extra_arguments = pa_xstrdup("--log-target=syslog --exit-idle-time=5");
+    c->extra_arguments = pa_xstrdup("--log-target=syslog");
     c->cookie_file = pa_xstrdup(PA_NATIVE_COOKIE_FILE);
 
     return c;
 }
 
 void pa_client_conf_free(pa_client_conf *c) {
-    assert(c);
+    pa_assert(c);
     pa_xfree(c->daemon_binary);
     pa_xfree(c->extra_arguments);
     pa_xfree(c->default_sink);
@@ -90,6 +83,7 @@ void pa_client_conf_free(pa_client_conf *c) {
     pa_xfree(c->cookie_file);
     pa_xfree(c);
 }
+
 int pa_client_conf_load(pa_client_conf *c, const char *filename) {
     FILE *f = NULL;
     char *fn = NULL;
@@ -117,13 +111,20 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
     table[6].data = &c->cookie_file;
     table[7].data = &c->disable_shm;
 
-    f = filename ?
-        fopen((fn = pa_xstrdup(filename)), "r") :
-        pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r");
+    if (filename) {
+
+        if (!(f = fopen(filename, "r"))) {
+            pa_log(_("Failed to open configuration file '%s': %s"), fn, pa_cstrerror(errno));
+            goto finish;
+        }
 
-    if (!f && errno != EINTR) {
-        pa_log("WARNING: failed to open configuration file '%s': %s", fn, pa_cstrerror(errno));
-        goto finish;
+        fn = pa_xstrdup(fn);
+
+    } else {
+
+        if (!(f = pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn)))
+            if (errno != ENOENT)
+                goto finish;
     }
 
     r = f ? pa_config_parse(fn, f, table, NULL) : 0;
@@ -131,7 +132,6 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
     if (!r)
         r = pa_client_conf_load_cookie(c);
 
-
 finish:
     pa_xfree(fn);
 
@@ -175,17 +175,16 @@ int pa_client_conf_env(pa_client_conf *c) {
 }
 
 int pa_client_conf_load_cookie(pa_client_conf* c) {
-    assert(c);
-
-    c->cookie_valid = 0;
+    pa_assert(c);
 
     if (!c->cookie_file)
         return -1;
 
+    c->cookie_valid = FALSE;
+
     if (pa_authkey_load_auto(c->cookie_file, c->cookie, sizeof(c->cookie)) < 0)
         return -1;
 
-    c->cookie_valid = 1;
+    c->cookie_valid = TRUE;
     return 0;
 }
-