]> code.delx.au - pulseaudio/blobdiff - src/pulse/client-conf-x11.c
Merge commit 'coling/lgpl21'
[pulseaudio] / src / pulse / client-conf-x11.c
index 8cedc48b9a97d7ced660e9f9f0735f24b62937a4..3bec742f3ea5df08ac64cfeedc01ce2028214650 100644 (file)
@@ -1,11 +1,11 @@
-/* $Id$ */
-
 /***
   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,
+  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
 #endif
 
 #include <string.h>
-#include <assert.h>
 
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
 #include <pulse/xmalloc.h>
+#include <pulse/i18n.h>
 
 #include <pulsecore/x11prop.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "client-conf-x11.h"
 
@@ -42,11 +43,16 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     int ret = -1;
     char t[1024];
 
-    if (!dname && !getenv("DISPLAY"))
+    pa_assert(c);
+
+    if (!dname && !(dname = getenv("DISPLAY")))
         goto finish;
-    
+
+    if (*dname == 0)
+        goto finish;
+
     if (!(d = XOpenDisplay(dname))) {
-        pa_log("XOpenDisplay() failed");
+        pa_log(_("XOpenDisplay() failed"));
         goto finish;
     }
 
@@ -69,14 +75,14 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
         uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
 
         if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
-            pa_log("failed to parse cookie data");
+            pa_log(_("Failed to parse cookie data"));
             goto finish;
         }
 
-        assert(sizeof(cookie) == sizeof(c->cookie));
+        pa_assert(sizeof(cookie) == sizeof(c->cookie));
         memcpy(c->cookie, cookie, sizeof(cookie));
 
-        c->cookie_valid = 1;
+        c->cookie_valid = TRUE;
 
         pa_xfree(c->cookie_file);
         c->cookie_file = NULL;
@@ -89,5 +95,5 @@ finish:
         XCloseDisplay(d);
 
     return ret;
-    
+
 }